本文整理汇总了C++中FileLoader::LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ FileLoader::LoadFile方法的具体用法?C++ FileLoader::LoadFile怎么用?C++ FileLoader::LoadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileLoader
的用法示例。
在下文中一共展示了FileLoader::LoadFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
int main(int argc, char **argv)
{
char Name = 'M';
std::string taq = "TaquinA5_2.txt";
if (argc == 3)
{
std::ifstream infile;
infile.open(argv[2]);
if (!infile.is_open())
{
std::cout << "Error: file <" << argv[2] << ">" << " not found" << std::endl;
return (-1);
}
infile.close();
taq = argv[2];
FileLoader F;
std::string S;
Puzzle P;
SolutionGenerator SG;
short unsigned int** Tab;
clock_t timeDeb, timeEnd;
std::list<Puzzle> OpenedList, ClosedList;
int x = 0, y = 0, fg = -42;
timeDeb = clock();
DisplayLogo();
F.LoadFile(taq.c_str(), S);
std::istringstream In(S);
P.SetAlgo(Name);
Tab = P.CreatePuzzle(S);
std::list<Puzzle>::iterator FirstPuzzle;
OpenedList.push_back(P);
while (fg != 0 && !OpenedList.empty())
{
FirstPuzzle = OpenedList.begin();
fg = Resume(FirstPuzzle, OpenedList, ClosedList, timeEnd);
ProcessUp(FirstPuzzle, OpenedList, ClosedList);
ProcessDown(FirstPuzzle, OpenedList, ClosedList);
ProcessRight(FirstPuzzle, OpenedList, ClosedList);
ProcessLeft(FirstPuzzle, OpenedList, ClosedList);
(*FirstPuzzle).ClearListTab();
ClosedList.push_back(*FirstPuzzle);
OpenedList.erase(FirstPuzzle);
}
if (fg != 0)
std::cout << "NO SOLUTION FOR THIS TAQUIN!!!" << std::endl;
std::cout << "CLOSED LIST NUMBER OF CONTENTS : \t\t[" << ClosedList.size() << "]"<< std::endl;
std::cout << "TIME ELAPSED : \t\t[" << static_cast<double>(timeEnd - timeDeb) << "] ms." << std::endl;
ShowNbMoves();
std::cout << "Cleaning..." << std::endl;
Clean(OpenedList, ClosedList);
std::cout << "Clean done" << std::endl;
}
return (0);
}
示例2: RecursivePreprocess
void Preprocessor::RecursivePreprocess( std::string filename, FileLoader& file_source, LexemList& lexems, DefineTable& define_table )
{
unsigned int start_line = CurrentLine;
LinesThisFile = 0;
CurrentFile = filename;
SetFileMacro( define_table, CurrentFile );
SetLineMacro( define_table, LinesThisFile );
// Path formatting must be done in main application
std::string CurrentFileRoot = RootPath + CurrentFile;
if( std::find( FilesPreprocessed.begin(), FilesPreprocessed.end(), CurrentFileRoot ) == FilesPreprocessed.end() )
FilesPreprocessed.push_back( CurrentFileRoot );
std::vector<char> data;
bool loaded = file_source.LoadFile( RootPath, filename, data );
if( !loaded )
{
PrintErrorMessage( std::string( "Could not open file " ) + RootPath + filename );
return;
}
if( data.size() == 0 )
return;
char* d_end = &data[data.size() - 1];
++d_end;
Lex( &data[0], d_end, lexems );
LexemList::iterator itr = lexems.begin();
LexemList::iterator end = lexems.end();
LLITR old = end;
while( itr != end )
{
if( itr->Type == Lexem::NEWLINE )
{
if( itr != old )
{
CurrentLine++;
LinesThisFile++;
SetLineMacro( define_table, LinesThisFile );
}
old = itr;
++itr;
}
else if( itr->Type == Lexem::PREPROCESSOR )
{
LLITR start_of_line = itr;
LLITR end_of_line = ParsePreprocessor( lexems, itr, end );
LexemList directive( start_of_line, end_of_line );
if( SkipPragmas && directive.begin()->Value == "#pragma" )
{
itr = end_of_line;
Lexem wspace;
wspace.Type = Lexem::WHITESPACE;
wspace.Value = " ";
for( LLITR it = start_of_line; it != end_of_line;)
{
++it;
it = lexems.insert( it, wspace );
++it;
}
continue;
}
itr = lexems.erase( start_of_line, end_of_line );
std::string value = directive.begin()->Value;
if( value == "#define" )
{
ParseDefine( define_table, directive );
}
else if( value == "#ifdef" )
{
std::string def_name;
ParseIf( directive, def_name );
DefineTable::iterator dti = define_table.find( def_name );
if( dti == define_table.end() )
{
LLITR splice_to = ParseIfDef( itr, end );
itr = lexems.erase( itr, splice_to );
}
}
else if( value == "#ifndef" )
{
std::string def_name;
ParseIf( directive, def_name );
DefineTable::iterator dti = define_table.find( def_name );
if( dti != define_table.end() )
{
LLITR splice_to = ParseIfDef( itr, end );
itr = lexems.erase( itr, splice_to );
}
}
else if( value == "#if" )
{
bool satisfied = EvaluateExpression( define_table, directive ) != 0;
if( !satisfied )
{
LLITR splice_to = ParseIfDef( itr, end );
//.........这里部分代码省略.........