Changeset 477 for library/bdm/base/user_info.h
- Timestamp:
- 08/05/09 14:40:03 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/user_info.h
r474 r477 165 165 the UIFile dealocation). And that is exactly the mechanism implemented within SettingResolver class. It assures, 166 166 that the #result Setting reference is valid within the scope of SettingResolver instance. 167 167 168 168 \ref ui_page 169 169 */ … … 288 288 289 289 //! This methods converts a Setting into a new templated array of type Array<T> 290 template<class T> static void from_setting ( Array<T> &array_to_load, const Setting &element ) {290 template<class T> static void from_setting ( T &variable_to_load, const Setting &element ) { 291 291 const SettingResolver link ( element ); 292 292 … … 306 306 //! The exception can help to find the place where the template is misused and also to correct it. 307 307 template<class T> static void from_setting ( T &array_to_load, const Setting &element ) { 308 throw UIException ( "from_setting is not implemented for this type", element );308 throw UIException ( "from_setting is not implemented for this type", element ); 309 309 } 310 310 … … 318 318 public: 319 319 320 //! Enumerical type used to determine whether the data for concrete Settingis is compulsory or optional 320 //! Enumerical type used to determine whether the data for concrete Settingis is compulsory or optional 321 321 enum SettingPresence { optional, compulsory } ; 322 322 … … 329 329 //! If there is not any sub-element named #name, the null pointer is returned. 330 330 template<class T> static T* build ( const Setting &element, const string &name, SettingPresence settingPresence = optional ) { 331 if ( !element.exists ( name ) ) 332 { 333 if( settingPresence == optional ) 331 if ( !element.exists ( name ) ) { 332 if ( settingPresence == optional ) 334 333 return NULL; 335 334 else … … 346 345 //! If there is not any sub-element indexed by #index, the null pointer is returned. 347 346 template<class T> static T* build ( const Setting &element, const int index, SettingPresence settingPresence = optional ) { 348 if ( element.getLength() <= index ) 349 { 350 if( settingPresence == optional ) 347 if ( element.getLength() <= index ) { 348 if ( settingPresence == optional ) 351 349 return NULL; 352 else 353 { 350 else { 354 351 stringstream stream; 355 352 stream << index; 356 throw UIException ( "the compulsory Setting with the index " + stream.str() + " is missing", element );353 throw UIException ( "the compulsory Setting with the index " + stream.str() + " is missing", element ); 357 354 } 358 355 } … … 380 377 //! If there is not any sub-element named #name, this method returns false. 381 378 template<class T> static bool get ( T &instance, const Setting &element, const string &name, SettingPresence settingPresence = optional ) { 382 if ( !element.exists ( name ) ) 383 { 384 if( settingPresence == optional ) 379 if ( !element.exists ( name ) ) { 380 if ( settingPresence == optional ) 385 381 return false; 386 382 else … … 395 391 //! If there is not any sub-element indexed by #index, this method returns false. 396 392 template<class T> static bool get ( T &instance, const Setting &element, const int index, SettingPresence settingPresence = optional ) { 397 if ( element.getLength() <= index ) 398 { 399 if( settingPresence == optional ) 393 if ( element.getLength() <= index ) { 394 if ( settingPresence == optional ) 400 395 return false; 401 else 402 { 396 else { 403 397 stringstream stream; 404 398 stream << index; 405 throw UIException ( "the compulsory Setting with the index " + stream.str() + " is missing", element );399 throw UIException ( "the compulsory Setting with the index " + stream.str() + " is missing", element ); 406 400 } 407 401 }