14 if(section_name == Name())
16 std::vector<util::ConfigParameters>::iterator pi = _parameters.begin();
17 while(pi != _parameters.end()){
18 if(pi->Name() == section_name)
19 return(_parameters[pi-_parameters.begin()]);
22 std::cerr <<
"util::ConfigurationObject::GetSectionParameters::Fatal Error - Section " 23 << section_name <<
" does not exist. Exiting." << std::endl;
26 return(_parameters[0]);
31 std::vector<util::ConfigParameters>::const_iterator pi = _parameters.begin();
32 unsigned int index = 0;
33 if(section_name != Name()){
34 while(pi != _parameters.end()){
35 if(pi->Name() == section_name)
46 return(_sections[SectionIndex(section_name)]);
50 return(_sections[SectionIndex(section_name)]);
57 std::getline(Inf,line);
60 std::vector<std::string> tokens;
62 if(tokens[0] ==
"#Section"){
63 if(tokens.size() > 1){
64 if(tokens[1] == section_name){
65 return (this->ReadSection(Inf));
73 return(std::string(
""));
78 std::string empty_retval;
82 std::getline(Inf,line);
85 std::vector<std::string> tokens;
87 if(tokens[0] ==
"#Section")
98 std::ostringstream Ostr;
101 int open_sections = 1;
103 std::getline(Inf,line);
105 std::vector<std::string> tokens;
107 if(tokens[0] ==
"#EndSection") {
108 open_sections = open_sections - 1;
109 if(open_sections == 0)
112 else if(tokens[0] ==
"#Section") {
117 Ostr << line << std::endl;
126 Ostr <<
"#" << std::endl
127 <<
"#Section Configuration" << std::endl
130 <<
"#Sections " << cob.
_sections[0] << std::endl
131 <<
"#EndSection" << std::endl;
134 std::vector<util::ConfigParameters>::const_iterator pi = cob.
_parameters.begin();
136 Ostr <<
"#" << std::endl
137 <<
"#Section " << pi->Name() << std::endl
141 <<
"#EndSection" << std::endl;
152 std::string configsection = cob.
ExtractSection(
"Configuration",Istr);
153 cob.
Name(
"Configuration");
154 std::istringstream ConfigIstr(configsection);
159 ConfigIstr.str(configsection);
162 while(std::getline(ConfigIstr,line) && cob.
_sections.empty()){
164 std::vector<std::string> tokens;
166 std::vector<std::string>::iterator ti = tokens.begin();
167 if(*ti++ ==
"#Sections"){
168 std::ostringstream Ostr;
169 while(ti != tokens.end())
170 Ostr << *ti++ <<
" ";
179 while(!sectionname.empty()){
182 std::istringstream SectionIstr(section);
191 SectionIstr.str(section);
194 while(std::getline(SectionIstr,line) && !done){
196 std::vector<std::string> tokens;
198 std::vector<std::string>::iterator ti = tokens.begin();
199 if(*ti++ ==
"#Sections"){
200 std::ostringstream Ostr;
201 while(ti != tokens.end())
202 Ostr << *ti++ <<
" ";
virtual std::string ReadSection(std::istream &Inf)
unsigned int SectionIndex(const std::string §ion_name) const
util::ConfigParameters & Section(const std::string §ion_name)
Extract parameters for particular section.
void TokenizeString(std::vector< std::string > &tokens, const std::string &source)
Tokenize string.
Defines MPI-specific parallel global and program classes.
std::ostream & operator<<(std::ostream &Ostr, const util::ConfigurationObject &cob)
Stream output operator for util::ConfigurationObject.
const std::string & Name() const
std::istream & operator>>(std::istream &Istr, util::ConfigurationObject &cob)
Stream input operator for util::ConfigurationObject.
virtual std::string AdvanceToNextSection(std::istream &Inf)
std::vector< util::ConfigParameters > _parameters
std::vector< std::string > _sections
Configuration object interface (for config files, etc).
std::string & NavigationSection(const std::string §ion_name)
virtual std::string ExtractSection(const std::string §ion_name, std::istream &Inf)