Changeset 243
- Timestamp:
- 01/22/09 19:46:09 (16 years ago)
- Location:
- bdm/config
- Files:
-
- 2 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/config/loadik.cpp
r242 r243 12 12 13 13 void prtS(Setting& S){ 14 int l = S.getLength(); 15 for (int i=0;i<l;i++){ 16 cout << S[i].getName(); 17 Setting::Type T=S[i].getType(); 18 if ((T== Setting::TypeArray)||(T== Setting::TypeList) || (T==Setting::TypeGroup)){ cout << endl; prtS(S[i]);} else 19 { if (T==Setting::TypeInt) cout << "=" << int(S[i]) <<endl; } 20 14 const char *Name=S.getName(); 15 if (Name!=NULL) {cout << std::string(Name);}; 16 Setting::Type T=S.getType(); 17 switch (T) { 18 case Setting::TypeArray: 19 cout << endl; 20 for(int i=0;i<S.getLength();i++){prtS(S[i]);}; 21 break; 22 case Setting::TypeList: 23 cout << endl; 24 for(int i=0;i<S.getLength();i++){prtS(S[i]);}; 25 break; 26 case Setting::TypeGroup: 27 cout << endl; 28 for(int i=0;i<S.getLength();i++){prtS(S[i]);} 29 break; 30 case Setting::TypeInt: 31 cout << " = "; 32 cout << int(S)<<endl; 33 break; 34 case Setting::TypeFloat: 35 cout << " = "; 36 cout << double(S)<<endl; 37 break; 38 case Setting::TypeString: 39 cout << " = "; 40 cout << (const char*)(S)<<endl; 41 break; 42 case Setting::TypeBoolean: 43 cout << " = "; 44 cout << bool(S)<<endl; 45 break; 46 default: {cout << "?";}; 21 47 } 22 48 } … … 24 50 int main(){ 25 51 52 cout << "========" <<endl; 53 26 54 Config C; 55 C.readFile("testik.cfg"); 27 56 Setting& S=C.getRoot();; 28 57 prtS(S); … … 30 59 vec x= getVec(S["application"]["misc"]["vec"]); 31 60 cout << x << endl; 32 cout << "wo co go?" <<endl;33 //cout << getVec(S["ivec"]) << endl;34 61 35 62 return 0; 36 63 } 37 -
bdm/config/testik.cfg
r242 r243 1 1 application: 2 2 { 3 window:4 {5 title = "My Application"; 6 size = { w = 640; h = 480; };7 pos = { x = 350; y = 250; };8 };9 list = ( ( "abc", 123, true ), 1.234, ( /* an empty list */) );10 books = ( { title = "Treasure Island";11 author = "Robert Louis Stevenson";12 price = 29.95;13 qty = 5; },14 { title = "Snow Crash";15 author = "Neal Stephenson";16 price = 9.99;17 qty = 8; } );18 misc:19 {20 pi = 3.141592654;21 bigint = 9223372036854775807L;22 columns = [ "Last Name", "First Name", "MI" ];23 vec = [ 1, 2, 3 ];24 bitmask = 0x1FC3;25 };3 window: 4 { 5 title = "My Application"; //QQQQQQQQQ /* iiasud */ 6 size = { w = 640; h = 480; }; 7 pos = { x = 350; y = 250; }; 8 }; 9 list = ( ( "abc", 123, true ), 1.234, ( /* an empty list */) ); 10 books = ( { title = "Treasure Island"; 11 author = "Robert Louis Stevenson"; 12 price = 29.95; 13 qty = 5; }, 14 { title = "Snow Crash"; 15 author = "Neal Stephenson"; 16 price = 9.99; 17 qty = 8; } ); 18 misc: 19 { 20 pi = 3.141592654; 21 bigint = 9223372036854775807L; 22 columns = [ "Last Name", "First Name", "MI" ]; 23 vec = [ 1, 2, 3 ]; 24 bitmask = 0x1FC3; 25 }; 26 26 }; 27 27