From ec05778d5718a7912e506764d443a78d6a6179e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Nov 2012 22:41:51 +0000 Subject: Converted tabs to spaces with tabconv. --- src/unstable/settingsdriverini.cpp | 258 ++++++++++++++++++------------------- 1 file changed, 129 insertions(+), 129 deletions(-) (limited to 'src/unstable/settingsdriverini.cpp') diff --git a/src/unstable/settingsdriverini.cpp b/src/unstable/settingsdriverini.cpp index 90debcb..31bc146 100644 --- a/src/unstable/settingsdriverini.cpp +++ b/src/unstable/settingsdriverini.cpp @@ -15,146 +15,146 @@ Bu::SettingsDriverIni::SettingsDriverIni() Bu::SettingsDriverIni::~SettingsDriverIni() { - Bu::File fOut( sPath, Bu::File::WriteNew ); - Bu::Buffer bOut( fOut ); - Bu::Formatter f( bOut ); - - for( GroupHash::iterator i = hGroup.begin(); i; i++ ) - { - f << "[" << i.getKey().get() << "]" << f.nl; - for( StrHash::iterator k = (*i).begin(); k; k++ ) - { - f << k.getKey().get() << " = " << k.getValue().get() << f.nl; - } - f << f.nl; - } + Bu::File fOut( sPath, Bu::File::WriteNew ); + Bu::Buffer bOut( fOut ); + Bu::Formatter f( bOut ); + + for( GroupHash::iterator i = hGroup.begin(); i; i++ ) + { + f << "[" << i.getKey().get() << "]" << f.nl; + for( StrHash::iterator k = (*i).begin(); k; k++ ) + { + f << k.getKey().get() << " = " << k.getValue().get() << f.nl; + } + f << f.nl; + } } void Bu::SettingsDriverIni::init( const Bu::UtfString &sCompany, - const Bu::UtfString &sProduct ) + const Bu::UtfString &sProduct ) { - Bu::UtfString us( getenv("HOME") ); - us += "/.config/"; - us += sCompany; - us += "/"; - us += sProduct; - sPath = us.get(); - try - { - Bu::File fIn( sPath, Bu::File::Read|Bu::File::Create ); - Bu::Buffer bIn( fIn ); - StrHash hKeys; - Bu::String sGroup; - bool bStart = true; - while( !bIn.isEos() ) - { - Bu::String sIn = bIn.readLine(); - if( sIn.isEmpty() ) - continue; - if( sIn[0] == '[' ) - { - if( bStart != true ) - { - hGroup.insert( sGroup, hKeys ); - hKeys.clear(); - } - sGroup = Bu::String( sIn.begin()+1, sIn.find(']') ); - bStart = false; - } - else - { - Bu::String::iterator i = sIn.find('='); - if( !i ) - continue; - - hKeys.insert( Bu::String( sIn.begin(), i ).trimWhitespace(), - Bu::String( i+1, sIn.end() ).trimWhitespace() ); - } - } - hGroup.insert( sGroup, hKeys ); - } - catch(...) - { - } + Bu::UtfString us( getenv("HOME") ); + us += "/.config/"; + us += sCompany; + us += "/"; + us += sProduct; + sPath = us.get(); + try + { + Bu::File fIn( sPath, Bu::File::Read|Bu::File::Create ); + Bu::Buffer bIn( fIn ); + StrHash hKeys; + Bu::String sGroup; + bool bStart = true; + while( !bIn.isEos() ) + { + Bu::String sIn = bIn.readLine(); + if( sIn.isEmpty() ) + continue; + if( sIn[0] == '[' ) + { + if( bStart != true ) + { + hGroup.insert( sGroup, hKeys ); + hKeys.clear(); + } + sGroup = Bu::String( sIn.begin()+1, sIn.find(']') ); + bStart = false; + } + else + { + Bu::String::iterator i = sIn.find('='); + if( !i ) + continue; + + hKeys.insert( Bu::String( sIn.begin(), i ).trimWhitespace(), + Bu::String( i+1, sIn.end() ).trimWhitespace() ); + } + } + hGroup.insert( sGroup, hKeys ); + } + catch(...) + { + } } void Bu::SettingsDriverIni::set( const Bu::UtfString &sKey, const Bu::UtfString &sValue ) { - Bu::String suKey = sKey.get(); - Bu::String::iterator i = suKey.find('/'); - Bu::UtfString sGrp; - Bu::UtfString sId; - if( !i ) - { - sGrp = ""; - sId = sKey; - } - else - { - Bu::String::iterator in; - for(;;) - { - in = i; - i = (in + 1).find('/'); - if( !i ) - break; - } - - sGrp.set( Bu::String( suKey.begin(), in ) ); - sId.set( Bu::String( in+1, suKey.end() ) ); - } - -// sio << "Group: " << sGrp.get() << sio.nl -// << "Key: " << sId.get() << sio.nl; - - if( !hGroup.has( sGrp ) ) - { - StrHash hVal; - hVal.insert( sId, sValue ); - hGroup.insert( sGrp, hVal ); - } - else - { - hGroup.get( sGrp ).insert( sId, sValue ); - } + Bu::String suKey = sKey.get(); + Bu::String::iterator i = suKey.find('/'); + Bu::UtfString sGrp; + Bu::UtfString sId; + if( !i ) + { + sGrp = ""; + sId = sKey; + } + else + { + Bu::String::iterator in; + for(;;) + { + in = i; + i = (in + 1).find('/'); + if( !i ) + break; + } + + sGrp.set( Bu::String( suKey.begin(), in ) ); + sId.set( Bu::String( in+1, suKey.end() ) ); + } + +// sio << "Group: " << sGrp.get() << sio.nl +// << "Key: " << sId.get() << sio.nl; + + if( !hGroup.has( sGrp ) ) + { + StrHash hVal; + hVal.insert( sId, sValue ); + hGroup.insert( sGrp, hVal ); + } + else + { + hGroup.get( sGrp ).insert( sId, sValue ); + } } Bu::UtfString Bu::SettingsDriverIni::get( const Bu::UtfString &sKey, const Bu::UtfString &sValue ) { - Bu::String suKey = sKey.get(); - Bu::String::iterator i = suKey.find('/'); - Bu::UtfString sGrp; - Bu::UtfString sId; - if( !i ) - { - sGrp = ""; - sId = sKey; - } - else - { - Bu::String::iterator in; - for(;;) - { - in = i; - i = (in + 1).find('/'); - if( !i ) - break; - } - - sGrp.set( Bu::String( suKey.begin(), in ) ); - sId.set( Bu::String( in+1, suKey.end() ) ); - } - -// sio << "Group: " << sGrp.get() << sio.nl -// << "Key: " << sId.get() << sio.nl; - - try - { - return hGroup.get( sGrp ).get( sId ); - } - catch(...) - { - return sValue; - } + Bu::String suKey = sKey.get(); + Bu::String::iterator i = suKey.find('/'); + Bu::UtfString sGrp; + Bu::UtfString sId; + if( !i ) + { + sGrp = ""; + sId = sKey; + } + else + { + Bu::String::iterator in; + for(;;) + { + in = i; + i = (in + 1).find('/'); + if( !i ) + break; + } + + sGrp.set( Bu::String( suKey.begin(), in ) ); + sId.set( Bu::String( in+1, suKey.end() ) ); + } + +// sio << "Group: " << sGrp.get() << sio.nl +// << "Key: " << sId.get() << sio.nl; + + try + { + return hGroup.get( sGrp ).get( sId ); + } + catch(...) + { + return sValue; + } } -- cgit v1.2.3