57 void clip_ws( std::string* str ) {
60 std::string::iterator itr;
61 for( itr = str->begin(); itr != str->end(); ++itr )
62 if( *itr !=
' ' )
break;
63 str->erase( str->begin(), itr );
67 std::string::iterator itr;
68 for( itr = str->end() - 1; itr > str->begin() - 1; --itr )
69 if( *itr !=
' ' )
break;
70 str->erase( itr + 1, str->end() );
76 namespace OptionsFromStreamPack {
78 namespace OptionsFromStreamUtilityPack {
93 (*itr).second.second.set(
true);
102 options_group_map_t::const_iterator itr =
options_group_map_.find( options_group_name );
105 return options_group_t(const_cast<option_to_value_map_t*>(&(*itr).second.first));
113 (*og_itr).second.second.set(
false);
120 for( ; og_itr !=
end(); ++og_itr ) {
121 if( (*og_itr).second.second ==
false )
132 std::string curr_word;
137 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
138 std::cout <<
"\n*** Entering OptionsFromStream::read_options(...)!\n\n";
142 while( curr_word !=
"begin_options" && !in.eof() )
144 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
145 std::cout <<
"Found begin_options, start parsing options!\n";
152 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
153 std::cout <<
"\ncurr_word = \""<<curr_word<<
"\"\n";
155 if( curr_word ==
"}" ) {
156 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
157 std::cout <<
"Found \'}\', Moving on to the next options group or the end!\n";
161 if( curr_word ==
"end_options" ) {
162 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
163 std::cout <<
"Found \'end_options\', stoping parsing options!\n";
169 ,
"OptionsFromStream::read_options(...) : "
170 "Error, curr_word = \'" << curr_word <<
" != \'options_group\'" );
172 std::getline(in,curr_word,
'{');
173 clip_ws( &curr_word );
174 const std::string optgroup_name = curr_word;
175 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
176 std::cout <<
"\noptgroup_name = \"" << optgroup_name <<
"\"\n";
182 std::string optgroup_options;
183 getline(in,optgroup_options,
'}');
184 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
185 std::cout <<
"optgroup_options = \"" << optgroup_options <<
"\"\n";
187 std::istringstream optgroup_options_in(optgroup_options);
192 std::string option_and_value;
193 getline(optgroup_options_in,option_and_value,
';');
199 clip_ws(&option_and_value);
200 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
201 std::cout <<
" option_and_value = \"" << option_and_value <<
"\"\n";
203 if(!option_and_value.length())
208 equal_idx==std::string::npos, std::logic_error,
209 "Error, for the option group \"" << optgroup_name <<
"\""
210 <<
" the option value string \"" << option_and_value <<
"\" is missing the \"=\" separator!"
212 std::string option = option_and_value.substr(0,equal_idx);
213 std::string value = option_and_value.substr(equal_idx+1);
216 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
217 std::cout <<
" option = \"" << option <<
"\"\n";
218 std::cout <<
" value = \"" << value <<
"\"\n";
220 optval[option] = value;
223 #ifdef PRINT_OPTIONS_FROM_STREAM_TRACE
224 std::cout <<
"\n*** Leaving OptionsFromStream::read_options(...)!\n\n";
229 out <<
"\nbegin_options\n";
231 for( ; og_itr !=
end(); ++og_itr ) {
234 if(itr == optgrp.
end())
continue;
236 for( ; itr != optgrp.
end(); ++itr ) {
240 out <<
" " << name <<
" = " << value <<
";\n";
244 out <<
"\nend_options\n\n";
AbstractLinAlgPack::size_type size_type
option_to_value_map_t::const_iterator const_iterator
void print_options(std::ostream &out) const
Print the options to an output stream.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const std::string & option_name(OptionsGroup::const_iterator &itr)
myDepList set(dependee1,"val1")
OptionsFromStreamUtilityPack::options_group_map_t::const_iterator const_iterator
non-const iterator through options group access options
OptionsFromStreamUtilityPack::OptionsGroup options_group_t
{OptionsGroup} typedef
options_group_map_t options_group_map_
void read_options(std::istream &in)
Add / modify options read in from a text stream.
OptionsFromStreamUtilityPack::option_to_value_map_t option_to_value_map_t
Class used to encapsulate options belonging an options group.
const OptionsFromStream::options_group_t options_group(OptionsFromStream::const_iterator &itr)
const std::string & options_group_name(OptionsFromStream::const_iterator &itr)
void reset_unaccessed_options_groups()
Reset the flags to false for if the options groups was accessed.
static std::string option_does_not_exist_
options_group_t options_group(const std::string &options_group_name)
void print_unaccessed_options_groups(std::ostream &out) const
Print a list of options groups never accessed (accessed flag is falsed).
OptionsFromStreamUtilityPack::options_group_map_t::iterator iterator
const iterator through options group access options
const std::string & option_value(OptionsGroup::const_iterator &itr)