aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/settingsdrivertaf.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/unstable/settingsdrivertaf.cpp
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/unstable/settingsdrivertaf.cpp')
-rw-r--r--src/unstable/settingsdrivertaf.cpp148
1 files changed, 74 insertions, 74 deletions
diff --git a/src/unstable/settingsdrivertaf.cpp b/src/unstable/settingsdrivertaf.cpp
index 8cbcbc5..3fd61b3 100644
--- a/src/unstable/settingsdrivertaf.cpp
+++ b/src/unstable/settingsdrivertaf.cpp
@@ -6,97 +6,97 @@
6#include <stdlib.h> 6#include <stdlib.h>
7 7
8Bu::SettingsDriverTaf::SettingsDriverTaf() : 8Bu::SettingsDriverTaf::SettingsDriverTaf() :
9 pRoot( NULL ) 9 pRoot( NULL )
10{ 10{
11} 11}
12 12
13Bu::SettingsDriverTaf::~SettingsDriverTaf() 13Bu::SettingsDriverTaf::~SettingsDriverTaf()
14{ 14{
15 if( !pRoot ) 15 if( !pRoot )
16 return; 16 return;
17 17
18 Bu::File fOut( sPath, Bu::File::WriteNew ); 18 Bu::File fOut( sPath, Bu::File::WriteNew );
19 Bu::TafWriter tw( fOut ); 19 Bu::TafWriter tw( fOut );
20 tw.writeGroup( pRoot ); 20 tw.writeGroup( pRoot );
21 delete pRoot; 21 delete pRoot;
22} 22}
23 23
24void Bu::SettingsDriverTaf::init( const Bu::UtfString &sCompany, 24void Bu::SettingsDriverTaf::init( const Bu::UtfString &sCompany,
25 const Bu::UtfString &sProduct ) 25 const Bu::UtfString &sProduct )
26{ 26{
27 Bu::UtfString us( getenv("HOME") ); 27 Bu::UtfString us( getenv("HOME") );
28 us += "/.config/"; 28 us += "/.config/";
29 us += sCompany; 29 us += sCompany;
30 us += "/"; 30 us += "/";
31 us += sProduct; 31 us += sProduct;
32 sPath = us.get(); 32 sPath = us.get();
33 try 33 try
34 { 34 {
35 Bu::File fIn( sPath, Bu::File::Read|Bu::File::Create ); 35 Bu::File fIn( sPath, Bu::File::Read|Bu::File::Create );
36 Bu::TafReader tr( fIn ); 36 Bu::TafReader tr( fIn );
37 pRoot = tr.readGroup(); 37 pRoot = tr.readGroup();
38 } 38 }
39 catch(...) 39 catch(...)
40 { 40 {
41 } 41 }
42 if( !pRoot ) 42 if( !pRoot )
43 { 43 {
44 pRoot = new Bu::TafGroup( sProduct.get() ); 44 pRoot = new Bu::TafGroup( sProduct.get() );
45 } 45 }
46} 46}
47 47
48void Bu::SettingsDriverTaf::set( const Bu::UtfString &sKey, 48void Bu::SettingsDriverTaf::set( const Bu::UtfString &sKey,
49 const Bu::UtfString &sValue ) 49 const Bu::UtfString &sValue )
50{ 50{
51 Bu::StringList lPath = sKey.get().split('/'); 51 Bu::StringList lPath = sKey.get().split('/');
52 Bu::StringList::iterator i = lPath.begin(); 52 Bu::StringList::iterator i = lPath.begin();
53 Bu::StringList::iterator in; 53 Bu::StringList::iterator in;
54 Bu::TafGroup *pGrp = pRoot; 54 Bu::TafGroup *pGrp = pRoot;
55 for(; i;) 55 for(; i;)
56 { 56 {
57 in = i; 57 in = i;
58 in++; 58 in++;
59 if( in ) 59 if( in )
60 { 60 {
61 if( pGrp->hasChild( *i ) ) 61 if( pGrp->hasChild( *i ) )
62 pGrp = (Bu::TafGroup *)pGrp->getChild( *i ); 62 pGrp = (Bu::TafGroup *)pGrp->getChild( *i );
63 else 63 else
64 pGrp = pGrp->addGroup( *i ); 64 pGrp = pGrp->addGroup( *i );
65 } 65 }
66 else 66 else
67 { 67 {
68 pGrp->addProperty( *i, sValue.get() ); 68 pGrp->addProperty( *i, sValue.get() );
69 } 69 }
70 i = in; 70 i = in;
71 } 71 }
72} 72}
73 73
74Bu::UtfString Bu::SettingsDriverTaf::get( const Bu::UtfString &sKey, 74Bu::UtfString Bu::SettingsDriverTaf::get( const Bu::UtfString &sKey,
75 const Bu::UtfString &sValue ) 75 const Bu::UtfString &sValue )
76{ 76{
77 Bu::StringList lPath = sKey.get().split('/'); 77 Bu::StringList lPath = sKey.get().split('/');
78 Bu::StringList::iterator i = lPath.begin(); 78 Bu::StringList::iterator i = lPath.begin();
79 Bu::StringList::iterator in; 79 Bu::StringList::iterator in;
80 Bu::TafGroup *pGrp = pRoot; 80 Bu::TafGroup *pGrp = pRoot;
81 for(; i;) 81 for(; i;)
82 { 82 {
83 in = i; 83 in = i;
84 in++; 84 in++;
85 if( in ) 85 if( in )
86 { 86 {
87 if( pGrp->hasChild( *i ) ) 87 if( pGrp->hasChild( *i ) )
88 pGrp = (Bu::TafGroup *)pGrp->getChild( *i ); 88 pGrp = (Bu::TafGroup *)pGrp->getChild( *i );
89 else 89 else
90 return sValue; 90 return sValue;
91 } 91 }
92 else 92 else
93 { 93 {
94 if( pGrp->hasProperty( *i ) ) 94 if( pGrp->hasProperty( *i ) )
95 return pGrp->getProperty( *i ); 95 return pGrp->getProperty( *i );
96 else 96 else
97 return sValue; 97 return sValue;
98 } 98 }
99 i = in; 99 i = in;
100 } 100 }
101} 101}
102 102