// Return a random string from the BWT std::string BWTAlgorithms::sampleRandomString(const BWT* pBWT) { assert(RAND_MAX > 0x7FFF); size_t n = pBWT->getNumStrings(); size_t idx = rand() % n; return extractString(pBWT, idx); }
int main(int argc, char const *argv[]) { /* code */ char * myString = "x33.333_y-43.222_z10"; triordinate myCoords = extractString(myString); printf("The Coordinates were: X:%lf Y:%lf Z:%lf\n", myCoords.x, myCoords.y, myCoords.z); }
// Return a random string from the BWT std::string BWTAlgorithms::sampleRandomString(const BWT* pBWT, size_t len) { size_t n = pBWT->getNumStrings(); assert(RAND_MAX >= n); size_t idx = rand() % n; return extractString(pBWT, idx, len); }
void HWInformation::parseOperation (const xmlpp::Node *node, std::string opName) { unsigned int size = 0; std::vector < std::string > vectPossibility; //Recurse through child nodes: xmlpp::Node::NodeList list = node->get_children (); for (xmlpp::Node::NodeList::iterator iter = list.begin (); iter != list.end (); ++iter) { const xmlpp::Node *tmp = *iter; //Be paranoid assert (tmp != NULL); if (verifyCanGetName (tmp)) { if (verifyNodeName (tmp, "size")) { size = convertStringInt (extractString (tmp)); } else if (verifyNodeName (tmp, "possibility")) { vectPossibility.push_back (extractString (tmp)); } else { Logging::log (1, "HWInformation: Warning: Node not handled in MDL parseOperation of HWInformation", NULL); } } } //Add the operation to the map std::map<std::pair<std::string, int>, std::vector<std::string> >::const_iterator it; std::pair<std::string, int> val; val = make_pair (opName, size); it = operation_possibility.find (val); //Check if not yet there if (it != operation_possibility.end ()) { Logging::log (1, "HWInformation: Warning: operation already defined", NULL); } operation_possibility[val] = vectPossibility; }
/* Return a new Value from the given value, and make a copy of a string inside persistent memory (not in the pool) if any. */ Value extractValue(const Value *const value) { if(value->type == STRING) { Value copy = *value; copy.data.string = extractString(value->data.string, NULL); return copy; } else return *value; }
/** * Returns string of the variable with a given id and offset **/ std::string NameManager::getStrName(id_offset id) { name_map::iterator it = id_to_inst.find(id); std::string res; assert(it != id_to_inst.end() && "getStrName: not recognized instruction id with given offset."); if (it != id_to_inst.end()) res = extractString(it->second->GetOperand(getStringPosition(it->second->opcode())).words); return res; }
float LogisticsComponent::extractFloat(PSTR& pFileLine) { char buffer[1024]; int32_t count = extractString(pFileLine, buffer, 1024); if (count > 0) { return atof(buffer); } return -1; }
bool JsonParser::extractString(JsonNode &node) { std::string str; if (!extractString(str)) return false; node.setType(JsonNode::DATA_STRING); node.String() = str; return true; }
bool extractOneHeaderTriple (std::istream & sourceFile, DataHeaderParameter & oneDHParameter) { std::string dummyString; std::wstring dummyWstring; extractWstring(sourceFile, dummyWstring); oneDHParameter.setParamName(dummyWstring); extractString(sourceFile, dummyString); oneDHParameter.setParamValue(dummyString); extractWstring(sourceFile, dummyWstring); oneDHParameter.setParamType(dummyWstring); return true; }
int LogisticsComponent::extractInt( char*& pFileLine ) { char buffer[1024]; int count = extractString( pFileLine, buffer, 1024 ); if ( count > 0 ) { return atoi( buffer ); } return -1; }
void testExtractString() { Token token; char text[] = "'hello world' '\\n' r'\\n'", *p; p = text; token.type = TOKEN_TYPE_UNKNOWN; skipSpaces(&p); assert(extractString(&p, &token)); assert(token.type == TOKEN_TYPE_STR); assert(strcmp(token.value.string, "hello world") == 0); token.type = TOKEN_TYPE_UNKNOWN; skipSpaces(&p); assert(extractString(&p, &token)); assert(token.type == TOKEN_TYPE_STR); assert(strcmp(token.value.string, "\n") == 0); token.type = TOKEN_TYPE_UNKNOWN; skipSpaces(&p); assert(extractString(&p, &token)); assert(token.type == TOKEN_TYPE_STR); assert(strcmp(token.value.string, "\\n") == 0); }
// Return a random string from the BWT std::string BWTAlgorithms::sampleRandomSubstring(const BWT* pBWT, size_t len) { assert(RAND_MAX > 0x7FFF); size_t tries = 1000; while(1 && tries-- > 0) { size_t n = pBWT->getBWLen(); size_t idx = rand() % n; std::string s = extractString(pBWT, idx, len); if(s.size() == len) return s; } return ""; }
bool extractGenericDataHeader(std::istream & sourceFile, std::vector<DataHeaderParameter> & vectorToStoreParameters) { std::string dataTypeID; std::string fileGUID; std::wstring timeOfCreation; std::wstring fileLocale; int parentHeaderCount; extractString(sourceFile, dataTypeID); extractString(sourceFile, fileGUID); extractWstring(sourceFile, timeOfCreation); extractWstring(sourceFile, fileLocale); extractNameTypeValueTrips(sourceFile, vectorToStoreParameters); // Extract and ignore parent Generic Data Headers bool parentRecordsExtracted = true; std::vector<DataHeaderParameter> parentParamVector; parentHeaderCount = extractInt(sourceFile); parentParamVector.reserve(parentHeaderCount); for (int i = 0; i < parentHeaderCount; i++) { parentRecordsExtracted &= extractGenericDataHeader(sourceFile, parentParamVector); } return parentRecordsExtracted; }
static int extractInteger ( const char *startCharacter, const char *onePastEnd ) { int rVal; char *lexeme; if (!(lexeme = extractString(startCharacter, onePastEnd))) return 0; rVal = atoi(lexeme); free(lexeme); return rVal; }
static float extractFloat ( const char * startCharacter, const char * onePastEnd ) { float rVal; char *lexeme; if (!(lexeme = extractString(startCharacter, onePastEnd))) return 0.0; rVal = atof(lexeme); free(lexeme); return rVal; }
void testExtractNumber() { Token token; char text[] = "123 54", *p = text; token.type = TOKEN_TYPE_UNKNOWN; skipSpaces(&p); assert(!extractString(&p, &token)); assert(extractNumber(&p, &token)); assert(token.type == TOKEN_TYPE_NUM); assert(token.value.number == 123); token.type = TOKEN_TYPE_UNKNOWN; skipSpaces(&p); assert(extractNumber(&p, &token)); assert(token.type == TOKEN_TYPE_NUM); assert(token.value.number == 54); }
KJS::Value MyCustomObjectImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) { kdDebug() << "MyCustomObjectImp::call() " << mid << endl; JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() ); if ( !op ) { kdWarning() << "MyCustomObjectImp::call() failed, not a JSOpaqueProxy" << endl; return KJS::Value(); } if ( op->typeName() != "MyCustomObject" ) { kdWarning() << "MyCustomObjectImp::call() failed, type is " << op->typeName() << endl; return KJS::Value(); } MyCustomObject *obj = op->toNative<MyCustomObject>(); KJS::Value retValue = KJS::Value(); switch ( mid ) { case Methodthing: { retValue = KJS::String(obj->thing); break; } case MethodsetThing: { obj->thing = extractString(exec, args, 0); break; } case Methodmode: { retValue = KJS::Number( (int)obj->mode ); break; } case MethodsetMode: { obj->mode = (MyCustomObject::Mode) extractInt(exec, args, 0); break; } default: kdWarning() << "MyCustomObject has no method " << mid << endl; break; } op->setValue((void*) obj, "MyCustomObject"); return retValue; }
/* Returns a new Value form the given Value, and simplifies a string, if any, if possible, to a primitive. */ Value extractSimplifiedValue(const Value *const value) { if(value->type == STRING) { Value copy; if(strTryToFloating(value->data.string, &t.f)) { copy.type = FLOATING; copy.data.floating = t.f; } else if(strTryToBoolean(value->data.string, &t.b)) { copy.type = BOOLEAN; copy.data.boolean = t.b; } else { copy.type = STRING; copy.data.string = extractString(value->data.string, NULL); } return copy; } else return *value; }
bool JsonParser::extractStruct(JsonNode &node) { node.setType(JsonNode::DATA_STRUCT); pos++; if (!extractWhitespace()) return false; //Empty struct found if (input[pos] == '}') { pos++; return true; } while (true) { if (!extractWhitespace()) return false; std::string key; if (!extractString(key)) return false; if (node.Struct().find(key) != node.Struct().end()) error("Dublicated element encountered!", true); if (!extractSeparator()) return false; if (!extractElement(node.Struct()[key], '}')) return false; if (input[pos] == '}') { pos++; return true; } } }
bool JsonParser::extractValue(JsonNode &node) { if (!extractWhitespace()) return false; switch (input[pos]) { case '\"': return extractString(node); case 'n' : return extractNull(node); case 't' : return extractTrue(node); case 'f' : return extractFalse(node); case '{' : return extractStruct(node); case '[' : return extractArray(node); case '-' : return extractFloat(node); default: { if (input[pos] >= '0' && input[pos] <= '9') return extractFloat(node); return error("Value expected!"); } } }
int loadTokens(Machine *machine, char *string) { skipSpaces(&string); while (*string != '\0') { Token *token; if (machine->tokensSize >= machine->tokensCapacity) { machine->tokensCapacity = 2*machine->tokensCapacity+10; machine->tokens = (Token*) realloc(machine->tokens, sizeof(Token)*machine->tokensCapacity); } token = machine->tokens+machine->tokensSize++; if (!(extractString(&string, token) || extractNumber(&string, token) || extractName(&string, token))) { /* Error */ return 0; } skipSpaces(&string); } return 1; }
String VTTScanner::restOfInputAsString() { Run rest(position(), end(), m_is8Bit); return extractString(rest); }
std::map<std::string, std::string> loadPOFile(SDL_RWops* rwop, bool freesrc, std::string filename) { std::map<std::string, std::string> mapping; if(rwop == NULL) { fprintf(stderr, "%s: Cannot find this file!\n", filename.c_str()); return mapping; } std::string msgid; std::string msgstr; bool msgidMode = false; bool msgstrMode = false; int lineNum = 0; bool bFinished = false; while(!bFinished) { lineNum++; std::string completeLine; unsigned char tmp; int readbytes; while(1) { readbytes = SDL_RWread(rwop,&tmp,1,1); if(readbytes <= 0) { bFinished = true; break; } else if(tmp == '\n') { break; } else if(tmp != '\r') { completeLine += tmp; } } size_t lineStart = completeLine.find_first_not_of(" \t"); if(lineStart == std::string::npos || completeLine[lineStart] == '#') { // blank line or comment line continue; } if(completeLine.substr(lineStart, 5) == "msgid") { if(msgidMode == true) { fprintf(stderr, "%s:%d: Opening a new msgid without finishing the previous one!\n", filename.c_str(), lineNum); } else if(msgstrMode == true) { // we have finished the previous translation mapping[msgid] = msgstr; msgid = ""; msgstr = ""; msgstrMode = false; } msgid = extractString(completeLine.substr(lineStart + 5), filename, lineNum); msgidMode = true; } else if(completeLine.substr(lineStart, 6) == "msgstr") { msgidMode = false; msgstr = extractString(completeLine.substr(lineStart + 6), filename, lineNum); msgstrMode = true; } else { if(msgidMode) { msgid += extractString(completeLine, filename, lineNum); } else if(msgstrMode) { msgstr += extractString(completeLine, filename, lineNum); } } } if(msgstrMode == true) { // we have a last translation to finish mapping[msgid] = msgstr; msgid = ""; msgstr = ""; msgstrMode = false; } if(freesrc) { SDL_RWclose(rwop); } return mapping; }
bool CMessages::extractEp4Strings(std::map<std::string, std::string>& StringMap) { switch(m_version) { case 140: { // Level loading Texts (2E00) setDecodeOffset(0x1F1F0); StringMap.insert( extractNextString( "WORLDMAP_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL1_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL2_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL3_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL4_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL5_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL6_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL7_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL8_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL9_LOAD_TEXT" ) ); StringMap.insert( extractNextString( "LEVEL10_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL11_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL12_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL13_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL14_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL15_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL16_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL17_LOAD_TEXT") ); StringMap.insert( extractNextString( "LEVEL18_LOAD_TEXT") ); // Elder Janitor Text. Strangely it is the end of the level load text being to only // in that data segment StringMap.insert( extractNextString( "JANITOR_TEXT1" ) ); StringMap.insert( extractNextString( "JANITOR_TEXT2" ) ); StringMap.insert( extractNextString( "JANITOR_TEXT3" ) ); StringMap.insert( extractNextString( "JANITOR_TEXT4" ) ); // Now the spoken Messages of some Characters like Lindsey and the elders StringMap.insert( extractString( "LINDSEY_TEXT1", 0x3094B, 0x30997 ) ); StringMap.insert( extractString( "LINDSEY_TEXT2", 0x30999, 0x309E1 ) ); StringMap.insert( extractString( "LINDSEY_END_TEXT1", 0x309E3, 0x309F9 ) ); StringMap.insert( extractString( "LINDSEY_END_TEXT2", 0x309FA, 0x30A22 ) ); StringMap.insert( extractString( "LINDSEY_START_TEXT", 0x30A23, 0x30A3B ) ); StringMap.insert( extractString( "CANT_SWIM_TEXT", 0x30A3D, 0x30A4A ) ); StringMap.insert( extractString( "SWIM_SUIT_TEXT", 0x30A4B, 0x30A72 ) ); StringMap.insert( extractString( "KEEN_NOSWEAT_TEXT", 0x30A71, 0x30A91 ) ); StringMap.insert( extractString( "KEEN_BEARDED_ONE_TEXT", 0x30A92, 0x30AB2 ) ); StringMap.insert( extractString( "KEEN_NO_PROBLEMO_TEXT", 0x30AB3, 0x30ABF ) ); StringMap.insert( extractString( "KEEN_GREAT_TEXT", 0x30AC0, 0x30AC7 ) ); StringMap.insert( extractString( "KEEN_LOOKS_LIKE_SAME_GUY_TEXT", 0x30AC8, 0x30AFF ) ); StringMap.insert( extractString( "KEEN_GOOD_IDEA_GRAMPS", 0x30B00, 0x30B12 ) ); StringMap.insert( extractString( "KEEN_ROAD_RISE_FEET_TEXT", 0x30B13, 0x30B43 ) ); StringMap.insert( extractString( "KEEN_WISE_PLAN_TEXT", 0x30B44, 0x30B6A ) ); StringMap.insert( extractString( "KEEN_LAST_ELDER_TEXT", 0x30B6B, 0x30BB2 ) ); StringMap.insert( extractString( "ELDERS_UNDERWATER_TEXT", 0x30BB3, 0x30C16 ) ); StringMap.insert( extractString( "ELDERS_TEXT", 0x30C17, 0x30C6A ) ); return true; } break; } return false; }
int32_t LogisticsComponent::init(PSTR dataLine) { PSTR line = dataLine; PSTR pLine = line; char pBuffer[1025]; ID = (extractInt(pLine)); // the type extractString(pLine, pBuffer, 1024); int32_t i; for (i = 0; i < NUM_COMPONENT_FORMS; ++i) { if (0 == _stricmp(ComponentFormString[i], pBuffer)) { Type = i; break; } } if (i == NUM_COMPONENT_FORMS) return -1; // name, probably aren't going to use this, they should be in the RC. extractString(pLine, pBuffer, 1024); // name, probably aren't going to use this, they should be in the RC. extractString(pLine, pBuffer, 1024); // ignore critical hits recycleTime = extractFloat(pLine); heat = extractFloat(pLine); // weight weight = extractFloat(pLine); damage = extractFloat(pLine); // ignore battle rating extractString(pLine, pBuffer, 1024); // cost cost = extractInt(pLine); // range extractString(pLine, pBuffer, 1024); if (!isWeapon()) rangeType = NO_RANGE; else if (!strcmp(pBuffer, "int32_t")) rangeType = int32_t; else if (!strcmp(pBuffer, "medium")) rangeType = MEDIUM; else rangeType = int16_t; // we need to figure out where things can go extractString(pLine, pBuffer, 1024); bHead = _stricmp(pBuffer, "Yes") ? false : true; extractString(pLine, pBuffer, 1024); bTorso = _stricmp(pBuffer, "Yes") ? false : true; // ignore the next 4 columns for (i = 0; i < 4; ++i) extractString(pLine, pBuffer, 1024); extractString(pLine, pBuffer, 1024); bLegs = _stricmp(pBuffer, "Yes") ? false : true; // ignore the next 4 columns for (i = 0; i < 4; ++i) extractString(pLine, pBuffer, 1024); Ammo = extractInt(pLine); // now read in icon info extractString(pLine, pBuffer, 1024); if (*pBuffer && (pBuffer[0] != '0')) { iconFileName = new char[strlen(pBuffer) + 1]; strcpy(iconFileName, pBuffer); } else return -1; // fail if no picture extractString(pLine, pBuffer, 1024); if (*pBuffer) { pictureFileName = new char[strlen(pBuffer) + 1]; // Forgot the nullptr all over the place did we? strcpy(pictureFileName, pBuffer); } stringID = extractInt(pLine); helpStringID = extractInt(pLine); iconX = extractInt(pLine); iconY = extractInt(pLine); char nameBuffer[256]; cLoadString(stringID, nameBuffer, 256); name = flavorText = new char[strlen(nameBuffer) + 1]; // Lets not forget the nullptr!!! strcpy(name, nameBuffer); return ID; }
bool CMessages::extractEp4Strings(std::map<std::string, std::string>& StringMap) { switch(m_version) { case 140: { // TODO: Copy of the Episode 1 Strings. Here the Episode 4 Strings needs the adaptations // Level loading Texts StringMap.insert( extractString( "WORLDMAP_LOAD_TEXT", 0x21FF0, 0x2200F ) ); StringMap.insert( extractString( "LEVEL1_LOAD_TEXT", 0x22010, 0x2203F ) ); StringMap.insert( extractString( "LEVEL2_LOAD_TEXT", 0x22040, 0x2205F ) ); StringMap.insert( extractString( "LEVEL3_LOAD_TEXT", 0x22060, 0x2208F ) ); StringMap.insert( extractString( "LEVEL4_LOAD_TEXT", 0x22090, 0x220CF ) ); StringMap.insert( extractString( "LEVEL5_LOAD_TEXT", 0x220D0, 0x220FF ) ); StringMap.insert( extractString( "LEVEL6_LOAD_TEXT", 0x22100, 0x2212F ) ); StringMap.insert( extractString( "LEVEL7_LOAD_TEXT", 0x22130, 0x2214F ) ); StringMap.insert( extractString( "LEVEL8_LOAD_TEXT", 0x22150, 0x2217F ) ); StringMap.insert( extractString( "LEVEL9_LOAD_TEXT", 0x22180, 0x2219F ) ); StringMap.insert( extractString( "LEVEL10_LOAD_TEXT", 0x221A0, 0x221CF ) ); StringMap.insert( extractString( "LEVEL11_LOAD_TEXT", 0x221D0, 0x221FF ) ); StringMap.insert( extractString( "LEVEL12_LOAD_TEXT", 0x22200, 0x2222F ) ); StringMap.insert( extractString( "LEVEL13_LOAD_TEXT", 0x22230, 0x2226F ) ); StringMap.insert( extractString( "LEVEL14_LOAD_TEXT", 0x22270, 0x222AF ) ); StringMap.insert( extractString( "LEVEL15_LOAD_TEXT", 0x222B0, 0x222DF ) ); StringMap.insert( extractString( "LEVEL16_LOAD_TEXT", 0x222E0, 0x2230F ) ); StringMap.insert( extractString( "LEVEL17_LOAD_TEXT", 0x22310, 0x2233f ) ); StringMap.insert( extractString( "LEVEL18_LOAD_TEXT", 0x22340, 0x2237F ) ); } break; } }
static void XaviLexerLoad(XaviLexer *lexer) { XaviDfaState dfaState = DFA_START; const char *current = lexer->location; if (lexer->token == EOL || lexer->token == ERROR) return; while (dfaState != DFA_END) switch (dfaState) { case DFA_END: break; case DFA_START: if(isOperator(*current)) { current++; dfaState = DFA_TERM_CHAR; } else if (*current == 'd') { current++; dfaState = DFA_DICE; } else if (*current == 'e') { current++; dfaState = DFA_E; } else if (*current == 'p') { current++; dfaState = DFA_PI_1; } else if (isdigit(*current)) { current++; dfaState = DFA_INTEGER; } else if (isalpha(*current)) { current++; dfaState = DFA_ID; } else if (isspace(*current)) { lexer->location++; current++; } else if (*current == '\0') { dfaState = DFA_TERM_EOI; } else { dfaState = DFA_ERROR; } break; case DFA_DICE: if (isalpha(*current)) { current++; dfaState = DFA_ID; } else { dfaState = DFA_TERM_CHAR; } break; case DFA_E: if (isalnum(*current)) { current++; dfaState = DFA_ID; } else { dfaState = DFA_TERM_E; } break; case DFA_PI_1: if (*current == 'i') { current++; dfaState = DFA_PI_2; } else if (isIdCharacter(*current)) { current++; dfaState = DFA_ID; } else { dfaState = DFA_TERM_STRING; } break; case DFA_PI_2: if (isIdCharacter(*current)) { current++; dfaState = DFA_ID; } else { dfaState = DFA_TERM_PI; } break; case DFA_ID: if (isalnum(*current)) { current++; } else { dfaState = DFA_TERM_STRING; } break; case DFA_INTEGER: if (*current == '.') { current++; dfaState = DFA_FLOAT; } else if (isdigit(*current)) { current++; } else { dfaState = DFA_TERM_INTEGER; } break; case DFA_FLOAT: if (isdigit(*current)) { current++; } else { dfaState = DFA_TERM_FLOAT; } break; case DFA_TERM_INTEGER: lexer->token = INTEGER; lexer->value.i = extractInteger(lexer->location, current); dfaState = DFA_END; break; case DFA_TERM_FLOAT: lexer->token = FLOAT; lexer->value.f = extractFloat(lexer->location, current); dfaState = DFA_END; break; case DFA_TERM_E: lexer->token = FLOAT; lexer->value.f = EULER; dfaState = DFA_END; break; case DFA_TERM_PI: lexer->token = FLOAT; lexer->value.f = PI; dfaState = DFA_END; break; case DFA_TERM_CHAR: lexer->token = *lexer->location; lexer->value.i = 0; dfaState = DFA_END; break; case DFA_TERM_STRING: lexer->token = ID; lexer->value.s = extractString(lexer->location, current); dfaState = DFA_END; break; case DFA_TERM_EOI: lexer->token = EOL; lexer->value.i = 0; dfaState = DFA_END; break; case DFA_ERROR: lexer->token = ERROR; lexer->value.i = 0; dfaState = DFA_END; break; } lexer->location = current; }
void HWInformation::parseRegister (const xmlpp::Node *node) { std::string vname = ""; std::string pname = ""; //Recurse through child nodes: xmlpp::Node::NodeList list = node->get_children (); for (xmlpp::Node::NodeList::iterator iter = list.begin (); iter != list.end (); ++iter) { const xmlpp::Node *tmp = *iter; //Paranoid assert (tmp != NULL); if (verifyCanGetName (tmp)) { if (verifyNodeName (tmp, "virtual")) { vname = extractString (tmp); } else { if (verifyNodeName (tmp, "physical")) { pname = extractString (tmp); } else { Logging::log (1, "HWInformation: Warning: Unsupported name '", extractNodeName (tmp).c_str (), "' in register node at: ", getLine (tmp).c_str (), NULL); } } } } //Ok now check what we have if (vname[0] == '\0') { Logging::log (1, "Warning: virtual register is empty, register ignored", NULL); } if (pname[0] == '\0') { Logging::log (1, "Warning: virtual register is empty, register ignored", NULL); } //Now actually add it if both are not empty if (vname[0] != '\0' && pname[0] != '\0') { //Check if not yet there std::map<std::string, std::string>::const_iterator it; it = register_association.find (vname); if (it != register_association.end ()) { Logging::log (1, "Warning: virtual register already defined", NULL); } register_association[vname] = pname; } }
bool CMessages::extractGlobalStrings() { std::map<std::string, std::string> StringMap; // Structure which stores all the extracted string // Here we begin to extract all the proper Strings switch(m_episode) { case 1: { switch(m_version) { case 131: { StringMap.insert( extractString( "CTSPACECHEAT", 0x14DEE, 0x14E51 ) ); StringMap.insert( extractString( "GODMODEON", 0x14EF6, 0x14F06 ) ); StringMap.insert( extractString( "GODMODEOFF", 0x14F07, 0x14F18 ) ); StringMap.insert( extractString( "EP1_StatusBox" , 0x15052, 0x150F5, -512 ) ); StringMap.insert( extractString( "EP1_SHIP" , 0x1679B, 0x167D3, -512 ) ); StringMap.insert( extractString( "LIVES_LEFT" , 0x160D8, 0x160E5, -512 ) ); // Message hint Dialogs StringMap.insert( extractString( "EP1_YSIYM_LVL2" , 0x15280, 0x15314, -512 ) ); StringMap.insert( extractString( "EP1_YSIYM_LVL6" , 0x1531A, 0x153B2, -512 ) ); StringMap.insert( extractString( "EP1_YSIYM_LVL9" , 0x153B4, 0x1544C, -512 ) ); StringMap.insert( extractString( "EP1_YSIYM_LVL10" , 0x1544E, 0x154E6, -512 ) ); StringMap.insert( extractString( "EP1_YSIYM_LVL11" , 0x154E8, 0x1553E, -512 ) ); StringMap.insert( extractString( "EP1_YSIYM_LVL12" , 0x15540, 0x155D9, -512 ) ); StringMap.insert( extractString( "EP1_YSIYM_LVL15" , 0x155DB, 0x1565D, -512 ) ); // Finale Text StringMap.insert( extractString( "EP1_ESEQ_PART1" , 0x15E24, 0x15EB0, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE1" , 0x15EBD, 0x15EFA, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE2" , 0x15EFB, 0x15F2F, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE3" , 0x15F30, 0x15F7E, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE4" , 0x15F7F, 0x15F9B, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE5" , 0x15F9C, 0x15FE1, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE6" , 0x15FE2, 0x15FF5, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE7" , 0x15FF6, 0x16006, -512 ) ); StringMap.insert( extractString( "EP1_ESEQ_PART2_PAGE8" , 0x16007, 0x16071, -512 ) ); StringMap.insert( extractString( "TO_BE_CONTINUED" , 0x16072, 0x16085, -512 ) ); } break; } } break; case 2: { switch(m_version) { case 131: { StringMap.insert( extractString( "CTSPACECHEAT", 0x19AC6, 0x19B1B, -512 ) ); StringMap.insert( extractString( "GODMODEON", 0x19BE4, 0x19BF4, -512 ) ); StringMap.insert( extractString( "GODMODEOFF", 0x19BF5, 0x19C06, -512 ) ); StringMap.insert( extractString( "EP2_StatusBox" , 0x19C40, 0x19CCE, -804 ) ); StringMap.insert( extractString( "LIVES_LEFT" , 0x1A9B2, 0x1A9BF, -776 ) ); StringMap.insert( extractString( "EP2_VE_NOJUMPINDARK" , 0x1A2D2, 0x1A391, -774 ) ); StringMap.insert( extractString( "EP2_VE_EVILBELTS" , 0x1A391, 0x1A4A6, -774) ); StringMap.insert( extractString( "EP2_LVL4_TargetName" , 0x19CCF, 0x19CD5, -804) ); StringMap.insert( extractString( "EP2_LVL6_TargetName" , 0x19CD6, 0x19CDB, -804) ); StringMap.insert( extractString( "EP2_LVL7_TargetName" , 0x19CDC, 0x19CE2, -804) ); StringMap.insert( extractString( "EP2_LVL9_TargetName" , 0x19CE3, 0x19CEB, -804) ); StringMap.insert( extractString( "EP2_LVL11_TargetName" , 0x19CEC, 0x19CF1, -804) ); StringMap.insert( extractString( "EP2_LVL13_TargetName" , 0x19CF2, 0x19CF6, -804) ); StringMap.insert( extractString( "EP2_LVL15_TargetName" , 0x19CF7, 0x19CFD, -804) ); StringMap.insert( extractString( "EP2_LVL16_TargetName" , 0x19CFE, 0x19D07, -804) ); // Message Boxes StringMap.insert( extractString( "EP2_ESEQ_PART1" , 0x1A4A7, 0x1A558, -774) ); StringMap.insert( extractString( "EP2_ESEQ_PART2" , 0x1A559, 0x1A5F0, -774) ); StringMap.insert( extractString( "EP2_ESEQ_PART3_PAGE1" , 0x1A5FD, 0x1A638, -774) ); StringMap.insert( extractString( "EP2_ESEQ_PART3_PAGE2" , 0x1A639, 0x1A6CD, -774) ); StringMap.insert( extractString( "EP2_ESEQ_PART3_PAGE3" , 0x1A6CF, 0x1A72D, -774) ); StringMap.insert( extractString( "EP2_ESEQ_PART3_PAGE4" , 0x1A72F, 0x1A739, -774) ); StringMap.insert( extractString( "TO_BE_CONTINUED" , 0x1A73A, 0x1A74D, -774 ) ); } break; } } break; case 3: { switch(m_version) { case 131: { StringMap.insert( extractString( "CTSPACECHEAT", 0x1BC9E, 0x1BCF3, -512 ) ); StringMap.insert( extractString( "GODMODEON", 0x1BD80, 0x1BD90, -512 ) ); StringMap.insert( extractString( "GODMODEOFF", 0x1BD91, 0x1BDA2, -512 ) ); StringMap.insert( extractString( "EP3_StatusBox" , 0x1BCF4, 0x1BD7F, -512 ) ); StringMap.insert( extractString( "LIVES_LEFT" , 0x1CAEE, 0x1CAFB, -806 ) ); // Ship Messages StringMap.insert( extractString( "EP3_SHIP1" , 0x1D100, 0x1D173, -765) ); StringMap.insert( extractString( "EP3_SHIP2" , 0x1D174, 0x1D1D1, -765) ); StringMap.insert( extractString( "EP3_SHIP3" , 0x1D1D2, 0x1D24C, -765) ); StringMap.insert( extractString( "EP3_SHIP4" , 0x1D24D, 0x1D2C4, -765) ); //Mortimer StringMap.insert( extractString( "EP3_MORTIMER" , 0x1C3B2, 0x1C3D7, -805) ); StringMap.insert( extractString( "EP3_MORTIMER2" , 0x1C3D8, 0x1C499, -805) ); StringMap.insert( extractString( "EP3_MORTIMER3" , 0x1C49B, 0x1C53E, -805) ); StringMap.insert( extractString( "EP3_MORTIMER4" , 0x1C53F, 0x1C606, -805) ); StringMap.insert( extractString( "EP3_MORTIMER5" , 0x1C607, 0x1C629, -805) ); StringMap.insert( extractString( "EP3_MORTIMER6" , 0x1C62A, 0x1C692, -805) ); // Ending Pages StringMap.insert( extractString( "EP3_ESEQ_PAGE1" , 0x1C692, 0x1C72E, -805) ); StringMap.insert( extractString( "EP3_ESEQ_PAGE2" , 0x1C730, 0x1C7A5, -805) ); StringMap.insert( extractString( "EP3_ESEQ_PAGE3" , 0x1C7A7, 0x1C811, -805) ); StringMap.insert( extractString( "EP3_ESEQ_PAGE4" , 0x1C813, 0x1C81F, -805) ); StringMap.insert( extractString( "THE_END" , 0x1C82D, 0x1C845, -806) ); } break; } } break; case 4: { if(extractEp4Strings(StringMap)) g_pLogFile->textOut(RED,"This version of the game is not supported!"); } break; default: { g_pLogFile->textOut(RED,"This version of the game is not supported!"); return false; } } // Now pass all the Map to the global text structure // Still a bad idea, because it's global string. if(!StringMap.empty()) { std::map<std::string, std::string>::iterator i; for( i = StringMap.begin() ; i != StringMap.end() ; i++ ) { g_pBehaviorEngine->addMessage(i->first, i->second); } g_pLogFile->ftextOut("Loaded %d strings from the exe-file.<br>", StringMap.size()); return true; } return false; }
// Extract the substring from start, start+length of the sequence starting at position idx std::string BWTAlgorithms::extractSubstring(const BWT* pBWT, uint64_t idx, size_t start, size_t length) { std::string s = extractString(pBWT, idx); return s.substr(start, length); }