Changeset 377 for bdm/user_info.h
- Timestamp:
- 06/15/09 18:27:16 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/user_info.h
r370 r377 137 137 template<class T> static void from_setting( T* &instance, const Setting &element ) 138 138 { 139 const SettingsResolver link_expander( element ); 140 const Setting &root = link_expander.root(); 141 142 ASSERT_UITYPE(root,TypeGroup); 139 const SettingResolver link( element ); 140 141 ASSERT_UITYPE(link.result,TypeGroup); 143 142 144 143 // we get a velue stored in the "class" attribute 145 144 string class_name; 146 if( ! root.lookupValue( "class", class_name ) )147 ui_error( "the obligatory ""class"" identifier is missing", root );145 if( !link.result.lookupValue( "class", class_name ) ) 146 ui_error( "the obligatory ""class"" identifier is missing", link.result ); 148 147 149 148 // and finally we find a UserInfo related to this type … … 164 163 try 165 164 { 166 instance->from_setting( root );165 instance->from_setting( link.result ); 167 166 } 168 167 catch(SettingException xcptn) … … 177 176 template<class T> static void from_setting( Array<T> &array_to_load, const Setting &element ) 178 177 { 179 const SettingsResolver link_expander( element ); 180 const Setting &root = link_expander.root(); 181 182 ASSERT_UITYPE(root,TypeList); 183 184 int len = root.getLength(); 178 const SettingResolver link( element ); 179 180 ASSERT_UITYPE(link.result,TypeList); 181 182 int len = link.result.getLength(); 185 183 array_to_load.set_length( len ); 186 184 if( len == 0 ) return; 187 185 188 186 for( int i=0; i < len; i++ ) 189 from_setting( array_to_load(i), root[i] );187 from_setting( array_to_load(i), link.result[i] ); 190 188 } 191 189 … … 212 210 // vraci true, kdyz to byl platny link, jinak false.. v pripade chyby konci it_errorem.. 213 211 // do elementu vrati setting prislusny po rozbaleni linku, jinak ponecha beze zmeny 214 class Setting sResolver212 class SettingResolver 215 213 { 216 214 private: 217 215 UI_File *file; 218 const Setting *result; 216 217 const Setting &initialize_reference( UI_File* &file, const Setting &potential_link); 219 218 220 219 public: 221 222 SettingsResolver( const Setting &potential_link ); 220 const Setting &result; 221 222 SettingResolver( const Setting &potential_link ); 223 223 224 ~SettingsResolver(); 225 226 const Setting& root() const; 224 ~SettingResolver(); 227 225 }; 228 226 … … 270 268 template< class T> static void save( const T * const instance, Setting &element, const string &name = "") 271 269 { 272 Setting & root = (name == "") ? element.add( Setting::TypeGroup )270 Setting &set = (name == "") ? element.add( Setting::TypeGroup ) 273 271 : element.add( name, Setting::TypeGroup ); 274 272 … … 276 274 277 275 // add attribute "class" 278 Setting &type = root.add( "class", Setting::TypeString );276 Setting &type = set.add( "class", Setting::TypeString ); 279 277 type = class_name; 280 278 281 279 try 282 280 { 283 instance->to_setting( root );281 instance->to_setting( set ); 284 282 } 285 283 catch(SettingException xcptn)