diff --git a/Code/Core/otbWrapperParameterKey.cxx b/Code/Core/otbWrapperParameterKey.cxx index 4c67028a359a4408e3f162d064b084a50666fba6..2cb1932903131dd2665211b1e0e9a8cb83a32d79 100644 --- a/Code/Core/otbWrapperParameterKey.cxx +++ b/Code/Core/otbWrapperParameterKey.cxx @@ -35,7 +35,7 @@ ParameterKey::ParameterKey( const char * val ) ParameterKey::ParameterKey( const std::string & val ) { - this->SetKey(val);//m_Key = val; + this->SetKey(val); } ParameterKey::~ParameterKey() @@ -73,16 +73,16 @@ ParameterKey::Split() void ParameterKey::Append( const std::string & val ) { + m_Key.append("."); m_Key.append(val); } - /* + void ParameterKey::Append( const ParameterKey & pKey ) { - - return appli; + this->Append( pKey.GetKey() ); } - */ + } // end namespace Wrapper } //end namespace otb diff --git a/Code/Core/otbWrapperParameterKey.h b/Code/Core/otbWrapperParameterKey.h index 0d09ce7cf91909737cad21e02c6b88411d09bb3f..cd1b15bd8bffad3b8de41579ea214d90fdea61a6 100644 --- a/Code/Core/otbWrapperParameterKey.h +++ b/Code/Core/otbWrapperParameterKey.h @@ -20,6 +20,8 @@ #include <string> #include "otbMacro.h" +#include <itksys/RegularExpression.hxx> + namespace otb { @@ -70,7 +72,7 @@ last() : return "tata" void Append( const std::string & val ); /** Append a string at the end of the key. A point separator will be added before the string. */ - //void Append( const std::string & val ); + void Append( const ParameterKey & pKey ); /** Get Key value */ std::string GetKey() @@ -78,24 +80,27 @@ last() : return "tata" return m_Key; } + /** Get Key value */ + std::string GetKey() const + { + return m_Key; + } + /** Set Key value */ void SetKey( const std::string & val ) { - /* - if( val.substr(1) == "." || - val.substr(val.size()-2, val.size()-1) == ".") + // Check chain : minuscule, alphanumerical or "." + itksys::RegularExpression reg; + reg.compile("([^0-9a-z\\.])"); + + if(!reg.find(val)) { - itkGenericExceptionMacro( "invalid key. Can't start or begin with a \".\"."); + m_Key = val; } - */ - m_Key = val; - /* - if( this->Split().size() != 3 ) + else { - m_Key = ""; - itkGenericExceptionMacro( "Invalid key. Must follow the format \"string1.string2.string3\"."); + itkGenericExceptionMacro( "Invalid key "<<val<<". Must be in minuscule, containing alphanumerical caracters or \".\""); } - */ } private: