42 #include "Teuchos_StringToIntMap.hpp"
46 StringToIntMap::StringToIntMap(
47 const std::string& defaultGroupName_in,
int n,
const char* strings[]
48 ) : defaultGroupName_(defaultGroupName_in)
50 typedef map_t::value_type val_t;
51 for(
int i = 0; i < n; ++i ) {
52 const bool unique = map_.insert( val_t( strings[i], i ) ).second;
55 ,
"Teuchos::StringToIntMap::StringToIntMap(...): "
56 <<
"Error, the std::string \"" << strings[i] <<
"\" is a duplicate for "
57 << defaultGroupName_ );
63 map_t::const_iterator itr = map_.find( option );
66 ,
"Teuchos::StringToIntMap:::get(\""<<option<<
"\",...): "
67 <<
"Error, the std::string \"" << option <<
"\" is not recongnised for "
68 << ( groupName.length() ? groupName : defaultGroupName_ )
69 <<
"; valid selections include " << this->validSelections() <<
"."
76 std::string StringToIntMap::validSelections()
const
78 std::ostringstream oss;
80 map_t::const_iterator itr = map_.begin();
81 for(
int i = 0; itr != map_.end(); ++itr, ++i ) {
84 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