bool Clipper::addPolylines(const std::vector<ofPolyline>& polylines, ClipperLib::PolyType PolyTyp, bool autoClose, ClipperLib::cInt scale) { auto _polylines = polylines; if (autoClose) { close(_polylines); } bool isClosed = autoClose ? true : areAllClosed(_polylines); return AddPaths(toClipper(_polylines, scale), PolyTyp, isClosed); }
void PathFinder::AddPaths(const String & ipathlist, bool recursive, bool prepend) { char *work = new char[ipathlist.length()+1]; char *found, *save_ptr; String tmp; String subdirList = wxEmptyString; MOcheck(); wxStrcpy(work,ipathlist.c_str()); found = wxStrtok(work, PATHFINDER_DELIMITER, &save_ptr); while(found) { if(prepend) pathList.push_front(found); else pathList.push_back(found); if(recursive && IsDir(found)) // look for subdirectories { tmp = String(found) + ANYFILE; wxString nextfile = wxFindFirstFile(tmp.c_str(), wxDIR); while ( !nextfile.empty() ) { if(IsDir(nextfile)) { if(subdirList.length() > 0) subdirList += _T(":"); subdirList = subdirList + String(nextfile); } nextfile = wxFindNextFile(); } } found = wxStrtok(NULL, PATHFINDER_DELIMITER, &save_ptr); } delete[] work; if(subdirList.length() > 0) AddPaths(subdirList, recursive); }
PathFinder::PathFinder(const String & ipathlist, bool recursive) { AddPaths(ipathlist,recursive); }
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 ); itr = lexems.erase( itr, splice_to ); } } else if( value == "#endif" ) { // ignore } else if( value == "#include" ) { if( LNT ) LNT->AddLineRange( PrependRootPath( filename ), start_line, CurrentLine - LinesThisFile ); unsigned int save_lines_this_file = LinesThisFile; std::string file_name; ParseIf( directive, file_name ); std::string file_name_ = RemoveQuotes( file_name ); if( IncludeTranslator ) IncludeTranslator->Call( file_name_ ); if( std::find( FileDependencies.begin(), FileDependencies.end(), file_name_ ) == FileDependencies.end() ) FileDependencies.push_back( file_name_ ); LexemList next_file; RecursivePreprocess( AddPaths( filename, file_name_ ), file_source, next_file, define_table ); lexems.splice( itr, next_file ); start_line = CurrentLine; LinesThisFile = save_lines_this_file; CurrentFile = filename; SetFileMacro( define_table, CurrentFile ); SetLineMacro( define_table, LinesThisFile ); } else if( value == "#pragma" ) { ParsePragma( directive ); } else if( value == "#message" ) { std::string message; ParseTextLine( directive, message ); PrintMessage( message ); } else if( value == "#warning" ) { std::string warning; ParseTextLine( directive, warning ); PrintWarningMessage( warning ); } else if( value == "#error" ) { std::string error; ParseTextLine( directive, error ); PrintErrorMessage( error ); } else { PrintErrorMessage( "Unknown directive '" + value + "'." ); } } else if( itr->Type == Lexem::IDENTIFIER ) { itr = ExpandDefine( itr, end, lexems, define_table ); } else { ++itr; } } if( LNT ) LNT->AddLineRange( PrependRootPath( filename ), start_line, CurrentLine - LinesThisFile ); }