in cli/mparser.cpp [428:504]
bool CModelData::readModel( const wstring& filePath )
{
// Some implementations of wifstream only allow ANSI strings as file names so converting before using
string ansiFilePath = wideCharToAnsi( filePath );
wifstream file( ansiFilePath );
if ( !file )
{
PrintMessage( InputDataError, L"Couldn't open file:", filePath.data() );
return( false );
}
wstring line;
// read definition of parameters
bool firstLine = true;
while( true )
{
// skip not important stuff
if ( lineIsEmpty( line ) || lineIsComment( line ))
{
if ( ! readLineFromFile( file, line )) return( true );
continue;
}
if ( firstLine )
{
m_encoding = getEncodingType( line );
if ( m_encoding != EncodingType::ANSI
&& m_encoding != EncodingType::UTF8 )
{
PrintMessage( InputDataError, L"Only ANSI and UTF-8 are supported" );
return( false );
}
firstLine = false;
}
// continue reading until a submodel/cluster or a constraint
if ( lineIsParamSet( line ) || lineIsConstraint( line )) break;
if ( ! readParameter( line )) return( false );
if ( ! readLineFromFile( file, line )) return( true );
}
// read submodels
if ( lineIsParamSet( line ))
{
while( true )
{
// skip not important stuff
if ( lineIsEmpty( line ) || lineIsComment( line ))
{
if ( ! readLineFromFile( file, line )) return( true );
continue;
}
// continue reading until a constraint
if ( lineIsConstraint( line )) break;
if ( ! readParamSet( line )) return( false );
if ( ! readLineFromFile( file, line )) return( true );
}
}
// anything that's left is constraints
while( true )
{
// if only a line is not empty or not a comment,
// it's got to be a part of constraints definition
if ( ! ( lineIsEmpty( line ) || lineIsComment( line )))
{
ConstraintPredicates += line;
}
if ( ! readLineFromFile( file, line )) return( true );
}
return( true );
}