Changeset 243

Show
Ignore:
Timestamp:
01/22/09 19:46:09 (15 years ago)
Author:
smidl
Message:

ui funguje...

Location:
bdm/config
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • bdm/config/loadik.cpp

    r242 r243  
    1212 
    1313void 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 << "?";}; 
    2147        } 
    2248} 
     
    2450int main(){ 
    2551 
     52cout << "========" <<endl; 
     53 
    2654Config C; 
     55C.readFile("testik.cfg"); 
    2756Setting& S=C.getRoot();; 
    2857prtS(S); 
     
    3059vec x= getVec(S["application"]["misc"]["vec"]); 
    3160cout << x << endl; 
    32 cout << "wo co go?" <<endl; 
    33 //cout << getVec(S["ivec"]) << endl; 
    3461 
    3562return 0; 
    3663} 
    37  
  • bdm/config/testik.cfg

    r242 r243  
    11application: 
    22{ 
    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        }; 
    2626}; 
    2727