HRESULT ReadIdentifierFromLocation(FILE* fp, DWORD pos, sysstring& ident) { long oldpos = ftell(fp); fseek(fp, pos, SEEK_SET); ReadIdentifier(fp, ident); fseek(fp, oldpos, SEEK_SET); return S_OK; }
/** Reads the image type from the core image file. It reads the value from the file and then translates it into the internal enum used for processing the images. @return Image type */ RCoreImageReader::TImageType RCoreImageReader::ReadImageType() { iImageType = E_UNKNOWN; if ( ReadIdentifier() == KErrNone) { if (iIdentifier[0] == 'R' && iIdentifier[1] == 'O' && iIdentifier[2] == 'F') { if (iIdentifier[3] == 'S') iImageType = E_ROFS; else if (iIdentifier[3] == 'x') iImageType = E_ROFX; } } return iImageType; }
int LoadBalancingConfig::ParseConfigFile(std::string path){ std::ifstream fid; fid.open(path.c_str(), std::fstream::in); if(fid==NULL){ fprintf(stderr, "Could not open LoadBalancingConfig settings file\n"); return -1; } while(!fid.eof()){ std::string identifier = ReadIdentifier(&fid); std::string value = ReadUntilNewLine(&fid); if(identifier=="END"){ break; } else if(strcmp(identifier.c_str(), "reconstruction_method") == 0){ if(strcmp(value.c_str(), "forward") == 0){ reconstruction_method = 1; } else if(strcmp(value.c_str(), "backward") == 0){ reconstruction_method = 2; } else{ //Scaling reconstruction_method = 3; } } else if(strcmp(identifier.c_str(), "bdr_update_coef") == 0){ bdr_update_coef = atof(value.c_str()); } else if(strcmp(identifier.c_str(), "fdr_update_coef") == 0){ fdr_update_coef = atof(value.c_str()); } else if(strcmp(identifier.c_str(), "scaling_coef") == 0){ scaling_coef = atof(value.c_str()); } else if(strcmp(identifier.c_str(), "num_quantiles") == 0){ num_quantiles = atoi(value.c_str()); } else if(strcmp(identifier.c_str(), "solver_timeout") == 0){ solver_timeout = atof(value.c_str()); } else if(strcmp(identifier.c_str(), "use_fixed_uniform_cuts") == 0){ if(strcmp(value.c_str(), "true") == 0){ use_fixed_uniform_cuts = 1; } else{ use_fixed_uniform_cuts = 0; } } else if(strcmp(identifier.c_str(), "uniform_IP_distribution") == 0){ if(strcmp(value.c_str(), "true") == 0){ u_d_alpha_d = 1; } else{ u_d_alpha_d = 0; } } else if(strcmp(identifier.c_str(), "training_period") == 0){ training_period = atoi(value.c_str()); } } fid.close(); return 0; }
Token Scanner::GetNextToken() { TokenType T; string str; State st; char c; if (!SkipSpaces(file, xy, pos)) throw Error("unclosed comment", pos.first, pos.second); pos = xy; c = GetSymb(file, xy); st = GetState(c); switch (st){ case is_letter : { str = str + c; T = ReadIdentifier(file, str, xy); map<string, TokenType>::const_iterator it = SpecSymb.begin(); it = SpecSymb.find(str); if (it != SpecSymb.end()) T = (*it).second; } break; case is_emphasize: str = str + c; T = ReadIdentifier(file, str, xy); break; case is_digit: str = str + c; T = ReadDecNumber(file, str, xy); break; case is_dollar: str = str + c; T = ReadHexNumber(file, str, xy); break; case is_ampersand: str = str + c; T = ReadOctNumber(file, str, xy); break; case is_quote: str = str + c; T = ReadStringConst(file, str ,xy); break; case is_sharp: str = str + c; T = ReadStringConst(file, str ,xy); break; case is_figure_bracket: while (c != '}') { c = GetSymb(file, xy); if (c == EOF) throw Error("unclosed comment", pos.first, pos.second); } break; case is_point: str = str + c; T = separator; if (file.peek() == '.') str = str + GetSymb(file, xy); break; case is_colon: str = str + c; T = separator; if (file.peek() == '=') { str = str + GetSymb(file, xy); T = operation; } break; case is_more: str = str + c; T = operation; if (file.peek() == '=') str = str + GetSymb(file, xy); break; case is_less: str = str + c; T = operation; if (file.peek() == '>' || file.peek() == '=') str = str + GetSymb(file, xy); break; case is_end_of_file: T = end_of_file; str = "EOF"; break; default: str = str + c; map<string, TokenType>::const_iterator it = SpecSymb.begin(); it = SpecSymb.find(str); if (it != SpecSymb.end()) T = (*it).second; else throw Error("syntax error", pos.first, pos.second); } return Token(str, T, pos); }