32 #include <boost/regex.hpp>
36 #include "combiner/WModuleProjectFileCombiner.h"
37 #include "WRoiProjectFileIO.h"
38 #include "../graphicsEngine/WGEProjectFileIO.h"
39 #include "../common/exceptions/WFileNotFound.h"
40 #include "../common/exceptions/WFileOpenFailed.h"
41 #include "../common/WStringUtils.h"
43 #include "WProjectFile.h"
76 if( ( *it )->getApplyOrder() == WProjectFileIO::POST_MODULES )
78 m_parsers.push_back( ( *it )->clone(
this ) );
82 m_parsers.push_front( ( *it )->clone(
this ) );
86 m_writers.push_back( ( *it )->clone(
this ) );
96 m_signalLoadDoneConnection( m_signalLoadDone.connect( doneCallback ) )
109 m_parsers.push_back( p2->clone(
this ) );
110 m_writers.push_back( p2->clone(
this ) );
113 m_parsers.push_back( p3->clone(
this ) );
114 m_writers.push_back( p3->clone(
this ) );
122 if( ( *it )->getApplyOrder() == WProjectFileIO::POST_MODULES )
124 m_parsers.push_back( ( *it )->clone(
this ) );
128 m_parsers.push_front( ( *it )->clone(
this ) );
132 m_writers.push_back( ( *it )->clone(
this ) );
172 std::list< boost::shared_ptr< WProjectFileIO > > l( writer.begin(), writer.end() );
181 std::ofstream output(
m_project.string().c_str() );
182 if( !output.is_open() )
185 std::string(
"\" could not be opened for write access." ) );
189 for( std::list< boost::shared_ptr< WProjectFileIO > >::const_iterator iter = writer.begin(); iter != writer.end(); ++iter )
191 ( *iter )->save( output );
209 std::vector< std::string > errors;
210 std::vector< std::string > warnings;
213 std::ifstream input(
m_project.string().c_str() );
214 if( !input.is_open() )
216 errors.push_back( std::string(
"The project file \"" ) +
m_project.string() + std::string(
"\" does not exist." ) );
227 static const boost::regex commentRe(
"^ *//.*$" );
233 boost::smatch matches;
235 while( std::getline( input, line ) )
241 for( std::list< boost::shared_ptr< WProjectFileIO > >::const_iterator iter =
m_parsers.begin(); iter !=
m_parsers.end(); ++iter )
245 if( ( *iter )->parse( line, i ) )
252 catch(
const std::exception& e )
260 if( !match && !line.empty() && !boost::regex_match( line, matches, commentRe ) )
263 wlog::warn(
"Project Loader" ) <<
"Line " << i <<
": Malformed. Skipping.";
270 for( std::list< boost::shared_ptr< WProjectFileIO > >::const_iterator iter =
m_parsers.begin(); iter !=
m_parsers.end(); ++iter )
276 std::copy( ( *iter )->getErrors().begin(), ( *iter )->getErrors().end(), std::back_inserter( errors ) );
277 std::copy( ( *iter )->getWarnings().begin(), ( *iter )->getWarnings().end(), std::back_inserter( warnings ) );
279 catch(
const std::exception& e )
281 errors.push_back(
"Exception while applying settings: " + std::string( e.what() ) );
311 if( it == w->get().end() )
314 w->get().push_back( parser );