Skip to content
Snippets Groups Projects
Commit e6fc7ad5 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Merge branch 'allow-adl-lookup-of-toString' into 'master'

allow ADL of `toString` in Property

See merge request !372
parents fd03aaf7 345694ce
No related branches found
No related tags found
1 merge request!372allow ADL of `toString` in Property
Pipeline #
......@@ -23,6 +23,7 @@ namespace GaudiMath
};
StatusCode parse(Type&, const std::string&);
std::string toString(const Type&);
std::ostream& toStream(const Type&, std::ostream&);
inline std::ostream& operator<<(std::ostream& os, const Type& t) { return toStream(t,os); }
......
......@@ -37,9 +37,12 @@ namespace Interpolation {
StatusCode parse(Type& t, const std::string& in) {
return Gaudi::Parsers::parse_(t,in);
}
std::ostream& toStream(const Type& t, std::ostream& os) {
std::string toString(const Type& t) {
assert(0<=t && t<=Type::Akima_Periodic);
return os << std::quoted( table[t], '\'' );
return table[t];
}
std::ostream& toStream(const Type& t, std::ostream& os) {
return os << std::quoted( toString(t), '\'' );
}
} }
......@@ -152,7 +152,11 @@ namespace Gaudi
{
template <class TYPE>
struct StringConverter {
inline std::string toString( const TYPE& v ) { return Gaudi::Utils::toString( v ); }
inline std::string toString( const TYPE& v )
{
using Gaudi::Utils::toString;
return toString( v );
}
inline TYPE fromString( const std::string& s )
{
TYPE tmp;
......@@ -178,9 +182,10 @@ namespace Gaudi
struct BoundedVerifier {
void operator()( const TYPE& value ) const
{
using Gaudi::Utils::toString;
// throw the exception if the limit is defined and value is outside
if ( ( m_hasLowerBound && ( value < m_lowerBound ) ) || ( m_hasUpperBound && ( m_upperBound < value ) ) )
throw std::out_of_range( "value " + Gaudi::Utils::toString( value ) + " outside range" );
throw std::out_of_range( "value " + toString( value ) + " outside range" );
}
/// Return if it has a lower bound
......@@ -1137,8 +1142,9 @@ namespace Gaudi
template <class TYPE>
StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc )
{
using Gaudi::Utils::toString;
return component && hasProperty( component, name )
? Gaudi::Utils::setProperty( component, name, Gaudi::Utils::toString( value ), doc )
? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
: StatusCode::FAILURE;
}
// ========================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment