TInt TPkgParser::ParseDataLineL(class CFileObjectHolder* &aFileList, char* line) { char* localName = NULL; char* url = NULL; uint32 fileSize = 0; char* checksum = NULL; uint32 action = 0; char* version = NULL; char* versionFile = NULL; char* versionCheck = NULL; char* isoLang = NULL; TBool ok = ETrue; ok = ok && ParseString(localName, line); ok = ok && ParseString(url, line); ok = ok && ParseUint32(fileSize, line); ok = ok && ParseString(checksum, line); ok = ok && ParseUint32(action, line); ok = ok && ParseString(version, line); //last mandatory field TBool lineCorrect = ok; ok = ok && ParseString(versionFile, line); //may return EFalse if //there is no ending ';' ok = ok && ParseString(versionCheck, line); ok = ok && ParseString(isoLang, line); if(!lineCorrect){ return 0; } //ignore lines that are language tagged but doesn't match the //selected language. if(isoLang && strlen(isoLang) > 0 && iSelectedLang != KNullDesC){ HBufC* lang = WFTextUtil::AllocL(isoLang); if(0 != lang->CompareF(iSelectedLang)){ action = 3; //Delete file. } delete lang; } class CFileObject *a = CFileObject::NewLC(localName, url, fileSize, checksum, action, version, versionFile, versionCheck, isoLang); if (!aFileList) { aFileList = new (ELeave) CFileObjectHolder(); } CleanupStack::Pop(a); aFileList->unshift(a); return 1; }
Uint32 ConfigReader::GetUint32(const std::string theSection, const std::string theName, const Uint32 theDefault) const { Uint32 anResult = theDefault; // Check if theSection really exists std::map<const std::string, typeNameValue*>::const_iterator iter; iter = mSections.find(theSection); if(iter != mSections.end()) { // Try to obtain the name, value pair typeNameValue* anMap = iter->second; if(NULL != anMap) { typeNameValueIter iterNameValue; iterNameValue = anMap->find(theName); if(iterNameValue != anMap->end()) { anResult = ParseUint32(iterNameValue->second, theDefault); } } } // Return the result found or theDefault assigned above return anResult; }
TInt TPkgParser::ParseLineL(class CFileObjectHolder* &aFileList, char* line, TUint32& aTotalDataSize) { char *save_line = line; TInt ret = 0; while(line && isspace(*line) ){ //strip whitespace ++line; } if(*line == '\n' || *line == '\0'){ ret = 1; } else if (!line) { //We need a valid string. ret = 0; } else if (line[0] == '!') { /* This is the line with the total number of */ /* bytes to read. */ if((ret = ParseUint32(iTotalDataSize, ++line))){ aTotalDataSize = iTotalDataSize; } ret = 1; } else if(line[0] == '#'){ //skip comment lines. //end function ret = 1; } else if(line[0] == '@'){ //version line ret = ParseInt32(iVersion, ++line); } else { ret = ParseDataLineL(aFileList, line); } delete save_line; return ret; }
sf::Vector2u ParseVector2u(const std::string theValue, const sf::Vector2u theDefault) { sf::Vector2u anResult = theDefault; // Try to find the first comma size_t anCommaOffset = theValue.find_first_of(','); if(anCommaOffset != std::string::npos) { Uint32 anX = ParseUint32(theValue.substr(0, anCommaOffset), theDefault.x); Uint32 anY = ParseUint32(theValue.substr(anCommaOffset+1), theDefault.y); // Now that both values have been parsed, return the vector found anResult.x = anX; anResult.y = anY; } // Return the result found or theDefault assigned above return anResult; }