10 #include "Teuchos_StringToIntMap.hpp"
14 StringToIntMap::StringToIntMap(
15 const std::string& defaultGroupName_in,
int n,
const char* strings[]
16 ) : defaultGroupName_(defaultGroupName_in)
18 typedef map_t::value_type val_t;
19 for(
int i = 0; i < n; ++i ) {
20 const bool unique = map_.insert( val_t( strings[i], i ) ).second;
23 ,
"Teuchos::StringToIntMap::StringToIntMap(...): "
24 <<
"Error, the std::string \"" << strings[i] <<
"\" is a duplicate for "
25 << defaultGroupName_ );
31 map_t::const_iterator itr = map_.find( option );
34 ,
"Teuchos::StringToIntMap:::get(\""<<option<<
"\",...): "
35 <<
"Error, the std::string \"" << option <<
"\" is not recongnised for "
36 << ( groupName.length() ? groupName : defaultGroupName_ )
37 <<
"; valid selections include " << this->validSelections() <<
"."
44 std::string StringToIntMap::validSelections()
const
46 std::ostringstream oss;
48 map_t::const_iterator itr = map_.begin();
49 for(
int i = 0; itr != map_.end(); ++itr, ++i ) {
52 oss <<
"\""<<itr->first<<
"\":"<<itr->second;
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
int get(const std::string &option, const std::string &groupName="") const