diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-08-28 16:01:55 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-08-28 16:01:55 +0000 |
commit | fc5132d68ae9e6afdbd0b5a687ba81c88fc84826 (patch) | |
tree | 3bf09dce90829287eb0612da076ff72b816b9e6a /src | |
parent | 2ff45ffd1a7ef36369c135090b39528860b25684 (diff) | |
download | libbu++-fc5132d68ae9e6afdbd0b5a687ba81c88fc84826.tar.gz libbu++-fc5132d68ae9e6afdbd0b5a687ba81c88fc84826.tar.bz2 libbu++-fc5132d68ae9e6afdbd0b5a687ba81c88fc84826.tar.xz libbu++-fc5132d68ae9e6afdbd0b5a687ba81c88fc84826.zip |
INI driver is loading and saving just fine. Ideally it would escape things
like ']', '=', and possibly some others just to make all characters safe to
use. Right now, just don't use ] or = in keys and you're good.
Diffstat (limited to '')
-rw-r--r-- | src/unstable/settingsdriverini.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/unstable/settingsdriverini.cpp b/src/unstable/settingsdriverini.cpp index 46a40c6..90debcb 100644 --- a/src/unstable/settingsdriverini.cpp +++ b/src/unstable/settingsdriverini.cpp | |||
@@ -24,7 +24,7 @@ Bu::SettingsDriverIni::~SettingsDriverIni() | |||
24 | f << "[" << i.getKey().get() << "]" << f.nl; | 24 | f << "[" << i.getKey().get() << "]" << f.nl; |
25 | for( StrHash::iterator k = (*i).begin(); k; k++ ) | 25 | for( StrHash::iterator k = (*i).begin(); k; k++ ) |
26 | { | 26 | { |
27 | f << k.getKey().get() << "=" << k.getValue().get() << f.nl; | 27 | f << k.getKey().get() << " = " << k.getValue().get() << f.nl; |
28 | } | 28 | } |
29 | f << f.nl; | 29 | f << f.nl; |
30 | } | 30 | } |
@@ -45,17 +45,21 @@ void Bu::SettingsDriverIni::init( const Bu::UtfString &sCompany, | |||
45 | Bu::Buffer bIn( fIn ); | 45 | Bu::Buffer bIn( fIn ); |
46 | StrHash hKeys; | 46 | StrHash hKeys; |
47 | Bu::String sGroup; | 47 | Bu::String sGroup; |
48 | bool bStart = true; | ||
48 | while( !bIn.isEos() ) | 49 | while( !bIn.isEos() ) |
49 | { | 50 | { |
50 | Bu::String sIn = bIn.readLine(); | 51 | Bu::String sIn = bIn.readLine(); |
52 | if( sIn.isEmpty() ) | ||
53 | continue; | ||
51 | if( sIn[0] == '[' ) | 54 | if( sIn[0] == '[' ) |
52 | { | 55 | { |
53 | if( !sGroup.isEmpty() ) | 56 | if( bStart != true ) |
54 | { | 57 | { |
55 | hGroup.insert( sGroup, hKeys ); | 58 | hGroup.insert( sGroup, hKeys ); |
56 | hKeys.clear(); | 59 | hKeys.clear(); |
57 | } | 60 | } |
58 | sGroup = Bu::String( sIn.begin()+1, sIn.find(']') ); | 61 | sGroup = Bu::String( sIn.begin()+1, sIn.find(']') ); |
62 | bStart = false; | ||
59 | } | 63 | } |
60 | else | 64 | else |
61 | { | 65 | { |
@@ -63,10 +67,11 @@ void Bu::SettingsDriverIni::init( const Bu::UtfString &sCompany, | |||
63 | if( !i ) | 67 | if( !i ) |
64 | continue; | 68 | continue; |
65 | 69 | ||
66 | hKeys.insert( Bu::String( sIn.begin(), i ), | 70 | hKeys.insert( Bu::String( sIn.begin(), i ).trimWhitespace(), |
67 | Bu::String( i+1, sIn.end() ) ); | 71 | Bu::String( i+1, sIn.end() ).trimWhitespace() ); |
68 | } | 72 | } |
69 | } | 73 | } |
74 | hGroup.insert( sGroup, hKeys ); | ||
70 | } | 75 | } |
71 | catch(...) | 76 | catch(...) |
72 | { | 77 | { |
@@ -140,8 +145,8 @@ Bu::UtfString Bu::SettingsDriverIni::get( const Bu::UtfString &sKey, const Bu::U | |||
140 | sId.set( Bu::String( in+1, suKey.end() ) ); | 145 | sId.set( Bu::String( in+1, suKey.end() ) ); |
141 | } | 146 | } |
142 | 147 | ||
143 | sio << "Group: " << sGrp.get() << sio.nl | 148 | // sio << "Group: " << sGrp.get() << sio.nl |
144 | << "Key: " << sId.get() << sio.nl; | 149 | // << "Key: " << sId.get() << sio.nl; |
145 | 150 | ||
146 | try | 151 | try |
147 | { | 152 | { |