You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
Hi, i would like to have a funtion like this in ticpp::element
/**
Returns an attribute of @a name from an element.
Uses FromString to convert the string to the type of choice.
@param name The name of the attribute you are querying.
@param throwIfNotFound [DEF] If true, will throw an exception if the
attribute doesn't exist
@throws Exception When the attribute doesn't exist and throwIfNotFound is
true
@see GetAttributeOrDefault
*/
template< class T >
T GetAttribute( const std::string& name, bool throwIfNotFound = true ) const
{
// Get the attribute's value as a std::string
std::string temp;
T value;
if ( !GetAttributeImp( name, &temp ) )
{
if ( throwIfNotFound )
{
TICPPTHROW( "Attribute does not exist" );
}
}
else
{
// Stream the value from the string to T
FromString( temp, &value );
}
return value;
}
I some Situations, this is quite useful, so i think it should be added to
ticpp. Maybe with a better note in the documentation, that the Object has
to be copied, and you should prefer the "old" version, where you can.
But if you want to call a function with a Parameter from a Attribute, this
little function is very useful.
Original issue reported on code.google.com by PerryHop...@googlemail.com on 21 Jun 2008 at 6:48
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
PerryHop...@googlemail.com
on 21 Jun 2008 at 6:48The text was updated successfully, but these errors were encountered: