Changeset 710

Show
Ignore:
Timestamp:
11/05/09 17:51:42 (14 years ago)
Author:
mido
Message:

patch of ui::get, NOT TESTE YET (it seems impossible to build the whole library at the moment)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/user_info.h

    r691 r710  
    493493        //! If there is not any sub-element named #name, this method returns false. 
    494494        template<class T> static bool get ( Array<T> &array_to_load, const Setting &element, const string &name, SettingPresence settingPresence = optional ) { 
    495                 if ( !element.exists ( name ) ) 
    496                         return false; 
     495                if ( !element.exists ( name ) ) { 
     496                        if ( settingPresence == optional ) 
     497                                return false; 
     498                        else 
     499                                throw UISettingException ( "UIException: the compulsory Setting named \"" + name + "\" is missing.", element ); 
     500                } 
    497501 
    498502                from_setting ( array_to_load, to_child_setting ( element, name ) ); 
     
    503507        //! If there is not any sub-element indexed by #index, this method returns false. 
    504508        template<class T> static bool get ( Array<T> &array_to_load, const Setting &element, const int index, SettingPresence settingPresence = optional ) { 
    505                 if ( element.getLength() <= index ) 
    506                         return false; 
     509                if ( element.getLength() <= index ) { 
     510                        if ( settingPresence == optional ) 
     511                                return shared_ptr<T>(); 
     512                        else { 
     513                                stringstream stream; 
     514                                stream << index; 
     515                                throw UISettingException ( "UIException: the compulsory Setting with the index " + stream.str() + " is missing.", element ); 
     516                        } 
     517                } 
    507518 
    508519                from_setting ( array_to_load, to_child_setting ( element, index ) );