1
1
/***************************************************************************
2
file_parser.cpp - Image Settings Handler
4
copyright : (C) 2005 - 2007 by Florian Richter
2
* file_parser.cpp - Image Settings Handler
4
* Copyright (C) 2005 - 2008 Florian Richter
5
5
***************************************************************************/
7
7
This program is free software; you can redistribute it and/or modify
56
56
bool cFile_parser :: Parse_Line( string command, int line )
58
if( command.length() <= 5 || command.find_first_of( '#' ) == 0 )
63
while( command.find( '\r' ) != string::npos ) // Linux support
59
while( command.find( '\r' ) != string::npos )
65
61
command.erase( command.find( '\r' ), 1 );
68
while( command.find( '\t' ) != string::npos ) // No Tabs
65
while( command.find( '\t' ) != string::npos )
70
67
command.replace( command.find( '\t' ), 1, " " );
73
while( command.find_last_of( ' ' ) == command.length() - 1 ) // No Spaces at the end
70
// remove trailing spaces
71
while( command.find_last_of( ' ' ) == command.length() - 1 )
75
73
command.erase( command.find_last_of( ' ' ), 1 );
78
while( command.find_first_of( ' ' ) == 0 ) // No Spaces at the beginning
76
// remove beginning spaces
77
while( command.find_first_of( ' ' ) == 0 )
80
79
command.erase( command.find_first_of( ' ' ), 1 );
82
// ignore comments and empty lines
83
if( command.find_first_of( '#' ) == 0 || command.empty() )
83
89
string tempstr = command;
86
while( tempstr.find( ' ' ) != string::npos ) // Count Spaces
93
while( tempstr.find( ' ' ) != string::npos )
88
95
tempstr.erase( tempstr.find( ' ' ) , 1 );