void XmlUniformiser::copyElementContent() { while ( isValidIndex() && !startsWith( "<" ) ) copyNext(); removeTrailingSpaces(); }
String& String::trim () { removeTrailingSpaces (); removeLeadingSpaces (); return *this; }
void ParseFile_Recurse(FILE* fd, Settings& settings,int& lineCount){ std::string key,value; char lastCharParsed; do{ lastCharParsed = getKey(fd,key); removeTrailingSpaces(key); if(lastCharParsed == '=' && key.size()>0){ lastCharParsed = getBody(fd,value); removeTrailingSpaces(value); settings.values[key] = value; //Now lets add a new nested tree of if statements //sorry future me about this mess if(lastCharParsed=='#'){ readRestOfLine(fd); lineCount++; }else if(lastCharParsed=='}'){ return; //unwind the stack to be done with this group }else if(lastCharParsed=='\n'){ //nothing special lineCount++; }else if(lastCharParsed=='{'){ printf("ERROR: CONFIG:%d: Opening new group ( { ) while specifing value\n",lineCount); }else if(lastCharParsed=='='){ printf("ERROR: CONFIG:%d: Value specifing ( = ) while specifing value\n",lineCount); }else if( !feof(fd) ){ printf("ERROR: CONFIG:%d: Reached EOF Unexpectedly (value parsing)\n",lineCount); } }else if(lastCharParsed == '{' && key.size()>0){ //found a named group, so recurse down to get everything inside of it ParseFile_Recurse(fd,settings.groups[key],lineCount); }else if(lastCharParsed == '}' && key.size()==0){ //found that we are closing the group we are currently in return; // unwind the stack }else if(lastCharParsed == '\n' && key.size()==0){ //just ignore blank lines lineCount++; }else if(lastCharParsed == '#' && key.size()==0){ //ignore lines that only have comments readRestOfLine(fd); lineCount++; } // end of good states, following are bad states else if( lastCharParsed=='#' && key.size()>0 ){ readRestOfLine(fd); lineCount++; printf("ERROR: CONFIG:%d: found a comment token ( # ) while parsing label\n",lineCount); }else if( lastCharParsed=='=' && key.size()==0 ){ readRestOfLine(fd); lineCount++; printf("ERROR: CONFIG:%d: found a ( = ) token with an empty label\n",lineCount); }else if( lastCharParsed=='}' && key.size()>0 ){ printf("ERROR: CONFIG:%d: found a ( } ) token with a non-empty label\n",lineCount); }else if( lastCharParsed=='\n' && key.size()>0 ){ printf("ERROR: CONFIG:%d: reached end of line with a non-empty label\n",lineCount); lineCount++; }else if( lastCharParsed=='{' && key.size()>0 ){ printf("ERROR: CONFIG:%d: found a ( { ) token with an empty label\n",lineCount); }else if( feof(fd) ){ if(key.size()>0) printf("ERROR: CONFIG:%d: Reached EOF Unexpectedly (key parsing)\n",lineCount); //else no-one cares as we are not losing any information } }while(!feof(fd)); }