diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:48 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:48 +0200 |
| commit | d9c4a95345bd758e45196b29368bd2ff0f2790e3 (patch) | |
| tree | 8e7aa76f3f2a3a064f440f7410e4ec01cd34a78f /lang.cpp | |
| parent | d4c9f10efe815af146438cafb694d16da0e5650a (diff) | |
tagging ychat-0.5.2ychat-0.5.2
Diffstat (limited to 'lang.cpp')
| -rw-r--r--[-rwxr-xr-x] | lang.cpp | 75 |
1 files changed, 38 insertions, 37 deletions
@@ -10,69 +10,70 @@ using namespace std; lang::lang( string s_lang = "en" ) : name( s_lang ) { - parse( ); // parse the config file. + parse( ); // parse the config file. } lang::~lang() -{ -} +{} void lang::parse() { #ifdef VERBOSE - cout << CFILEOK << get_name() << endl; + cout << CFILEOK << get_name() << endl; #endif - string filename("lang/"); - filename.append(get_name()); + string filename("lang/"); + filename.append(get_name()); - ifstream fs_conf( filename.c_str() ); + ifstream fs_conf( filename.c_str() ); - if ( ! fs_conf ) - { + if ( ! fs_conf ) + { #ifdef VERBOSE - cout << CFILENO << get_name() << endl; + cout << CFILENO << get_name() << endl; #endif - return; - } - char c_buf[READBUF]; + return; + } + + char c_buf[READBUF]; - while( fs_conf.getline( c_buf, READBUF ) ) - { - string s_token( c_buf ); - unsigned int ui_pos = s_token.find( "#", 0 ); - - // if line is commented out: - if ( ui_pos == 0 ) - continue; + while( fs_conf.getline( c_buf, READBUF ) ) + { + string s_token( c_buf ); + unsigned int ui_pos = s_token.find( "#", 0 ); - ui_pos = s_token.find( ";", 0 ); + // if line is commented out: + if ( ui_pos == 0 ) + continue; - // if token has not been found. - if ( ui_pos == string::npos ) - continue; + ui_pos = s_token.find( ";", 0 ); - s_token = s_token.substr( 0 , --ui_pos ); - ui_pos = s_token.find ( "\"", 0 ); + // if token has not been found. + if ( ui_pos == string::npos ) + continue; - if ( ui_pos == string::npos ) - continue; + s_token = s_token.substr( 0 , --ui_pos ); + ui_pos = s_token.find ( "\"", 0 ); - string s_val = s_token.substr( ui_pos+1, s_token.length() ); - string s_key = s_token.substr( 0 , --ui_pos ); + if ( ui_pos == string::npos ) + continue; + + string s_val = s_token.substr( ui_pos+1, s_token.length() ); + string s_key = s_token.substr( 0 , --ui_pos ); #ifdef VERBOSE2 - cout << s_key << "=" << s_val << endl; + + cout << s_key << "=" << s_val << endl; #endif - // fill the map. - map_vals[s_key] = s_val; - } + // fill the map. + map_vals[s_key] = s_val; + } - fs_conf.close(); - fs_conf.~ifstream(); + fs_conf.close(); + fs_conf.~ifstream(); } #endif |
