Changeset 281 for bdm/uibuilder.cpp
- Timestamp:
- 02/24/09 14:13:23 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/uibuilder.cpp
r278 r281 1 1 #include "uibuilder.h" 2 2 3 namespace bdm {4 5 3 namespace bdm { 4 5 //! global map of UIbulder names to instances of UIbuilders. Created by UIREGISTER macro 6 6 UImap __uimap__; 7 7 8 bdmroot* UIexternal::build (Setting &S) const{8 bdmroot* UIexternal::build ( Setting &S ) const { 9 9 Config C; 10 10 bdmroot* tmp; 11 try{ 12 C.readFile((const char*)S["filename"]); 13 } catch (...){ 14 it_error("File " + string((const char*)S["filename"]) + " not found or broken"); 11 try { 12 C.readFile ( ( const char* ) S["filename"] ); 15 13 } 16 try { 17 Setting& remS=C.lookup((const char*)S["path"]); 18 UIbuild(remS,tmp); 14 catch ( ... ) { 15 it_error ( "File " + string ( ( const char* ) S["filename"] ) + " not found or broken" ); 19 16 } 20 catch (...) { it_error("External field " + string(S.getPath()) + " not valid"); 17 try { 18 Setting& remS=C.lookup ( ( const char* ) S["path"] ); 19 UIbuild ( remS,tmp ); 20 } 21 catch ( ... ) { 22 it_error ( "External field " + string ( S.getPath() ) + " not valid" ); 21 23 } 22 24 return tmp; 23 25 }; 24 UIREGISTER (UIexternal);26 UIREGISTER ( UIexternal ); 25 27 26 bdmroot* UIinternal::build (Setting &S) const{28 bdmroot* UIinternal::build ( Setting &S ) const { 27 29 bdmroot* tmp; 28 try { 30 try { 29 31 Setting* Stmp = &S; 30 do {Stmp=&(Stmp->getParent());} while (!Stmp->isRoot()); 31 Setting& intS=Stmp->lookup((const char*)S["path"]); 32 UIbuild(intS,tmp); 32 do {Stmp=& ( Stmp->getParent() );} 33 while ( !Stmp->isRoot() ); 34 Setting& intS=Stmp->lookup ( ( const char* ) S["path"] ); 35 UIbuild ( intS,tmp ); 33 36 } 34 catch (...) { it_error("Internal field " + string(S.getPath()) + " not valid"); 37 catch ( ... ) { 38 it_error ( "Internal field " + string ( S.getPath() ) + " not valid" ); 35 39 } 36 40 return tmp; 37 41 }; 38 UIREGISTER (UIinternal);42 UIREGISTER ( UIinternal ); 39 43 40 void UI_DBG ( Setting &S, const string &spc ) { 41 const char *Name=S.getName(); 42 if ( Name!=NULL ) {cout << spc << std::string ( Name );}; 43 Setting::Type T=S.getType(); 44 switch ( T ) { 45 case Setting::TypeArray: 46 cout << endl; 47 for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}; 48 break; 49 case Setting::TypeList: 50 cout << endl; 51 for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}; 52 break; 53 case Setting::TypeGroup: 54 cout << endl; 55 for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );} 56 break; 57 case Setting::TypeInt: 58 cout << " = "; 59 cout << int ( S ) <<endl; 60 break; 61 case Setting::TypeFloat: 62 cout << " = "; 63 cout << double ( S ) <<endl; 64 break; 65 case Setting::TypeString: 66 cout << " = "; 67 cout << ( const char* ) ( S ) <<endl; 68 break; 69 case Setting::TypeBoolean: 70 cout << " = "; 71 cout << bool ( S ) <<endl; 72 break; 73 default: {cout << "?";}; 74 } 44 void UI_DBG ( Setting &S, const string &spc ) { 45 const char *Name=S.getName(); 46 if ( Name!=NULL ) {cout << spc << std::string ( Name );}; 47 Setting::Type T=S.getType(); 48 switch ( T ) { 49 case Setting::TypeArray: 50 cout << endl; 51 for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}; 52 break; 53 case Setting::TypeList: 54 cout << endl; 55 for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );}; 56 break; 57 case Setting::TypeGroup: 58 cout << endl; 59 for ( int i=0;i<S.getLength();i++ ) {UI_DBG ( S[i], spc+" " );} 60 break; 61 case Setting::TypeInt: 62 cout << " = "; 63 cout << int ( S ) <<endl; 64 break; 65 case Setting::TypeFloat: 66 cout << " = "; 67 cout << double ( S ) <<endl; 68 break; 69 case Setting::TypeString: 70 cout << " = "; 71 cout << ( const char* ) ( S ) <<endl; 72 break; 73 case Setting::TypeBoolean: 74 cout << " = "; 75 cout << bool ( S ) <<endl; 76 break; 77 default: {cout << "?";}; 75 78 } 79 } 76 80 77 81 }