00001 #include <DemangleWrapper.h> 00002 #include <StringTable.h> 00003 #include <BinaryFile.h> 00004 00005 char* StringTable::getString(uint32_t offset){ 00006 PRINT_DEBUG("Offset is %d in %d",offset,sizeInBytes); 00007 ASSERT(offset < sizeInBytes); 00008 if(!offset) 00009 return ""; 00010 return stringTablePtr+offset; 00011 } 00012 00013 void StringTable::print() { 00014 PRINT_INFOR("STRINGTABLE"); 00015 if(stringTablePtr && sizeInBytes){ 00016 PRINT_INFOR("\tSize : %d",sizeInBytes); 00017 } else { 00018 PRINT_INFOR("\tSize : 0 EMPTY"); 00019 } 00020 00021 PRINT_INFOR("\tStrs :"); 00022 for(uint32_t currByte = sizeof(uint32_t);currByte<sizeInBytes;currByte++){ 00023 char* ptr = (char*)(stringTablePtr+currByte); 00024 DemangleWrapper wrapper; 00025 char* demangled = wrapper.demangle_combined(ptr); 00026 ASSERT(demangled && "FATAL : demangling should always return non-null pointer"); 00027 00028 PRINT_INFOR("%9d %s --- %s",currByte,ptr,demangled); 00029 00030 currByte += strlen(ptr); 00031 } 00032 } 00033 00034 uint32_t StringTable::read(BinaryInputFile* binaryInputFile){ 00035 00036 binaryInputFile->setInPointer(stringTablePtr); 00037 setFileOffset(binaryInputFile->currentOffset()); 00038 00039 binaryInputFile->copyBytes(&sizeInBytes,sizeof(uint32_t)); 00040 DEBUG( 00041 uint32_t left = binaryInputFile->bytesLeftInBuffer(); 00042 PRINT_DEBUG("%d bytesleft to the end and total string table size is %d",left,sizeInBytes); 00043 ASSERT((left == sizeInBytes) && "FATAL : Number of bytes in string table does not match"); 00044 ); 00045 return sizeInBytes; 00046 }