GETPOT_NAMESPACE::GetPot Class Reference

#include <getpot.h>

List of all members.

Classes

struct  ltstr
struct  variable

Public Member Functions

 GetPot ()
 GetPot (const GetPot &)
 GetPot (const int argc_, char **argv_, const char *FieldSeparator=0x0)
 GetPot (const char *FileName, const char *CommentStart=0x0, const char *CommentEnd=0x0, const char *FieldSeparator=0x0)
 GetPot (const std::string &FileName, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\n"), const std::string &FieldSeparator=std::string(" \t\n"))
 ~GetPot ()
GetPotoperator= (const GetPot &)
void parse_command_line (const int argc_, char **argv_, const char *FieldSeparator=0x0)
void parse_input_file (const std::string &FileName, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\n"), const std::string &FieldSeparator=std::string(" \t\n"))
void absorb (const GetPot &Other)
void clear_requests ()
void disable_request_recording ()
void enable_request_recording ()
const char * operator[] (unsigned Idx) const
template<typename T >
get (unsigned Idx, const T &Default) const
const char * get (unsigned Idx, const char *Default) const
unsigned size () const
bool options_contain (const char *FlagList) const
bool argument_contains (unsigned Idx, const char *FlagList) const
bool have_variable (const char *VarName) const
bool have_variable (const std::string &VarName) const
template<typename T >
operator() (const char *VarName, const T &Default) const
template<typename T >
operator() (const std::string &VarName, const T &Default) const
const char * operator() (const char *VarName, const char *Default) const
const char * operator() (const std::string &VarName, const char *Default) const
template<typename T >
operator() (const char *VarName, const T &Default, unsigned Idx) const
template<typename T >
operator() (const std::string &VarName, const T &Default, unsigned Idx) const
const char * operator() (const char *VarName, const char *Default, unsigned Idx) const
const char * operator() (const std::string &VarName, const char *Default, unsigned Idx) const
template<typename T >
get_value_no_default (const char *VarName, const T &Default) const
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default) const
const char * get_value_no_default (const char *VarName, const char *Default) const
const char * get_value_no_default (const std::string &VarName, const char *Default) const
template<typename T >
get_value_no_default (const char *VarName, const T &Default, unsigned Idx) const
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default, unsigned Idx) const
const char * get_value_no_default (const char *VarName, const char *Default, unsigned Idx) const
const char * get_value_no_default (const std::string &VarName, const char *Default, unsigned Idx) const
template<typename T >
void set (const char *VarName, const T &Value, const bool Requested=true)
template<typename T >
void set (const std::string &VarName, const T &Value, const bool Requested=true)
void set (const char *VarName, const char *Value, const bool Requested=true)
void set (const std::string &VarName, const char *Value, const bool Requested=true)
unsigned vector_variable_size (const char *VarName) const
unsigned vector_variable_size (const std::string &VarName) const
STRING_VECTOR get_variable_names () const
STRING_VECTOR get_section_names () const
std::set< std::string > get_overridden_variables () const
void set_prefix (const char *Prefix)
bool search_failed () const
void disable_loop ()
void enable_loop ()
void reset_cursor ()
void init_multiple_occurrence ()
bool search (const char *option)
bool search (const std::string &option)
bool search (unsigned No, const char *P,...)
template<typename T >
next (const T &Default)
const char * next (const char *Default)
template<typename T >
follow (const T &Default, const char *Option)
const char * follow (const char *Default, const char *Option)
template<typename T >
follow (const T &Default, unsigned No, const char *Option,...)
const char * follow (const char *Default, unsigned No, const char *Option,...)
template<typename T >
direct_follow (const T &Default, const char *Option)
const char * direct_follow (const char *Default, const char *Option)
void reset_nominus_cursor ()
STRING_VECTOR nominus_vector () const
unsigned nominus_size () const
const char * next_nominus ()
STRING_VECTOR unidentified_arguments (unsigned Number, const char *Known,...) const
STRING_VECTOR unidentified_arguments (const std::set< std::string > &Knowns) const
STRING_VECTOR unidentified_arguments (const std::vector< std::string > &Knowns) const
STRING_VECTOR unidentified_arguments () const
STRING_VECTOR unidentified_options (unsigned Number, const char *Known,...) const
STRING_VECTOR unidentified_options (const std::set< std::string > &Knowns) const
STRING_VECTOR unidentified_options (const std::vector< std::string > &Knowns) const
STRING_VECTOR unidentified_options () const
std::string unidentified_flags (const char *Known, int ArgumentNumber) const
STRING_VECTOR unidentified_variables (unsigned Number, const char *Known,...) const
STRING_VECTOR unidentified_variables (const std::set< std::string > &Knowns) const
STRING_VECTOR unidentified_variables (const std::vector< std::string > &Knowns) const
STRING_VECTOR unidentified_variables () const
STRING_VECTOR unidentified_sections (unsigned Number, const char *Known,...) const
STRING_VECTOR unidentified_sections (const std::set< std::string > &Knowns) const
STRING_VECTOR unidentified_sections (const std::vector< std::string > &Knowns) const
STRING_VECTOR unidentified_sections () const
STRING_VECTOR unidentified_nominuses (unsigned Number, const char *Known,...) const
STRING_VECTOR unidentified_nominuses (const std::set< std::string > &Knowns) const
STRING_VECTOR unidentified_nominuses (const std::vector< std::string > &Knowns) const
STRING_VECTOR unidentified_nominuses () const
int print (std::ostream &out_stream=std::cout) const
int print (const char *custom_prefix, std::ostream &out_stream=std::cout, unsigned int skip_count=1) const
template<>
std::string _convert_to_type (const std::string &String, const std::string &) const
template<>
std::string _convert_to_type_no_default (const char *, const std::string &String, const std::string &) const
template<typename T >
get (unsigned int Idx, const T &Default) const
template<typename T >
follow (const T &Default, unsigned int No, const char *P,...)
template<typename T >
operator() (const char *VarName, const T &Default, unsigned int Idx) const
template<typename T >
operator() (const std::string &VarName, const T &Default, unsigned int Idx) const
template<typename T >
get_value_no_default (const char *VarName, const T &Default, unsigned int Idx) const
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default, unsigned int Idx) const

Private Member Functions

void _basic_initialization ()
const char * _internal_managed_copy (const std::string &Arg) const
void _record_argument_request (const std::string &Arg) const
void _record_variable_request (const std::string &Arg) const
void _set_variable (const std::string &VarName, const std::string &Value, const bool Requested)
void _parse_argument_vector (const STRING_VECTOR &ARGV)
const variable_find_variable (const char *) const
const variable_request_variable (const char *) const
const char * _match_starting_string (const char *StartString)
bool _check_flags (const std::string &Str, const char *FlagList) const
template<typename T >
_convert_to_type (const std::string &String, const T &Default) const
std::string _convert_to_type (const std::string &String, const char *Default) const
template<typename T >
_convert_to_type_no_default (const char *VarName, const std::string &String, const T &Default) const
std::string _convert_to_type_no_default (const char *VarName, const std::string &String, const char *Default) const
const std::string _get_remaining_string (const std::string &String, const std::string &Start) const
bool _search_string_vector (const STRING_VECTOR &Vec, const std::string &Str) const
void _skip_whitespace (std::istream &istr)
const std::string _get_next_token (std::istream &istr)
const std::string _get_string (std::istream &istr)
const std::string _get_until_closing_bracket (std::istream &istr)
const std::string _get_until_closing_square_bracket (std::istream &istr)
STRING_VECTOR _read_in_stream (std::istream &istr)
STRING_VECTOR _read_in_file (const std::string &FileName)
std::string _process_section_label (const std::string &Section, STRING_VECTOR &section_stack)
std::string _DBE_expand_string (const std::string &str)
std::string _DBE_expand (const std::string &str)
const GetPot::variable_DBE_get_variable (const std::string &str)
STRING_VECTOR _DBE_get_expr_list (const std::string &str, const unsigned ExpectedNumber)
template<>
bool _convert_to_type (const std::string &String, const bool &Default) const
template<>
bool _convert_to_type_no_default (const char *VarName, const std::string &String, const bool &) const

Static Private Member Functions

template<typename T >
static std::string _convert_from_type (const T &Value)
static STRING_VECTOR _get_section_tree (const std::string &FullPath)

Private Attributes

std::string prefix
std::string section
STRING_VECTOR section_list
STRING_VECTOR argv
unsigned cursor
bool search_loop_f
bool search_failed_f
std::set< std::string > overridden_vars
int nominus_cursor
std::vector< unsigned > idx_nominus
std::vector< variablevariables
std::string _comment_start
std::string _comment_end
std::string _field_separator
libMesh::Threads::spin_mutex _getpot_mtx
std::set< const char *, ltstr_internal_string_container
std::set< std::string > _requested_arguments
std::set< std::string > _requested_variables
std::set< std::string > _requested_sections
bool request_recording_f

Detailed Description

Definition at line 106 of file getpot.h.


Constructor & Destructor Documentation

GETPOT_NAMESPACE::GetPot::GetPot (  )  [inline]

Definition at line 483 of file getpot.h.

References _basic_initialization().

00483                :
00484   prefix(),
00485   section(),
00486   section_list(),
00487   argv(),
00488   cursor(),
00489   search_loop_f(),
00490   search_failed_f(),
00491   nominus_cursor(),
00492   idx_nominus(),
00493   variables(),
00494   _comment_start(),
00495   _comment_end(),
00496   _field_separator(),
00497   _getpot_mtx(),
00498   _internal_string_container(),
00499   _requested_arguments(),
00500   _requested_variables(),
00501   _requested_sections(),
00502   request_recording_f()
00503 {
00504     _basic_initialization();
00505 }

GETPOT_NAMESPACE::GetPot::GetPot ( const GetPot Other  )  [inline]

Definition at line 653 of file getpot.h.

References _internal_string_container, and end.

00653                                   :
00654   prefix(Other.prefix),
00655   section(Other.section),
00656   section_list(Other.section_list),
00657   argv(Other.argv),
00658   cursor(Other.cursor),
00659   search_loop_f(Other.search_loop_f),
00660   search_failed_f(Other.search_failed_f),
00661   overridden_vars(),
00662   nominus_cursor(Other.nominus_cursor),
00663   idx_nominus(Other.idx_nominus),
00664   variables(Other.variables),
00665   _comment_start(Other._comment_start),
00666   _comment_end(Other._comment_end),
00667   _field_separator(Other._field_separator),
00668   _getpot_mtx(Other._getpot_mtx),
00669   _internal_string_container(),
00670   _requested_arguments(Other._requested_arguments),
00671   _requested_variables(Other._requested_variables),
00672   _requested_sections(Other._requested_sections),
00673   request_recording_f(Other.request_recording_f)
00674 {
00675     std::set<const char*,ltstr>::const_iterator it =
00676       Other._internal_string_container.begin();
00677 
00678     const std::set<const char*,ltstr>::const_iterator end =
00679       Other._internal_string_container.end();
00680 
00681     for (; it != end; ++it) {
00682         const char* otherstr = *it;
00683         char* newcopy = new char[strlen(otherstr)+1];
00684         strncpy(newcopy, otherstr, strlen(otherstr)+1);
00685         this->_internal_string_container.insert(newcopy);
00686     }
00687 }

GETPOT_NAMESPACE::GetPot::GetPot ( const int  argc_,
char **  argv_,
const char *  FieldSeparator = 0x0 
) [inline]

Definition at line 508 of file getpot.h.

References parse_command_line().

00509                                                       :
00510     // leave 'char**' non-const to honor less capable compilers ...
00511   prefix(),
00512   section(),
00513   section_list(),
00514   argv(),
00515   cursor(),
00516   search_loop_f(),
00517   search_failed_f(),
00518   nominus_cursor(),
00519   idx_nominus(),
00520   variables(),
00521   _comment_start(),
00522   _comment_end(),
00523   _field_separator(),
00524   _getpot_mtx(),
00525   _internal_string_container(),
00526   _requested_arguments(),
00527   _requested_variables(),
00528   _requested_sections(),
00529   request_recording_f()
00530 {
00531     this->parse_command_line(argc_, argv_, FieldSeparator);
00532 }

GETPOT_NAMESPACE::GetPot::GetPot ( const char *  FileName,
const char *  CommentStart = 0x0,
const char *  CommentEnd = 0x0,
const char *  FieldSeparator = 0x0 
) [inline]

Definition at line 564 of file getpot.h.

References parse_input_file().

00566                                                       :
00567   prefix(),
00568   section(),
00569   section_list(),
00570   argv(),
00571   cursor(),
00572   search_loop_f(),
00573   search_failed_f(),
00574   nominus_cursor(),
00575   idx_nominus(),
00576   variables(),
00577   _comment_start(),
00578   _comment_end(),
00579   _field_separator(),
00580   _getpot_mtx(),
00581   _internal_string_container(),
00582   _requested_arguments(),
00583   _requested_variables(),
00584   _requested_sections(),
00585   request_recording_f()
00586 {
00587   const std::string& StrCommentStart   = CommentStart   ? CommentStart   : std::string("#");
00588   const std::string& StrCommentEnd     = CommentEnd     ? CommentEnd     : std::string("\n");
00589   const std::string& StrFieldSeparator = FieldSeparator ? FieldSeparator : std::string(" \t\n");
00590   this->parse_input_file(FileName, StrCommentStart, StrCommentEnd, StrFieldSeparator);
00591 }

GETPOT_NAMESPACE::GetPot::GetPot ( const std::string &  FileName,
const std::string &  CommentStart = std::string("#"),
const std::string &  CommentEnd = std::string("\n"),
const std::string &  FieldSeparator = std::string(" \t\n") 
) [inline]

Definition at line 596 of file getpot.h.

References parse_input_file().

00599                                                 :
00600   prefix(),
00601   section(),
00602   section_list(),
00603   argv(),
00604   cursor(),
00605   search_loop_f(),
00606   search_failed_f(),
00607   nominus_cursor(),
00608   idx_nominus(),
00609   variables(),
00610   _comment_start(),
00611   _comment_end(),
00612   _field_separator(),
00613   _getpot_mtx(),
00614   _internal_string_container(),
00615   _requested_arguments(),
00616   _requested_variables(),
00617   _requested_sections(),
00618   request_recording_f()
00619 {
00620     this->parse_input_file(FileName, CommentStart, CommentEnd, FieldSeparator);
00621 }

GETPOT_NAMESPACE::GetPot::~GetPot (  )  [inline]

Definition at line 690 of file getpot.h.

References _internal_string_container, and end.

00691 {
00692     // // may be some return strings had to be created, delete now !
00693     std::set<const char*, ltstr>::const_iterator        it = _internal_string_container.begin();
00694     const std::set<const char*, ltstr>::const_iterator end = _internal_string_container.end();
00695     for(; it != end; ++it)
00696         delete [] *it;
00697 }


Member Function Documentation

void GETPOT_NAMESPACE::GetPot::_basic_initialization (  )  [inline, private]

Definition at line 465 of file getpot.h.

References _comment_end, _comment_start, _field_separator, cursor, nominus_cursor, prefix, request_recording_f, search_failed_f, search_loop_f, and section.

Referenced by GetPot(), parse_command_line(), and parse_input_file().

00466 {
00467     cursor = 0;              nominus_cursor = -1;
00468     search_failed_f = true;  search_loop_f = true;
00469     prefix = "";             section = "";
00470 
00471     // automatic request recording for later ufo detection
00472     request_recording_f = true;
00473 
00474     // comment start and end strings
00475     _comment_start = std::string("#");
00476     _comment_end   = std::string("\n");
00477 
00478     // default: separate vector elements by whitespaces
00479     _field_separator = " \t\n";
00480 }

bool GETPOT_NAMESPACE::GetPot::_check_flags ( const std::string &  Str,
const char *  FlagList 
) const [inline, private]

Definition at line 1618 of file getpot.h.

Referenced by argument_contains(), and options_contain().

01619 {
01620     const char* p=FlagList;
01621     for(; *p != '\0' ; p++)
01622         if( Str.find(*p) != std::string::npos ) return true; // found something
01623     return false;
01624 }

template<typename T >
static std::string GETPOT_NAMESPACE::GetPot::_convert_from_type ( const T &  Value  )  [inline, static, private]

Definition at line 439 of file getpot.h.

Referenced by _DBE_expand().

00439                                                         {
00440       std::ostringstream out_string;
00441       out_string << Value;
00442       return out_string.str();
00443     }

template<>
bool GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const bool &  Default 
) const [inline, private]
template<>
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const std::string &   
) const [inline]

Definition at line 1172 of file getpot.h.

01173 {
01174     return String;
01175 }

std::string GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const char *  Default 
) const [inline, private]

Definition at line 1179 of file getpot.h.

01180 {
01181     return String;
01182 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const T &  Default 
) const [inline, private]

Definition at line 1159 of file getpot.h.

Referenced by _DBE_expand(), direct_follow(), get(), next(), and operator()().

01160 {
01161   std::istringstream in_string(String);
01162   T retval;
01163   in_string >> retval;
01164   if (in_string.fail())
01165     retval = Default;
01166   return retval;
01167 }

template<>
bool GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const bool &   
) const [inline, private]
template<>
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  ,
const std::string &  String,
const std::string &   
) const [inline]

Definition at line 1232 of file getpot.h.

01233 {
01234     return String;
01235 }

std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const char *  Default 
) const [inline, private]

Definition at line 1239 of file getpot.h.

01240 {
01241     return String;
01242 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const T &  Default 
) const [inline, private]

Definition at line 1215 of file getpot.h.

References libMesh::Quality::name().

Referenced by get_value_no_default().

01216 {
01217   std::istringstream in_string(String);
01218   T retval;
01219   in_string >> retval;
01220   if (in_string.fail())
01221   {
01222     getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
01223     getpot_cerr <<"       value = "<<String<<" expected type = "<<typeid(T).name()<<std::endl;
01224     getpot_error();
01225   }
01226   return retval;
01227 }

std::string GETPOT_NAMESPACE::GetPot::_DBE_expand ( const std::string &  str  )  [inline, private]

Definition at line 2156 of file getpot.h.

References _convert_from_type(), _convert_to_type(), _DBE_get_expr_list(), _DBE_get_variable(), std::abs(), end, std::max(), std::min(), GETPOT_NAMESPACE::GetPot::variable::name, GETPOT_NAMESPACE::GetPot::variable::original, std::pow(), and size().

Referenced by _DBE_expand_string(), and _DBE_get_expr_list().

02157 {
02158     // ${: } pure text
02159     if( expr[0] == ':' )
02160         return expr.substr(1);
02161 
02162     // ${& expr expr ... } text concatination
02163     else if( expr[0] == '&' ) {
02164         const STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 1);
02165 
02166         STRING_VECTOR::const_iterator it = A.begin();
02167         std::string result = *it++;
02168         for(; it != A.end(); ++it) result += *it;
02169 
02170         return result;
02171     }
02172 
02173     // ${<-> expr expr expr} text replacement
02174     else if( expr.length() >= 3 && expr.substr(0, 3) == "<->" ) {
02175         STRING_VECTOR A = _DBE_get_expr_list(expr.substr(3), 3);
02176         size_t tmp = 0;
02177         const size_t L = A[1].length();
02178         while( (tmp = A[0].find(A[1])) != std::string::npos ) {
02179             A[0].replace(tmp, L, A[2]);
02180         }
02181         return A[0];
02182     }
02183 
02184     // ${=func [expr...] } function evaluation
02185     else if( expr.length() >= 2 &&
02186              expr.substr(0, 1) == "=" &&
02187              expr.substr(0, 2) != "==" ) {
02188         size_t funcnamestart = expr.find_first_not_of(" \t", 1);
02189         if (funcnamestart != std::string::npos) {
02190             size_t funcnameend = expr.find_first_of(" \t",funcnamestart);
02191             std::string funcname = expr.substr(funcnamestart,
02192                                                funcnameend-funcnamestart);
02193             if (funcname == "log") {
02194                 STRING_VECTOR A =
02195                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02196                 double arg = _convert_to_type(A[0], 0.0);
02197                 return _convert_from_type(std::log(arg));
02198             }
02199             else if (funcname == "log10") {
02200                 STRING_VECTOR A =
02201                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02202                 double arg = _convert_to_type(A[0], 0.0);
02203                 return _convert_from_type(std::log10(arg));
02204             }
02205             else if (funcname == "sin") {
02206                 STRING_VECTOR A =
02207                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02208                 double arg = _convert_to_type(A[0], 0.0);
02209                 return _convert_from_type(std::sin(arg));
02210             }
02211             else if (funcname == "cos") {
02212                 STRING_VECTOR A =
02213                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02214                 double arg = _convert_to_type(A[0], 0.0);
02215                 return _convert_from_type(std::cos(arg));
02216             }
02217             else if (funcname == "tan") {
02218                 STRING_VECTOR A =
02219                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02220                 double arg = _convert_to_type(A[0], 0.0);
02221                 return _convert_from_type(std::tan(arg));
02222             }
02223             else if (funcname == "asin") {
02224                 STRING_VECTOR A =
02225                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02226                 double arg = _convert_to_type(A[0], 0.0);
02227                 return _convert_from_type(std::asin(arg));
02228             }
02229             else if (funcname == "acos") {
02230                 STRING_VECTOR A =
02231                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02232                 double arg = _convert_to_type(A[0], 0.0);
02233                 return _convert_from_type(std::acos(arg));
02234             }
02235             else if (funcname == "atan") {
02236                 STRING_VECTOR A =
02237                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02238                 double arg = _convert_to_type(A[0], 0.0);
02239                 return _convert_from_type(std::atan(arg));
02240             }
02241             else if (funcname == "atan2") {
02242                 STRING_VECTOR A =
02243                   _DBE_get_expr_list(expr.substr(funcnameend), 2);
02244                 double arg1 = _convert_to_type(A[0], 0.0);
02245                 double arg2 = _convert_to_type(A[1], 0.0);
02246                 return _convert_from_type(std::atan2(arg1, arg2));
02247             }
02248             else if (funcname == "sinh") {
02249                 STRING_VECTOR A =
02250                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02251                 double arg = _convert_to_type(A[0], 0.0);
02252                 return _convert_from_type(std::sinh(arg));
02253             }
02254             else if (funcname == "cosh") {
02255                 STRING_VECTOR A =
02256                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02257                 double arg = _convert_to_type(A[0], 0.0);
02258                 return _convert_from_type(std::cosh(arg));
02259             }
02260             else if (funcname == "tanh") {
02261                 STRING_VECTOR A =
02262                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02263                 double arg = _convert_to_type(A[0], 0.0);
02264                 return _convert_from_type(std::tanh(arg));
02265             }
02266             else if (funcname == "sqrt") {
02267                 STRING_VECTOR A =
02268                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02269                 double arg = _convert_to_type(A[0], 0.0);
02270                 return _convert_from_type(std::sqrt(arg));
02271             }
02272             else if (funcname == "abs") {
02273                 STRING_VECTOR A =
02274                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02275                 double arg = _convert_to_type(A[0], 0.0);
02276                 return _convert_from_type(std::abs(arg));
02277             }
02278             else if (funcname == "max") {
02279                 STRING_VECTOR A =
02280                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02281                 STRING_VECTOR::const_iterator it = A.begin();
02282                 double result = _convert_to_type(*it++, 0.0);
02283                 for(; it != A.end(); ++it)
02284                     result = std::max(result, _convert_to_type(*it, 0.0));
02285                 return _convert_from_type(result);
02286             }
02287             else if (funcname == "min") {
02288                 STRING_VECTOR A =
02289                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02290                 STRING_VECTOR::const_iterator it = A.begin();
02291                 double result = _convert_to_type(*it++, 0.0);
02292                 for(; it != A.end(); ++it)
02293                     result = std::min(result, _convert_to_type(*it, 0.0));
02294                 return _convert_from_type(result);
02295             }
02296             else if (funcname == "ceil") {
02297                 STRING_VECTOR A =
02298                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02299                 double arg = _convert_to_type(A[0], 0.0);
02300                 return _convert_from_type(std::ceil(arg));
02301             }
02302             else if (funcname == "floor") {
02303                 STRING_VECTOR A =
02304                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02305                 double arg = _convert_to_type(A[0], 0.0);
02306                 return _convert_from_type(std::floor(arg));
02307             }
02308             else if (funcname == "fmod") {
02309                 STRING_VECTOR A =
02310                   _DBE_get_expr_list(expr.substr(funcnameend), 2);
02311                 double arg1 = _convert_to_type(A[0], 0.0);
02312                 double arg2 = _convert_to_type(A[1], 0.0);
02313                 return _convert_from_type(std::fmod(arg1, arg2));
02314             }
02315             else if (funcname == "srand") {
02316                 STRING_VECTOR A =
02317                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02318                 unsigned int arg = _convert_to_type(A[0], 0u);
02319                 std::srand(arg);
02320                 return A[0];
02321             }
02322             // ${=rand range} with default range==RAND_MAX
02323             else if (funcname == "rand") {
02324                 if (funcnameend >= expr.length() ||
02325                     expr.find_first_not_of(" \t", funcnameend) == std::string::npos)
02326                   return _convert_from_type(std::rand());
02327 
02328                 STRING_VECTOR A =
02329                   _DBE_get_expr_list(expr.substr(funcnameend), 1);
02330                 unsigned int range = _convert_to_type(A[0],0u);
02331                 if (!range)
02332                   return _convert_from_type(0);
02333                 const unsigned int x = (RAND_MAX + 1u) / range;
02334                 const unsigned int y = x * range;
02335                 unsigned int returnval;
02336                 do {
02337                         returnval = rand();
02338                 } while(returnval >= y);
02339                 return _convert_from_type(returnval / x);
02340             }
02341             else if (funcname == "time") {
02342                 return _convert_from_type(std::time(NULL));
02343             }
02344         }
02345     }
02346 
02347     // ${+ ...}, ${- ...}, ${* ...}, ${/ ...} expressions
02348     else if( expr[0] == '+' ) {
02349         STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
02350         STRING_VECTOR::const_iterator it = A.begin();
02351         double result = _convert_to_type(*it++, 0.0);
02352         for(; it != A.end(); ++it)
02353             result += _convert_to_type(*it, 0.0);
02354 
02355         return _convert_from_type(result);
02356     }
02357     else if( expr[0] == '-' ) {
02358         STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
02359         STRING_VECTOR::const_iterator it = A.begin();
02360         double result = _convert_to_type(*it++, 0.0);
02361         for(; it != A.end(); ++it)
02362             result -= _convert_to_type(*it, 0.0);
02363 
02364         return _convert_from_type(result);
02365     }
02366     else if( expr[0] == '*' ) {
02367         STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
02368         STRING_VECTOR::const_iterator it = A.begin();
02369         double result = _convert_to_type(*it++, 0.0);
02370         for(; it != A.end(); ++it)
02371             result *= _convert_to_type(*it, 0.0);
02372 
02373         return _convert_from_type(result);
02374     }
02375     else if( expr[0] == '/' ) {
02376         STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
02377         STRING_VECTOR::const_iterator it = A.begin();
02378         double result = _convert_to_type(*it++, 0.0);
02379         if( result == 0 ) {
02380             return "0.0";
02381         }
02382         for(; it != A.end(); ++it) {
02383             const double Q = _convert_to_type(*it, 0.0);
02384             result /= Q;
02385         }
02386         return _convert_from_type(result);
02387     }
02388 
02389     // ${^ ... } power expressions
02390     else if( expr[0] == '^' ) {
02391         STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
02392         STRING_VECTOR::const_iterator it = A.begin();
02393         double result = _convert_to_type(*it++, 0.0);
02394         for(; it != A.end(); ++it)
02395             result = pow(result, _convert_to_type(*it, 0.0));
02396         return _convert_from_type(result);
02397     }
02398 
02399     // ${==  } ${<=  } ${>= } comparisons (return the number of the first 'match'
02400     else if( expr.length() >= 2 &&
02401              ( expr.substr(0,2) == "==" || expr.substr(0,2) == ">=" ||
02402                expr.substr(0,2) == "<=" || expr[0] == '>'           || expr[0] == '<')) {
02403         // differentiate between two and one sign operators
02404         unsigned op = 0;
02405         enum { EQ, GEQ, LEQ, GT, LT };
02406         if      ( expr.substr(0, 2) == "==" ) op = EQ;
02407         else if ( expr.substr(0, 2) == ">=" ) op = GEQ;
02408         else if ( expr.substr(0, 2) == "<=" ) op = LEQ;
02409         else if ( expr[0] == '>' )            op = GT;
02410         else    /*                     "<" */ op = LT;
02411 
02412         STRING_VECTOR a;
02413         if ( op == GT || op == LT ) a = _DBE_get_expr_list(expr.substr(1), 2);
02414         else                        a = _DBE_get_expr_list(expr.substr(2), 2);
02415 
02416         std::string   x_orig = a[0];
02417         double   x = _convert_to_type(x_orig, 1e37);
02418         unsigned i = 1;
02419 
02420         STRING_VECTOR::const_iterator y_orig = a.begin();
02421         for(y_orig++; y_orig != a.end(); ++y_orig) {
02422             double y = _convert_to_type(*y_orig, 1e37);
02423 
02424             // set the strings as reference if one wasn't a number
02425             if ( x == 1e37 || y == 1e37 ) {
02426                 // it's a string comparison
02427                 if( (op == EQ  && x_orig == *y_orig) || (op == GEQ && x_orig >= *y_orig) ||
02428                     (op == LEQ && x_orig <= *y_orig) || (op == GT  && x_orig >  *y_orig) ||
02429                     (op == LT  && x_orig <  *y_orig) )
02430                     return _convert_from_type(i);
02431             }
02432             else {
02433                 // it's a number comparison
02434                 if( (op == EQ  && x == y) || (op == GEQ && x >= y) ||
02435                     (op == LEQ && x <= y) || (op == GT  && x >  y) ||
02436                     (op == LT  && x <  y) )
02437                     return _convert_from_type(i);
02438             }
02439             i++;
02440         }
02441 
02442         // nothing fulfills the condition => return 0
02443         return "0";
02444     }
02445     // ${?? expr expr} select
02446     else if( expr.length() >= 2 && expr.substr(0, 2) == "??" ) {
02447         STRING_VECTOR a = _DBE_get_expr_list(expr.substr(2), 2);
02448         double x = _convert_to_type(a[0], 1e37);
02449         // last element is always the default argument
02450         if( x == 1e37 || x < 0 || x >= a.size() - 1 ) return a[a.size()-1];
02451 
02452         // round x to closest integer
02453         return a[int(x+0.5)];
02454     }
02455     // ${? expr expr expr} if then else conditions
02456     else if( expr[0] == '?' ) {
02457         STRING_VECTOR a = _DBE_get_expr_list(expr.substr(1), 2);
02458         if( _convert_to_type(a[0], 0.0) == 1.0 ) return a[1];
02459         else if( a.size() > 2 ) return a[2];
02460     }
02461     // ${! expr} maxro expansion
02462     else if( expr[0] == '!' ) {
02463         const GetPot::variable* Var = _DBE_get_variable(expr.substr(1));
02464         // error
02465         if( Var->name == "" ) return std::string(Var->original);
02466 
02467         const STRING_VECTOR A = _DBE_get_expr_list(Var->original, 2);
02468         return A[0];
02469     }
02470     // ${@: } - string subscription
02471     else if( expr.length() >= 2 && expr.substr(0,2) == "@:" ) {
02472         const STRING_VECTOR A = _DBE_get_expr_list(expr.substr(2), 2);
02473         double x = _convert_to_type(A[1], 1e37);
02474 
02475         // last element is always the default argument
02476         if( x == 1e37 || x < 0 || x >= A[0].size() - 1)
02477             return "<<1st index out of range>>";
02478 
02479         if( A.size() > 2 ) {
02480             double y = _convert_to_type(A[2], 1e37);
02481             if ( y != 1e37 && y > 0 && y <= A[0].size() - 1 && y > x )
02482                 return A[0].substr(int(x+0.5), int(y+1.5) - int(x+0.5));
02483             else if( y == -1 )
02484                 return A[0].substr(int(x+0.5));
02485             return "<<2nd index out of range>>";
02486         }
02487         else {
02488             char* tmp = new char[2];
02489             tmp[0] = A[0][int(x+0.5)]; tmp[1] = '\0';
02490             std::string result(tmp);
02491             delete [] tmp;
02492             return result;
02493         }
02494     }
02495     // ${@ } - vector subscription
02496     else if( expr[0] == '@' ) {
02497         STRING_VECTOR          A   = _DBE_get_expr_list(expr.substr(1), 2);
02498         const GetPot::variable* Var = _DBE_get_variable(A[0]);
02499         // error
02500         if( Var->name == "" ) {
02501             // make a copy of the string if an error occured
02502             // (since the error variable is a static variable inside get_variable())
02503             return std::string(Var->original);
02504         }
02505 
02506         double x = _convert_to_type(A[1], 1e37);
02507 
02508         // last element is always the default argument
02509         if (x == 1e37 || x < 0 || x >= Var->value.size() )
02510             return "<<1st index out of range>>";
02511 
02512         if ( A.size() > 2) {
02513             double y = _convert_to_type(A[2], 1e37);
02514             int    begin = int(x+0.5);
02515             int    end = 0;
02516             if ( y != 1e37 && y > 0 && y <= Var->value.size() && y > x)
02517                 end = int(y+1.5);
02518             else if( y == -1 )
02519                 end = int(Var->value.size());
02520             else
02521                 return "<<2nd index out of range>>";
02522 
02523             std::string result = *(Var->get_element(begin));
02524             int i = begin+1;
02525             for(; i < end; i++)
02526                 result += std::string(" ") + *(Var->get_element(i));
02527             return result;
02528         }
02529         else
02530             return *(Var->get_element(int(x+0.5)));
02531     }
02532 
02533     const STRING_VECTOR    A = _DBE_get_expr_list(expr, 1);
02534     const GetPot::variable* B = _DBE_get_variable(A[0]);
02535 
02536     // make a copy of the string if an error occured
02537     // (since the error variable is a static variable inside get_variable())
02538     if( B->name == "" ) return std::string(B->original);
02539     // (psuggs@pobox.com mentioned to me the warning MSVC++6.0 produces
02540     //  with:  else return B->original (thanks))
02541     return B->original;
02542 }

std::string GETPOT_NAMESPACE::GetPot::_DBE_expand_string ( const std::string &  str  )  [inline, private]

Definition at line 2031 of file getpot.h.

References _DBE_expand().

Referenced by _parse_argument_vector().

02032 {
02033     // Parses for closing operators '${ }' and expands them letting
02034     // white spaces and other letters as they are.
02035     std::string   new_string = "";
02036     unsigned open_brackets = 0;
02037     unsigned first = 0;
02038     unsigned i = 0;
02039     for(;  i<str.size(); i++) {
02040         if( i < str.size() - 2 && str.substr(i, 2) == "${" ) {
02041             if( open_brackets == 0 ) first = i+2;
02042             open_brackets++;
02043         }
02044         else if( str[i] == '}' && open_brackets > 0) {
02045             open_brackets -= 1;
02046             if( open_brackets == 0 ) {
02047                 const std::string Replacement = _DBE_expand(str.substr(first, i - first));
02048                 new_string += Replacement;
02049             }
02050         }
02051         else if( open_brackets == 0 )
02052             new_string += str[i];
02053     }
02054     return new_string;
02055 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::_DBE_get_expr_list ( const std::string &  str,
const unsigned  ExpectedNumber 
) [inline, private]

Definition at line 2058 of file getpot.h.

References _DBE_expand().

Referenced by _DBE_expand().

02061 {
02062     std::string str = str_;
02063     // Separates expressions by non-bracketed whitespaces, expands them
02064     // and puts them into a list.
02065 
02066     unsigned i=0;
02067     // (1) eat initial whitespaces
02068     for(; i < str.size(); i++)
02069         if( ! isspace(str[i]) ) break;
02070 
02071     STRING_VECTOR   expr_list;
02072     unsigned         open_brackets = 0;
02073     std::vector<unsigned> start_idx;
02074     unsigned         start_new_string = i;
02075     unsigned         l = (unsigned)(str.size());
02076 
02077     // (2) search for ${ } expressions ...
02078     while( i < l ) {
02079         const char letter = str[i];
02080         // whitespace -> end of expression
02081         if( isspace(letter) && open_brackets == 0) {
02082             expr_list.push_back(str.substr(start_new_string, i - start_new_string));
02083             bool no_breakout_f = true;
02084             for(i++; i < l ; i++) {
02085                 if( ! isspace(str[i]) )
02086                 { no_breakout_f = false; start_new_string = i; break; }
02087             }
02088             if( no_breakout_f ) {
02089                 // end of expression list
02090                 if( expr_list.size() < ExpectedNumber ) {
02091                     const std::string   pre_tmp("<< ${ }: missing arguments>>");
02092                     STRING_VECTOR tmp(ExpectedNumber - expr_list.size(), pre_tmp);
02093                     expr_list.insert(expr_list.end(), tmp.begin(), tmp.end());
02094                 }
02095                 return expr_list;
02096             }
02097         }
02098 
02099         // dollar-bracket expression
02100         if( str.length() >= i+2 && str.substr(i, 2) == "${" ) {
02101             open_brackets++;
02102             start_idx.push_back(i+2);
02103         }
02104         else if( letter == '}' && open_brackets > 0) {
02105             int start = start_idx[start_idx.size()-1];
02106             start_idx.pop_back();
02107             const std::string Replacement = _DBE_expand(str.substr(start, i-start));
02108             if( start - 3 < (int)0)
02109                 str = Replacement + str.substr(i+1);
02110             else
02111                 str = str.substr(0, start-2) + Replacement + str.substr(i+1);
02112             l = (int)(str.size());
02113             i = start + (int)(Replacement.size()) - 3;
02114             open_brackets--;
02115         }
02116         i++;
02117     }
02118 
02119     // end of expression list
02120     expr_list.push_back(str.substr(start_new_string, i-start_new_string));
02121 
02122     if( expr_list.size() < ExpectedNumber ) {
02123         const std::string   pre_tmp("<< ${ }: missing arguments>>");
02124         STRING_VECTOR tmp(ExpectedNumber - expr_list.size(), pre_tmp);
02125         expr_list.insert(expr_list.end(), tmp.begin(), tmp.end());
02126     }
02127 
02128     return expr_list;
02129 }

const GetPot::variable * GETPOT_NAMESPACE::GetPot::_DBE_get_variable ( const std::string &  str  )  [inline, private]

Definition at line 2132 of file getpot.h.

References _request_variable(), GETPOT_NAMESPACE::GetPot::variable::original, prefix, and section.

Referenced by _DBE_expand().

02133 {
02134     static GetPot::variable ev;
02135     std::string secure_Prefix = prefix;
02136 
02137     prefix = section;
02138     // (1) first search in currently active section
02139     const GetPot::variable* var = _request_variable(VarName.c_str());
02140     if( var != 0 ) { prefix = secure_Prefix; return var; }
02141 
02142     // (2) search in root name space
02143     prefix = "";
02144     var = _request_variable(VarName.c_str());
02145     if( var != 0 ) { prefix = secure_Prefix; return var; }
02146 
02147     prefix = secure_Prefix;
02148 
02149     // error occured => variable name == ""
02150     ev.original = "<<${ } variable '";
02151     ev.original += VarName + "' undefined>>";
02152     return &ev;
02153 }

const GetPot::variable * GETPOT_NAMESPACE::GetPot::_find_variable ( const char *  VarName  )  const [inline, private]

Definition at line 1926 of file getpot.h.

References prefix, and variables.

Referenced by _request_variable(), and _set_variable().

01927 {
01928     const std::string Name = prefix + VarName;
01929 
01930     std::vector<variable>::const_iterator it = variables.begin();
01931     for(; it != variables.end(); ++it) {
01932         if( (*it).name == Name ) return &(*it);
01933     }
01934     return 0;
01935 }

const std::string GETPOT_NAMESPACE::GetPot::_get_next_token ( std::istream &  istr  )  [inline, private]

Definition at line 1004 of file getpot.h.

References _get_string(), _get_until_closing_bracket(), and _get_until_closing_square_bracket().

Referenced by _read_in_stream().

01007 {
01008     std::string token;
01009     int    tmp = 0;
01010     int    last_letter = 0;
01011     while(1+1 == 2) {
01012         last_letter = tmp; tmp = istr.get();
01013         if( tmp == '=' )
01014         {
01015           // Always break at '='.
01016           // This separates '=' at the beginning of a word into its own word.
01017           token += getpot_cast_int<char>(tmp);
01018           return token;
01019         }
01020         else if( tmp == EOF
01021             || ((tmp == ' ' || tmp == '\t' || tmp == '\n') && last_letter != '\\') ) {
01022             return token;
01023         }
01024         else if( tmp == '\'' && last_letter != '\\' ) {
01025             // QUOTES: un-backslashed quotes => it's a string
01026             token += _get_string(istr);
01027             continue;
01028         }
01029         else if( tmp == '{' && last_letter == '$') {
01030             token += '{' + _get_until_closing_bracket(istr);
01031             continue;
01032         }
01033         else if( tmp == '[') {
01034             token += '[' + _get_until_closing_square_bracket(istr);
01035             continue;
01036         }
01037         else if( tmp == '$' && last_letter == '\\') {
01038             token += getpot_cast_int<char>(tmp); tmp = 0;  //  so that last_letter will become = 0, not '$';
01039             continue;
01040         }
01041         else if( tmp == '\\' && last_letter != '\\')
01042             continue;              // don't append un-backslashed backslashes
01043         token += getpot_cast_int<char>(tmp);
01044     }
01045 }

const std::string GETPOT_NAMESPACE::GetPot::_get_remaining_string ( const std::string &  String,
const std::string &  Start 
) const [inline, private]

Definition at line 1303 of file getpot.h.

Referenced by argument_contains(), get_variable_names(), next(), options_contain(), unidentified_arguments(), unidentified_flags(), unidentified_nominuses(), unidentified_options(), unidentified_sections(), and unidentified_variables().

01306 {
01307     if( Start == "" ) return String;
01308     // note: java.lang.String: substring(a,b) = from a to b-1
01309     //        C++ string:      substr(a,b)    = from a to a + b
01310     if( String.find(Start) == 0 ) return String.substr(Start.length());
01311     else                          return "";
01312 }

static STRING_VECTOR GETPOT_NAMESPACE::GetPot::_get_section_tree ( const std::string &  FullPath  )  [inline, static, private]

Definition at line 445 of file getpot.h.

Referenced by _record_argument_request(), and _record_variable_request().

00445                                                                       {
00446         // -- cuts a variable name into a tree of sub-sections. this is requested for recording
00447         //    requested sections when dealing with 'ufo' detection.
00448         STRING_VECTOR   result;
00449         for (std::size_t pos = 0; pos != FullPath.size(); ++pos) {
00450             if( FullPath[pos] == '/' ) {
00451                 result.push_back(FullPath.substr(0,pos));
00452             }
00453         }
00454 
00455         return result;
00456     }

const std::string GETPOT_NAMESPACE::GetPot::_get_string ( std::istream &  istr  )  [inline, private]

Definition at line 1048 of file getpot.h.

Referenced by _get_next_token().

01050 {
01051     std::string str;
01052     int    tmp = 0;
01053     int    last_letter = 0;
01054     while(1 + 1 == 2) {
01055         last_letter = tmp; tmp = istr.get();
01056         if( tmp == EOF)  return str;
01057         // un-backslashed quotes => it's the end of the string
01058         else if( tmp == '\'' && last_letter != '\\')  return str;
01059         else if( tmp == '\\' && last_letter != '\\')  continue; // don't append
01060 
01061         str += getpot_cast_int<char>(tmp);
01062     }
01063 }

const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_bracket ( std::istream &  istr  )  [inline, private]

Definition at line 1066 of file getpot.h.

Referenced by _get_next_token().

01068 {
01069     std::string str = "";
01070     int    tmp = 0;
01071     int    last_letter = 0;
01072     int    brackets = 1;
01073     while(1 + 1 == 2) {
01074         last_letter = tmp; tmp = istr.get();
01075         if( tmp == EOF) return str;
01076         else if( tmp == '{' && last_letter == '$') brackets += 1;
01077         else if( tmp == '}') {
01078             brackets -= 1;
01079             // un-backslashed brackets => it's the end of the string
01080             if( brackets == 0) return str + '}';
01081             else if( tmp == '\\' && last_letter != '\\')
01082                 continue;  // do not append an unbackslashed backslash
01083         }
01084         str += getpot_cast_int<char>(tmp);
01085     }
01086 }

const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_square_bracket ( std::istream &  istr  )  [inline, private]

Definition at line 1090 of file getpot.h.

Referenced by _get_next_token().

01092 {
01093     std::string str = "";
01094     int    tmp = 0;
01095     int    brackets = 1;
01096     while(1 + 1 == 2) {
01097         tmp = istr.get();
01098         if( tmp == EOF) return str;
01099         else if( tmp == '[') {
01100             brackets += 1;
01101         }
01102         else if( tmp == ']') {
01103             brackets -= 1;
01104             if( brackets == 0) return str + ']';
01105         }
01106         str += getpot_cast_int<char>(tmp);
01107     }
01108 }

const char * GETPOT_NAMESPACE::GetPot::_internal_managed_copy ( const std::string &  Arg  )  const [inline, private]

Definition at line 1277 of file getpot.h.

References _internal_string_container.

Referenced by direct_follow(), follow(), get_value_no_default(), next(), and operator()().

01278 {
01279     const char* arg = Arg.c_str();
01280 
01281     // Get a lock before touching anything mutable
01282     SCOPED_MUTEX;
01283 
01284     // See if there's already an identical string saved
01285     std::set<const char*,ltstr>::const_iterator it =
01286         _internal_string_container.find(arg);
01287 
01288     // If so, return it
01289     if (it != _internal_string_container.end())
01290         return *it;
01291 
01292     // Otherwise, create a new one
01293     char* newcopy = new char[strlen(arg)+1];
01294     strncpy(newcopy, arg, strlen(arg)+1);
01295     _internal_string_container.insert(newcopy);
01296     return newcopy;
01297 }

const char * GETPOT_NAMESPACE::GetPot::_match_starting_string ( const char *  StartString  )  [inline, private]

Definition at line 1538 of file getpot.h.

References argv, cursor, search_failed_f, and search_loop_f.

Referenced by direct_follow().

01542 {
01543     const unsigned N =
01544       getpot_cast_int<unsigned>(strlen(StartString));
01545     unsigned       OldCursor = cursor;
01546 
01547     if( OldCursor >= argv.size() )
01548       OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
01549     search_failed_f = true;
01550 
01551     // (*) first loop from cursor position until end
01552     unsigned c = cursor;
01553     for(; c < argv.size(); c++) {
01554         if( strncmp(StartString, argv[c].c_str(), N) == 0)
01555         { cursor = c; search_failed_f = false; return &(argv[c].c_str()[N]); }
01556     }
01557 
01558     if( ! search_loop_f ) return NULL;
01559 
01560     // (*) second loop from 0 to old cursor position
01561     for(c = 1; c < OldCursor; c++) {
01562         if( strncmp(StartString, argv[c].c_str(), N) == 0)
01563         { cursor = c; search_failed_f = false; return &(argv[c].c_str()[N]); }
01564     }
01565     return 0;
01566 }

void GETPOT_NAMESPACE::GetPot::_parse_argument_vector ( const STRING_VECTOR ARGV  )  [inline, private]

Definition at line 789 of file getpot.h.

References _comment_end, _comment_start, _DBE_expand_string(), _field_separator, _process_section_label(), _requested_arguments, _set_variable(), argv, idx_nominus, parse_input_file(), request_recording_f, section, and section_list.

Referenced by parse_command_line(), and parse_input_file().

00790 {
00791     if( ARGV.empty() ) return;
00792 
00793     // build internal databases:
00794     //   1) array with no-minus arguments (usually used as filenames)
00795     //   2) variable assignments:
00796     //             'variable name' '=' number | string
00797     STRING_VECTOR                 section_stack;
00798     STRING_VECTOR::const_iterator it = ARGV.begin();
00799 
00800 
00801     section = "";
00802 
00803     // -- do not parse the first argument, so that this parsing source
00804     // name is not interpreted a s a nominus or so.  If we already
00805     // have parsed arguments, don't bother adding another parsing
00806     // source name
00807     if (argv.empty())
00808       argv.push_back(*it);
00809     ++it;
00810 
00811     // -- loop over remaining arguments
00812     for(; it != ARGV.end(); ++it) {
00813         std::string arg = *it;
00814 
00815         if( arg.length() == 0 ) continue;
00816 
00817         // -- [section] labels and [include file] directives
00818         if( arg.length() > 1 && arg[0] == '[' && arg[arg.length()-1] == ']' ) {
00819 
00820             // Is this an include file directive?
00821             std::size_t include_pos = arg.find("include ", 1);
00822             if (include_pos != std::string::npos) {
00823 
00824                 const std::string includefile =
00825                   _DBE_expand_string(arg.substr(9, arg.length()-9-include_pos));
00826 
00827                 this->parse_input_file
00828                   (includefile, _comment_start, _comment_end, _field_separator);
00829             } else {
00830 
00831                 // (*) sections are considered 'requested arguments'
00832                 if( request_recording_f ) {
00833                     // Get a lock before touching anything mutable
00834                     SCOPED_MUTEX;
00835 
00836                     _requested_arguments.insert(arg);
00837                 }
00838 
00839                 const std::string Name = _DBE_expand_string(arg.substr(1, arg.length()-2));
00840                 section = _process_section_label(Name, section_stack);
00841                 // new section --> append to list of sections
00842                 if( find(section_list.begin(), section_list.end(), section) == section_list.end() )
00843                     if( section.length() != 0 ) section_list.push_back(section);
00844                 argv.push_back(arg);
00845             }
00846         }
00847         else {
00848             arg = section + _DBE_expand_string(arg);
00849             argv.push_back(arg);
00850         }
00851 
00852         // -- separate array for nominus arguments
00853         if( arg[0] != '-' )
00854             idx_nominus.push_back(getpot_cast_int<unsigned>(argv.size()-1));
00855 
00856         // -- variables: does arg contain a '=' operator ?
00857         const std::size_t equals_pos = arg.find_first_of('=');
00858         if( equals_pos != std::string::npos ) {
00859             // (*) record for later ufo detection
00860             //     arguments carriying variables are always treated as 'requested' arguments.
00861             //     unrequested variables have to be detected with the ufo-variable
00862             //     detection routine.
00863             if( request_recording_f ) {
00864                 // Get a lock before touching anything mutable
00865                 SCOPED_MUTEX;
00866 
00867                 _requested_arguments.insert(arg);
00868             }
00869 
00870             // => arg (from start to '=') = Name of variable
00871             //        (from '=' to end)   = value of variable
00872             _set_variable(arg.substr(0,equals_pos),
00873                           arg.substr(equals_pos+1), false);
00874         }
00875     }
00876 }

std::string GETPOT_NAMESPACE::GetPot::_process_section_label ( const std::string &  Section,
STRING_VECTOR section_stack 
) [inline, private]

Definition at line 1111 of file getpot.h.

Referenced by _parse_argument_vector().

01113 {
01114     std::string sname = Section;
01115     //  1) subsection of actual section ('./' prefix)
01116     if( sname.length() >= 2 && sname.substr(0, 2) == "./" ) {
01117         sname = sname.substr(2);
01118     }
01119     //  2) subsection of parent section ('../' prefix)
01120     else if( sname.length() >= 3 && sname.substr(0, 3) == "../" ) {
01121         do {
01122             if( section_stack.end() != section_stack.begin() )
01123                 section_stack.pop_back();
01124             sname = sname.substr(3);
01125         } while( sname.substr(0, 3) == "../" );
01126     }
01127     // 3) subsection of the root-section
01128     else {
01129         section_stack.erase(section_stack.begin(), section_stack.end());
01130         // [] => back to root section
01131     }
01132 
01133     if( sname != "" ) {
01134         // parse section name for 'slashes'
01135         unsigned i=0;
01136         while( i < sname.length() ) {
01137             if( sname[i] == '/' ) {
01138                 section_stack.push_back(sname.substr(0,i));
01139                 if( i+1 < sname.length()-1 )
01140                     sname = sname.substr(i+1);
01141                 i = 0;
01142             }
01143             else
01144                 i++;
01145         }
01146         section_stack.push_back(sname);
01147     }
01148     std::string section_label = "";
01149     if( !section_stack.empty() ) {
01150         victorate(std::string, section_stack, it)
01151             section_label += *it + "/";
01152     }
01153     return section_label;
01154 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::_read_in_file ( const std::string &  FileName  )  [inline, private]

Definition at line 880 of file getpot.h.

References _read_in_stream().

Referenced by parse_input_file().

00881 {
00882     std::ifstream  i(FileName.c_str());
00883     if( ! i ) return STRING_VECTOR();
00884     // argv[0] == the filename of the file that was read in
00885     return _read_in_stream(i);
00886 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::_read_in_stream ( std::istream &  istr  )  [inline, private]

Definition at line 889 of file getpot.h.

References _comment_start, _get_next_token(), and _skip_whitespace().

Referenced by _read_in_file().

00890 {
00891     STRING_VECTOR  brute_tokens;
00892     while(istr) {
00893         _skip_whitespace(istr);
00894         const std::string Token = _get_next_token(istr);
00895         // Allow 'keyword =' to parse with an empty string as value.
00896         // Only break at EOF.
00897 //      if( Token.length() == 0 || Token[0] == EOF) break;
00898         if( Token[0] == EOF) break;
00899         brute_tokens.push_back(Token);
00900     }
00901 
00902     // -- reduce expressions of token1'='token2 to a single
00903     //    string 'token1=token2'
00904     // -- copy everything into 'argv'
00905     // -- arguments preceded by something like '[' name ']' (section)
00906     //    produce a second copy of each argument with a prefix '[name]argument'
00907     unsigned i1 = 0;
00908     unsigned i2 = 1;
00909     unsigned i3 = 2;
00910 
00911     STRING_VECTOR  arglist;
00912     while( i1 < brute_tokens.size() ) {
00913         // 1) concatenate 'abcdef' '=' 'efgasdef' to 'abcdef=efgasdef'
00914         // note: java.lang.String: substring(a,b) = from a to b-1
00915         //        C++ string:      substr(a,b)    = from a to a + b
00916         std::string result;
00917         if( i2 < brute_tokens.size() && brute_tokens[i2] == "=" ) {
00918             if( i3 >= brute_tokens.size() )
00919               result = brute_tokens[i1] + brute_tokens[i2];
00920             else
00921               result = brute_tokens[i1] + brute_tokens[i2] + brute_tokens[i3];
00922             i1 = i3+1; i2 = i3+2; i3 = i3+3;
00923         }
00924         else if ( i2 < brute_tokens.size() &&
00925                   brute_tokens[i2].length() > 0 &&
00926                   brute_tokens[i2][0] == '=' ) {
00927           // This case should not be hit if '=' at the beginning of a word
00928           //   is always separated into its own word
00929           result = brute_tokens[i1] + brute_tokens[i2];
00930           i1 = i3; i2 = i3+1; i3 = i3+2;
00931         }
00932         else if ( i2 < brute_tokens.size() && brute_tokens[i1][brute_tokens[i1].size()-1] == '=' ) {
00933           result = brute_tokens[i1] + brute_tokens[i2];
00934           i1 = i3; i2 = i3+1; i3 = i3+2;
00935         }
00936         else {
00937           result = brute_tokens[i1];
00938           i1=i2; i2=i3; i3++;
00939         }
00940         // Now strip out any comment
00941         size_t comment_start_loc = result.find(_comment_start, 0);
00942         if (comment_start_loc != std::string::npos)
00943         {
00944           result = result.substr(0, comment_start_loc);
00945         }
00946         arglist.push_back(result);
00947     }
00948     return arglist;
00949 }

void GETPOT_NAMESPACE::GetPot::_record_argument_request ( const std::string &  Arg  )  const [inline, private]

Definition at line 1811 of file getpot.h.

References _get_section_tree(), _requested_arguments, _requested_sections, request_recording_f, and section.

Referenced by argument_contains(), direct_follow(), next(), next_nominus(), nominus_vector(), and search().

01812 {
01813     if( ! request_recording_f ) return;
01814 
01815     // Get a lock before touching anything mutable
01816     SCOPED_MUTEX;
01817 
01818     // (*) record requested variable for later ufo detection
01819     _requested_arguments.insert(Name);
01820 
01821     // (*) record considered section for ufo detection
01822     STRING_VECTOR      STree = _get_section_tree(Name);
01823     victorate(std::string, STree, it)
01824         if( _requested_sections.find(*it) == _requested_sections.end() )
01825             if( section.length() != 0 ) _requested_sections.insert(*it);
01826 }

void GETPOT_NAMESPACE::GetPot::_record_variable_request ( const std::string &  Arg  )  const [inline, private]

Definition at line 1829 of file getpot.h.

References _get_section_tree(), _requested_sections, _requested_variables, request_recording_f, and section.

Referenced by _request_variable().

01830 {
01831     if( ! request_recording_f ) return;
01832 
01833     // Get a lock before touching anything mutable
01834     SCOPED_MUTEX;
01835 
01836     // (*) record requested variable for later ufo detection
01837     _requested_variables.insert(Name);
01838 
01839     // (*) record considered section for ufo detection
01840     STRING_VECTOR      STree = _get_section_tree(Name);
01841     victorate(std::string, STree, it)
01842         if( _requested_sections.find(*it) == _requested_sections.end() )
01843             if( section.length() != 0 ) _requested_sections.insert(*it);
01844 }

const GetPot::variable * GETPOT_NAMESPACE::GetPot::_request_variable ( const char *  VarName  )  const [inline, private]

Definition at line 1938 of file getpot.h.

References _find_variable(), and _record_variable_request().

Referenced by _DBE_get_variable(), _set_variable(), get_value_no_default(), have_variable(), operator()(), and vector_variable_size().

01939 {
01940     // (*) record requested variable for later ufo detection
01941     this->_record_variable_request(VarName);
01942 
01943     return this->_find_variable(VarName);
01944 }

bool GETPOT_NAMESPACE::GetPot::_search_string_vector ( const STRING_VECTOR Vec,
const std::string &  Str 
) const [inline, private]

Definition at line 2550 of file getpot.h.

02551 {
02552     victorate(std::string, VecStr, itk) {
02553         if( *itk == Str ) return true;
02554     }
02555     return false;
02556 }

void GETPOT_NAMESPACE::GetPot::_set_variable ( const std::string &  VarName,
const std::string &  Value,
const bool  Requested 
) [inline, private]

Definition at line 1849 of file getpot.h.

References _field_separator, _find_variable(), _request_variable(), overridden_vars, and variables.

Referenced by _parse_argument_vector(), and set().

01851 {
01852     const GetPot::variable* Var = Requested ?
01853                     _request_variable(VarName.c_str()) :
01854                     _find_variable(VarName.c_str());
01855     if( Var == 0 ) variables.push_back(variable(VarName.c_str(),
01856                                                 Value.c_str(), _field_separator.c_str()));
01857     else {
01858       overridden_vars.insert(VarName.c_str());
01859       (const_cast<GetPot::variable*>(Var))->take(Value.c_str(), _field_separator.c_str());
01860     }
01861 }

void GETPOT_NAMESPACE::GetPot::_skip_whitespace ( std::istream &  istr  )  [inline, private]

Definition at line 952 of file getpot.h.

References _comment_end, and _comment_start.

Referenced by _read_in_stream().

00954 {
00955     int tmp = istr.get();
00956     do {
00957         // -- search a non whitespace
00958         while( isspace(tmp) ) {
00959             tmp = istr.get();
00960             if( ! istr ) return;
00961         }
00962 
00963         // -- look if characters match the comment starter string
00964         const std::istream::pos_type  Pos = istr.tellg();
00965         unsigned    i=0;
00966         for(; i<_comment_start.length() ; i++) {
00967             if( tmp != _comment_start[i] ) {
00968                 istr.seekg(Pos);
00969                 // -- one step more backwards, since 'tmp' already at non-whitespace
00970                 istr.unget();
00971                 return;
00972             }
00973 
00974 // RHS: Why is this here?  It breaks on empty comments
00975 //          tmp = istr.get();
00976 //          if( ! istr ) { istr.unget(); return; }
00977         }
00978         // 'tmp' contains last character of _comment_starter
00979 
00980         // -- comment starter found -> search for comment ender
00981         unsigned match_no=0;
00982         while(1+1 == 2) {
00983             tmp = istr.get();
00984             if( ! istr ) { istr.unget(); return; }
00985 
00986             if( tmp == _comment_end[match_no] ) {
00987                 match_no++;
00988                 if( match_no == _comment_end.length() ) {
00989                     istr.unget();
00990                     break; // shuffle more whitespace, end of comment found
00991                 }
00992             }
00993             else
00994                 match_no = 0;
00995         }
00996 
00997         tmp = istr.get();
00998 
00999     } while( istr );
01000     istr.unget();
01001 }

void GETPOT_NAMESPACE::GetPot::absorb ( const GetPot Other  )  [inline]

Definition at line 751 of file getpot.h.

References _requested_arguments, _requested_sections, _requested_variables, argv, request_recording_f, and variables.

00752 {
00753     if (&Other == this) return;
00754 
00755     // variables that are not influenced by absorption:
00756     //               _comment_start
00757     //               _comment_end
00758     //               cursor
00759     //               nominus_cursor
00760     //               search_failed
00761     //               idx_nominus
00762     //               search_loop_f
00763     argv      = Other.argv;
00764     variables = Other.variables;
00765 
00766     if( request_recording_f ) {
00767         // Get a lock before touching anything mutable
00768         SCOPED_MUTEX;
00769 
00770         _requested_arguments.insert(Other._requested_arguments.begin(), Other._requested_arguments.end());
00771         _requested_variables.insert(Other._requested_variables.begin(), Other._requested_variables.end());
00772         _requested_sections.insert(Other._requested_sections.begin(), Other._requested_sections.end());
00773     }
00774 
00775 }

bool GETPOT_NAMESPACE::GetPot::argument_contains ( unsigned  Idx,
const char *  FlagList 
) const [inline]

Definition at line 1588 of file getpot.h.

References _check_flags(), _get_remaining_string(), _record_argument_request(), argv, and prefix.

01589 {
01590     if( Idx >= argv.size() ) return false;
01591 
01592     // (*) record requested of argument for later ufo-detection
01593     //     an argument that is checked for flags is considered to be 'requested'
01594     _record_argument_request(argv[Idx]);
01595 
01596     if( prefix == "" )
01597         // search argument for any flag in flag list
01598         return _check_flags(argv[Idx], FlagList);
01599 
01600     // if a prefix is set, then the argument index is the index
01601     //   inside the 'namespace'
01602     // => only check list of arguments that start with prefix
01603     unsigned no_matches = 0;
01604     unsigned i=0;
01605     for(; i<argv.size(); i++) {
01606         const std::string Remain = _get_remaining_string(argv[i], prefix);
01607         if( Remain != "") {
01608             no_matches += 1;
01609             if( no_matches == Idx)
01610                 return _check_flags(Remain, FlagList);
01611         }
01612     }
01613     // no argument in this namespace
01614     return false;
01615 }

void GETPOT_NAMESPACE::GetPot::clear_requests (  )  [inline]

Definition at line 778 of file getpot.h.

References _requested_arguments, _requested_sections, and _requested_variables.

00779 {
00780     // Get a lock before touching anything mutable
00781     SCOPED_MUTEX;
00782 
00783     _requested_arguments.clear();
00784     _requested_variables.clear();
00785     _requested_sections.clear();
00786 }

const char * GETPOT_NAMESPACE::GetPot::direct_follow ( const char *  Default,
const char *  Option 
) [inline]

Definition at line 1532 of file getpot.h.

References _internal_managed_copy(), and direct_follow().

01533 {
01534     return _internal_managed_copy(direct_follow(std::string(Default), Option));
01535 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::direct_follow ( const T &  Default,
const char *  Option 
) [inline]

Definition at line 1518 of file getpot.h.

References _convert_to_type(), _match_starting_string(), _record_argument_request(), argv, and cursor.

Referenced by direct_follow().

01519 {
01520     const char* FollowStr = _match_starting_string(Option);
01521 
01522     // (*) record requested of argument for later ufo-detection
01523     _record_argument_request(std::string(Option) + FollowStr);
01524 
01525     if( FollowStr == 0 )                    return Default;
01526     if( ++cursor >= argv.size() )
01527       cursor = getpot_cast_int<unsigned>(argv.size());
01528     return _convert_to_type(FollowStr, Default);
01529 }

void GETPOT_NAMESPACE::GetPot::disable_loop (  )  [inline]

Definition at line 207 of file getpot.h.

References search_loop_f.

Referenced by init_multiple_occurrence().

00207 { search_loop_f = false; }

void GETPOT_NAMESPACE::GetPot::disable_request_recording (  )  [inline]

Definition at line 137 of file getpot.h.

References request_recording_f.

00137 { request_recording_f = false; }

void GETPOT_NAMESPACE::GetPot::enable_loop (  )  [inline]

Definition at line 208 of file getpot.h.

References search_loop_f.

00208 { search_loop_f = true; }

void GETPOT_NAMESPACE::GetPot::enable_request_recording (  )  [inline]

Definition at line 138 of file getpot.h.

References request_recording_f.

00138 { request_recording_f = true; }

template<typename T >
T GETPOT_NAMESPACE::GetPot::follow ( const T &  Default,
unsigned int  No,
const char *  P,
  ... 
) [inline]

Definition at line 1471 of file getpot.h.

References next(), and search().

01472 {
01473     // (*) record requested of argument is entirely handled in 'search()' and 'next()'
01474     if( No == 0 ) return Default;
01475     if( search(P) == true ) return next(Default);
01476 
01477     va_list ap;
01478     va_start(ap, P);
01479     unsigned i=1;
01480     for(; i<No; i++) {
01481         char* Opt = va_arg(ap, char *);
01482         if( search(Opt) == true ) {
01483             va_end(ap);
01484             return next(Default);
01485         }
01486     }
01487     va_end(ap);
01488     return Default;
01489 }

const char * GETPOT_NAMESPACE::GetPot::follow ( const char *  Default,
unsigned  No,
const char *  Option,
  ... 
) [inline]

Definition at line 1492 of file getpot.h.

References next(), and search().

01493 {
01494     // (*) record requested of argument is entirely handled in 'search()' and 'next()'
01495     if( No == 0 ) return Default;
01496     if( search(P) == true ) return next(Default);
01497 
01498     va_list ap;
01499     va_start(ap, P);
01500     unsigned i=1;
01501     for(; i<No; i++) {
01502         char* Opt = va_arg(ap, char *);
01503         if( search(Opt) == true ) {
01504             va_end(ap);
01505             return next(Default);
01506         }
01507     }
01508     va_end(ap);
01509     return Default;
01510 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::follow ( const T &  Default,
unsigned  No,
const char *  Option,
  ... 
) [inline]
const char * GETPOT_NAMESPACE::GetPot::follow ( const char *  Default,
const char *  Option 
) [inline]

Definition at line 1462 of file getpot.h.

References _internal_managed_copy(), and follow().

01463 {
01464     return _internal_managed_copy(follow(std::string(Default), Option));
01465 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::follow ( const T &  Default,
const char *  Option 
) [inline]

Definition at line 1454 of file getpot.h.

References next(), and search().

Referenced by follow().

01455 {
01456     // (*) record requested of argument is entirely handled in 'search()' and 'next()'
01457     if( search(Option) == false ) return Default;
01458     return next(Default);
01459 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::get ( unsigned int  Idx,
const T &  Default 
) const [inline]

Definition at line 1408 of file getpot.h.

References _convert_to_type(), and argv.

01409 {
01410     if( Idx >= argv.size() ) return Default;
01411     return _convert_to_type(argv[Idx], Default);
01412 }

const char* GETPOT_NAMESPACE::GetPot::get ( unsigned  Idx,
const char *  Default 
) const [inline]
template<typename T >
T GETPOT_NAMESPACE::GetPot::get ( unsigned  Idx,
const T &  Default 
) const [inline]
std::set< std::string > GETPOT_NAMESPACE::GetPot::get_overridden_variables (  )  const [inline]

Definition at line 1922 of file getpot.h.

References overridden_vars.

01923 { return overridden_vars; }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_section_names (  )  const [inline]

Definition at line 1918 of file getpot.h.

References section_list.

01919 { return section_list; }

template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const T &  Default,
unsigned int  Idx 
) const [inline]

Definition at line 1793 of file getpot.h.

References get_value_no_default().

01794 {
01795     return get_value_no_default(VarName.c_str(), Default, Idx);
01796 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const T &  Default,
unsigned int  Idx 
) const [inline]

Definition at line 1775 of file getpot.h.

References _convert_to_type_no_default(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::get_element().

01776 {
01777     // (*) recording of requested variables happens in '_request_variable()'
01778     const variable* sv = _request_variable(VarName);
01779     if( sv == 0 ){
01780       getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
01781       getpot_error();
01782     }
01783     const std::string*  element = sv->get_element(Idx);
01784     if( element == 0 ){
01785       getpot_cerr << "ERROR: cannot find index "<<Idx<<" of variable "<<VarName<<std::endl;
01786       getpot_error();
01787     }
01788     return _convert_to_type_no_default(VarName, *element, Default);
01789 }

const char* GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const char *  Default,
unsigned  Idx 
) const [inline]
const char* GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const char *  Default,
unsigned  Idx 
) const [inline]
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const T &  Default,
unsigned  Idx 
) const [inline]
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const T &  Default,
unsigned  Idx 
) const [inline]
const char * GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const char *  Default 
) const [inline]

Definition at line 1768 of file getpot.h.

References get_value_no_default().

01769 {
01770     return get_value_no_default(VarName.c_str(),Default);
01771 }

const char * GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const char *  Default 
) const [inline]

Definition at line 1762 of file getpot.h.

References _internal_managed_copy(), and get_value_no_default().

01763 {
01764     return _internal_managed_copy(get_value_no_default(VarName, Default));
01765 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const T &  Default 
) const [inline]

Definition at line 1756 of file getpot.h.

References get_value_no_default().

01757 {
01758     return get_value_no_default(VarName.c_str(),Default);
01759 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const T &  Default 
) const [inline]

Definition at line 1742 of file getpot.h.

References _convert_to_type_no_default(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::original.

Referenced by get_value_no_default().

01743 {
01744     // (*) recording of requested variables happens in '_request_variable()'
01745     const variable*  sv = _request_variable(VarName);
01746     if( sv == 0 )
01747     {
01748       getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
01749       getpot_error();
01750     }
01751     return _convert_to_type_no_default(VarName, sv->original, Default);
01752 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_variable_names (  )  const [inline]

Definition at line 1906 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

01907 {
01908     STRING_VECTOR  result;
01909     std::vector<GetPot::variable>::const_iterator it = variables.begin();
01910     for(; it != variables.end(); ++it) {
01911         const std::string Tmp = _get_remaining_string((*it).name, prefix);
01912         if( Tmp != "" ) result.push_back(Tmp);
01913     }
01914     return result;
01915 }

bool GETPOT_NAMESPACE::GetPot::have_variable ( const std::string &  VarName  )  const [inline]

Definition at line 1675 of file getpot.h.

References have_variable().

01676 {
01677     return have_variable(VarName.c_str());
01678 }

bool GETPOT_NAMESPACE::GetPot::have_variable ( const char *  VarName  )  const [inline]

Definition at line 1667 of file getpot.h.

References _request_variable().

Referenced by have_variable().

01668 {
01669     const variable* sv = _request_variable(VarName);
01670     if (sv == 0) return false;
01671     return true;
01672 }

void GETPOT_NAMESPACE::GetPot::init_multiple_occurrence (  )  [inline]

Definition at line 1396 of file getpot.h.

References disable_loop(), and reset_cursor().

01397 { disable_loop(); reset_cursor(); }

const char * GETPOT_NAMESPACE::GetPot::next ( const char *  Default  )  [inline]

Definition at line 1445 of file getpot.h.

References _internal_managed_copy(), and next().

01446 {
01447     return _internal_managed_copy(next(std::string(Default)));
01448 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::next ( const T &  Default  )  [inline]

Definition at line 1429 of file getpot.h.

References _convert_to_type(), _get_remaining_string(), _record_argument_request(), argv, cursor, prefix, and search_failed_f.

Referenced by follow(), and next().

01430 {
01431     if( search_failed_f ) return Default;
01432     cursor++;
01433     if( cursor >= argv.size() )
01434     { cursor = getpot_cast_int<unsigned>(argv.size()); return Default; }
01435 
01436     // (*) record requested argument for later ufo detection
01437     _record_argument_request(argv[cursor]);
01438 
01439     const std::string Remain = _get_remaining_string(argv[cursor], prefix);
01440 
01441     return Remain != "" ? _convert_to_type(Remain, Default) : Default;
01442 }

const char * GETPOT_NAMESPACE::GetPot::next_nominus (  )  [inline]

Definition at line 1646 of file getpot.h.

References _record_argument_request(), argv, idx_nominus, and nominus_cursor.

01647 {
01648     if( nominus_cursor < int(idx_nominus.size()) - 1 ) {
01649         const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
01650 
01651         // (*) record for later ufo-detection
01652         _record_argument_request(Tmp);
01653 
01654         return Tmp.c_str();
01655     }
01656     return 0;
01657 }

unsigned GETPOT_NAMESPACE::GetPot::nominus_size (  )  const [inline]

Definition at line 238 of file getpot.h.

References idx_nominus.

00238                                                 {
00239         return getpot_cast_int<unsigned>(idx_nominus.size());
00240     }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::nominus_vector (  )  const [inline]

Definition at line 1629 of file getpot.h.

References _record_argument_request(), argv, and idx_nominus.

01631 {
01632     STRING_VECTOR nv;
01633     std::vector<unsigned>::const_iterator it = idx_nominus.begin();
01634     for(; it != idx_nominus.end(); ++it) {
01635         nv.push_back(argv[*it]);
01636 
01637         // (*) record for later ufo-detection
01638         //     when a nominus vector is requested, the entire set of nominus arguments are
01639         //     tagged as 'requested'
01640         _record_argument_request(argv[*it]);
01641     }
01642     return nv;
01643 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const T &  Default,
unsigned int  Idx 
) const [inline]

Definition at line 1723 of file getpot.h.

References operator()().

01724 {
01725     return operator()(VarName.c_str(), Default, Idx);
01726 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const T &  Default,
unsigned int  Idx 
) const [inline]

Definition at line 1711 of file getpot.h.

References _convert_to_type(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::get_element().

01712 {
01713     // (*) recording of requested variables happens in '_request_variable()'
01714     const variable* sv = _request_variable(VarName);
01715     if( sv == 0 ) return Default;
01716     const std::string*  element = sv->get_element(Idx);
01717     if( element == 0 ) return Default;
01718     return _convert_to_type(*element, Default);
01719 }

const char* GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const char *  Default,
unsigned  Idx 
) const [inline]
const char* GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const char *  Default,
unsigned  Idx 
) const [inline]
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const T &  Default,
unsigned  Idx 
) const [inline]
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const T &  Default,
unsigned  Idx 
) const [inline]
const char * GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const char *  Default 
) const [inline]

Definition at line 1704 of file getpot.h.

References operator()().

01705 {
01706     return operator()(VarName.c_str(), Default);
01707 }

const char * GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const char *  Default 
) const [inline]

Definition at line 1698 of file getpot.h.

References _internal_managed_copy().

01699 {
01700     return _internal_managed_copy(operator()(VarName, std::string(Default)));
01701 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const T &  Default 
) const [inline]

Definition at line 1692 of file getpot.h.

References operator()().

01693 {
01694     return operator()(VarName.c_str(), Default);
01695 }

template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const T &  Default 
) const [inline]

Definition at line 1682 of file getpot.h.

References _convert_to_type(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::original.

Referenced by operator()().

01683 {
01684     // (*) recording of requested variables happens in '_request_variable()'
01685     const variable*  sv = _request_variable(VarName);
01686     if( sv == 0 ) return Default;
01687     return _convert_to_type(sv->original, Default);
01688 }

GetPot & GETPOT_NAMESPACE::GetPot::operator= ( const GetPot Other  )  [inline]

Definition at line 700 of file getpot.h.

References _comment_end, _comment_start, _field_separator, _getpot_mtx, _internal_string_container, _requested_arguments, _requested_sections, _requested_variables, argv, cursor, end, idx_nominus, nominus_cursor, overridden_vars, prefix, request_recording_f, search_failed_f, search_loop_f, section, section_list, and variables.

00701 {
00702     if (&Other == this) return *this;
00703 
00704     prefix               = Other.prefix;
00705     section              = Other.section;
00706     section_list         = Other.section_list;
00707     argv                 = Other.argv;
00708     cursor               = Other.cursor;
00709     search_loop_f        = Other.search_loop_f;
00710     search_failed_f      = Other.search_failed_f;
00711     nominus_cursor       = Other.nominus_cursor;
00712     overridden_vars      = Other.overridden_vars;
00713     idx_nominus          = Other.idx_nominus;
00714     variables            = Other.variables;
00715     _comment_start       = Other._comment_start;
00716     _comment_end         = Other._comment_end;
00717     _field_separator     = Other._field_separator;
00718     _getpot_mtx          = Other._getpot_mtx;
00719     _requested_arguments = Other._requested_arguments;
00720     _requested_variables = Other._requested_variables;
00721     _requested_sections  = Other._requested_sections;
00722     request_recording_f  = Other.request_recording_f;
00723 
00724     std::set<const char*, ltstr>::const_iterator        my_it =
00725       _internal_string_container.begin();
00726     const std::set<const char*, ltstr>::const_iterator my_end =
00727       _internal_string_container.end();
00728 
00729     for(; my_it != my_end; ++my_it)
00730         delete [] *my_it;
00731 
00732     _internal_string_container.clear();
00733 
00734     std::set<const char*,ltstr>::const_iterator it =
00735       Other._internal_string_container.begin();
00736     const std::set<const char*,ltstr>::const_iterator end =
00737       Other._internal_string_container.end();
00738 
00739     for (; it != end; ++it) {
00740         const char* otherstr = *it;
00741         char* newcopy = new char[strlen(otherstr)+1];
00742         strncpy(newcopy, otherstr, strlen(otherstr)+1);
00743         this->_internal_string_container.insert(newcopy);
00744     }
00745 
00746     return *this;
00747 }

const char * GETPOT_NAMESPACE::GetPot::operator[] ( unsigned  Idx  )  const [inline]

Definition at line 1403 of file getpot.h.

References argv.

01404 { return idx<argv.size() ? argv[idx].c_str() : 0; }

bool GETPOT_NAMESPACE::GetPot::options_contain ( const char *  FlagList  )  const [inline]

Definition at line 1573 of file getpot.h.

References _check_flags(), _get_remaining_string(), argv, and prefix.

01574 {
01575     // go through all arguments that start with a '-' (but not '--')
01576     std::string str;
01577     STRING_VECTOR::const_iterator it = argv.begin();
01578     for(; it != argv.end(); ++it) {
01579         str = _get_remaining_string(*it, prefix);
01580 
01581         if( str.length() >= 2 && str[0] == '-' && str[1] != '-' )
01582             if( _check_flags(str, FlagList) ) return true;
01583     }
01584     return false;
01585 }

void GETPOT_NAMESPACE::GetPot::parse_command_line ( const int  argc_,
char **  argv_,
const char *  FieldSeparator = 0x0 
) [inline]

Definition at line 536 of file getpot.h.

References _basic_initialization(), _field_separator, and _parse_argument_vector().

Referenced by GetPot().

00539 {
00540     _basic_initialization();
00541 
00542     // if specified -> overwrite default string
00543     if( FieldSeparator ) _field_separator = std::string(FieldSeparator);
00544 
00545     // -- make an internal copy of the argument list:
00546     STRING_VECTOR _apriori_argv;
00547     // -- for the sake of clarity: we do want to include the first
00548     //    argument of the first parsing source in the argument vector!
00549     //    it will not be a nominus argument, though. This gives us a
00550     //    minimum vector size of one which facilitates error checking
00551     //    in many functions. Also the user will be able to retrieve
00552     //    the name of his application or input file by "get[0]"
00553     _apriori_argv.push_back(std::string(argv_[0]));
00554     int i=1;
00555     for(; i<argc_; i++) {
00556         std::string tmp(argv_[i]);   // recall the problem with temporaries,
00557         _apriori_argv.push_back(tmp);       // reference counting in arguement lists ...
00558     }
00559     _parse_argument_vector(_apriori_argv);
00560 }

void GETPOT_NAMESPACE::GetPot::parse_input_file ( const std::string &  FileName,
const std::string &  CommentStart = std::string("#"),
const std::string &  CommentEnd = std::string("\n"),
const std::string &  FieldSeparator = std::string(" \t\n") 
) [inline]

Definition at line 626 of file getpot.h.

References _basic_initialization(), _comment_end, _comment_start, _field_separator, _parse_argument_vector(), and _read_in_file().

Referenced by _parse_argument_vector(), and GetPot().

00630 {
00631     _basic_initialization();
00632 
00633     // overwrite default strings
00634     _comment_start = std::string(CommentStart);
00635     _comment_end   = std::string(CommentEnd);
00636     _field_separator = FieldSeparator;
00637 
00638     STRING_VECTOR _apriori_argv;
00639     // -- the first element of the argument vector stores the name of
00640     //    the first parsing source; however, this element is not
00641     //    parsed for variable assignments or nominuses.
00642     //
00643     //    Regardless, we don't add more than one name to the argument
00644     //    vector.
00645     _apriori_argv.push_back(FileName);
00646 
00647     STRING_VECTOR args = _read_in_file(FileName.c_str());
00648     _apriori_argv.insert(_apriori_argv.begin()+1, args.begin(), args.end());
00649     _parse_argument_vector(_apriori_argv);
00650 }

int GETPOT_NAMESPACE::GetPot::print ( const char *  custom_prefix,
std::ostream &  out_stream = std::cout,
unsigned int  skip_count = 1 
) const [inline]

Definition at line 1968 of file getpot.h.

References argv.

01969 {
01970     STRING_VECTOR::const_iterator it = argv.begin();
01971     it += skip_count;
01972     for(; it != argv.end(); ++it)
01973       {
01974         out_stream << custom_prefix;
01975         out_stream << *it << std::endl;
01976       }
01977     out_stream << std::endl;
01978     return 1;
01979 }

int GETPOT_NAMESPACE::GetPot::print ( std::ostream &  out_stream = std::cout  )  const [inline]

Definition at line 1951 of file getpot.h.

References argv.

01952 {
01953     out_stream << "argc = " << argv.size() << std::endl;
01954     STRING_VECTOR::const_iterator it = argv.begin();
01955     for(; it != argv.end(); ++it)
01956         out_stream << *it << std::endl;
01957     out_stream << std::endl;
01958     return 1;
01959 }

void GETPOT_NAMESPACE::GetPot::reset_cursor (  )  [inline]

Definition at line 1392 of file getpot.h.

References cursor, and search_failed_f.

Referenced by init_multiple_occurrence().

01393 { search_failed_f = false; cursor = 0; }

void GETPOT_NAMESPACE::GetPot::reset_nominus_cursor (  )  [inline]

Definition at line 1660 of file getpot.h.

References nominus_cursor.

01661 { nominus_cursor = -1; }

bool GETPOT_NAMESPACE::GetPot::search ( unsigned  No,
const char *  P,
  ... 
) [inline]

Definition at line 1354 of file getpot.h.

References _record_argument_request(), and search().

01355 {
01356     // (*) recording the requested arguments happens in subroutine 'search'
01357     if( No == 0 ) return false;
01358 
01359     // search for the first argument
01360     if( search(P) == true ) return true;
01361 
01362     // start interpreting variable argument list
01363     va_list ap;
01364     va_start(ap, P);
01365     unsigned i = 1;
01366     for(; i < No; i++) {
01367         char* Opt = va_arg(ap, char *);
01368         // (*) search records itself for later ufo detection
01369         if( search(Opt) == true ) break;
01370     }
01371 
01372     if( i < No ) {
01373         i++;
01374         // loop was left before end of array --> hit but
01375         // make sure that the rest of the search terms is marked
01376         // as requested.
01377         for(; i < No; i++) {
01378             char* Opt = va_arg(ap, char *);
01379             // (*) record requested arguments for later ufo detection
01380             _record_argument_request(Opt);
01381         }
01382         va_end(ap);
01383         return true;
01384     }
01385 
01386     va_end(ap);
01387     // loop was left normally --> no hit
01388     return false;
01389 }

bool GETPOT_NAMESPACE::GetPot::search ( const std::string &  option  )  [inline]

Definition at line 1316 of file getpot.h.

References search().

01317 {
01318   return search(Option.c_str());
01319 }

bool GETPOT_NAMESPACE::GetPot::search ( const char *  option  )  [inline]

Definition at line 1323 of file getpot.h.

References _record_argument_request(), argv, cursor, prefix, search_failed_f, and search_loop_f.

Referenced by follow(), and search().

01324 {
01325     unsigned           OldCursor = cursor;
01326     const std::string  SearchTerm = prefix + Option;
01327 
01328     // (*) record requested arguments for later ufo detection
01329     _record_argument_request(SearchTerm);
01330 
01331     if( OldCursor >= argv.size() )
01332       OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
01333     search_failed_f = true;
01334 
01335     // (*) first loop from cursor position until end
01336     unsigned  c = cursor;
01337     for(; c < argv.size(); c++) {
01338         if( argv[c] == SearchTerm )
01339         { cursor = c; search_failed_f = false; return true; }
01340     }
01341     if( ! search_loop_f ) return false;
01342 
01343     // (*) second loop from 0 to old cursor position
01344     for(c = 1; c < OldCursor; c++) {
01345         if( argv[c] == SearchTerm )
01346         { cursor = c; search_failed_f = false; return true; }
01347     }
01348     // in case nothing is found the cursor stays where it was
01349     return false;
01350 }

bool GETPOT_NAMESPACE::GetPot::search_failed (  )  const [inline]

Definition at line 204 of file getpot.h.

References search_failed_f.

00204 { return search_failed_f; }

void GETPOT_NAMESPACE::GetPot::set ( const std::string &  VarName,
const char *  Value,
const bool  Requested = true 
) [inline]

Definition at line 1886 of file getpot.h.

01887 {
01888     set(VarName.c_str(), Value, Requested);
01889 }

void GETPOT_NAMESPACE::GetPot::set ( const char *  VarName,
const char *  Value,
const bool  Requested = true 
) [inline]

Definition at line 1880 of file getpot.h.

References _set_variable().

01881 {
01882   _set_variable(VarName, Value, Requested);
01883 }

template<typename T >
void GETPOT_NAMESPACE::GetPot::set ( const std::string &  VarName,
const T &  Value,
const bool  Requested = true 
) [inline]

Definition at line 1874 of file getpot.h.

01875 {
01876     set(VarName.c_str(), Value, Requested);
01877 }

template<typename T >
void GETPOT_NAMESPACE::GetPot::set ( const char *  VarName,
const T &  Value,
const bool  Requested = true 
) [inline]

Definition at line 1865 of file getpot.h.

References _set_variable().

01866 {
01867   std::ostringstream string_value;
01868   string_value << Value;
01869   _set_variable(VarName, string_value.str().c_str(), Requested);
01870 }

void GETPOT_NAMESPACE::GetPot::set_prefix ( const char *  Prefix  )  [inline]

Definition at line 203 of file getpot.h.

References prefix.

00203 { prefix = std::string(Prefix); }

unsigned GETPOT_NAMESPACE::GetPot::size (  )  const [inline]

Definition at line 1422 of file getpot.h.

References argv.

Referenced by _DBE_expand().

01423 { return getpot_cast_int<unsigned>(argv.size()); }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments (  )  const [inline]

Definition at line 2579 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_arguments(), and unidentified_options().

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( const std::vector< std::string > &  Knowns  )  const [inline]

Definition at line 2583 of file getpot.h.

References unidentified_arguments().

02584 {
02585     // We use set for efficiency, but want to support vector inputs for
02586     // backwards compatibility.
02587     return unidentified_arguments(std::set<std::string> (Knowns.begin(), Knowns.end()));
02588 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( const std::set< std::string > &  Knowns  )  const [inline]

Definition at line 2591 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

02592 {
02593     STRING_VECTOR ufos;
02594     STRING_VECTOR::const_iterator it = argv.begin();
02595     ++it; // forget about argv[0] (application or filename)
02596     for(; it != argv.end(); ++it) {
02597         // -- argument belongs to prefixed section ?
02598         const std::string arg = _get_remaining_string(*it, prefix);
02599         if( arg == "" ) continue;
02600 
02601         // -- check if in list
02602         if( Knowns.find(arg) == Knowns.end() )
02603             ufos.push_back(*it);
02604     }
02605     return ufos;
02606 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( unsigned  Number,
const char *  Known,
  ... 
) const [inline]

Definition at line 2559 of file getpot.h.

References unidentified_arguments().

02561 {
02562     std::set<std::string> known_arguments;
02563 
02564     // (1) create a vector of known arguments
02565     if( Number == 0 ) return STRING_VECTOR();
02566 
02567     va_list ap;
02568     va_start(ap, KnownArgument1);
02569     known_arguments.insert(std::string(KnownArgument1));
02570     unsigned i=1;
02571     for(; i<Number; i++)
02572         known_arguments.insert(std::string(va_arg(ap, char *)));
02573     va_end(ap);
02574 
02575     return unidentified_arguments(known_arguments);
02576 }

std::string GETPOT_NAMESPACE::GetPot::unidentified_flags ( const char *  Known,
int  ArgumentNumber = -1 
) const [inline]

Definition at line 2670 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

02671                 :
02672     //  ArgumentNumber >= 0 check specific argument
02673     //  ArgumentNumber == -1 check all options starting with one '-'
02674     //                       for flags
02675 {
02676     std::string         ufos;
02677     STRING_VECTOR known_arguments;
02678     std::string         KFL(KnownFlagList);
02679 
02680     // (2) iteration over '-' arguments (options)
02681     if( ArgumentNumber == -1 ) {
02682         STRING_VECTOR::const_iterator it = argv.begin();
02683         it++; // forget about argv[0] (application or filename)
02684         for(; it != argv.end(); ++it) {
02685             // -- argument belongs to prefixed section ?
02686             const std::string arg = _get_remaining_string(*it, prefix);
02687             if( arg == "" ) continue;
02688 
02689             // -- does arguments start with '-' (but not '--')
02690             if     ( arg.length() < 2 ) continue;
02691             else if( arg[0] != '-' )    continue;
02692             else if( arg[1] == '-' )    continue;
02693 
02694             // -- check out if flags inside option are contained in KnownFlagList
02695             const char* p=arg.c_str();
02696             p++; // skip starting minus
02697             for(; *p != '\0' ; p++)
02698                 if( KFL.find(*p) == std::string::npos ) ufos += *p;
02699         }
02700     }
02701     // (1) check specific argument
02702     else {
02703         // -- only check arguments that start with prefix
02704         int no_matches = 0;
02705         unsigned i=1;
02706         for(; i<argv.size(); i++) {
02707             const std::string Remain = _get_remaining_string(argv[i], prefix);
02708             if( Remain != "") {
02709                 no_matches++;
02710                 if( no_matches == ArgumentNumber) {
02711                     // -- the right argument number inside the section is found
02712                     // => check it for flags
02713                     const char* p = Remain.c_str();
02714                     p++; // skip starting minus
02715                     for(; *p != '\0' ; p++)
02716                         if( KFL.find(*p) == std::string::npos ) ufos += *p;
02717                     return ufos;
02718                 }
02719             }
02720         }
02721     }
02722     return ufos;
02723 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses (  )  const [inline]

Definition at line 2853 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_nominuses().

02853                                      {
02854     // -- every nominus is an argument.
02855     // -- the set of requested arguments contains the set of requested nominuss.
02856     // -- IF the set of requested arguments contains unrequested nominuss,
02857     //    THEN they were requested as 'follow' and 'next' arguments and not as real nominuses.
02858     //
02859     // => it is not necessary to separate requested nominus from the list
02860 
02861     return unidentified_nominuses(_requested_arguments);
02862 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( const std::vector< std::string > &  Knowns  )  const [inline]

Definition at line 2865 of file getpot.h.

References unidentified_nominuses().

02866 {
02867     // We use set for efficiency, but want to support vector inputs for
02868     // backwards compatibility.
02869     return unidentified_nominuses(std::set<std::string> (Knowns.begin(), Knowns.end()));
02870 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( const std::set< std::string > &  Knowns  )  const [inline]

Definition at line 2873 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

02874 {
02875     STRING_VECTOR ufos;
02876 
02877     // (2) iterate over all arguments
02878     STRING_VECTOR::const_iterator it = argv.begin();
02879     ++it; // forget about argv[0] (application or filename)
02880     for(; it != argv.end(); ++it) {
02881         // -- check if nominus part of prefix
02882         const std::string arg = _get_remaining_string(*it, prefix);
02883         if( arg == "" )                                         continue;
02884 
02885         if( arg.length() < 1 )                                  continue;
02886         // option ? --> not a nomius
02887         if( arg[0] == '-' )                                     continue;
02888         // section ? --> not a real nominus
02889         if( arg[0] == '[' && arg[arg.length()-1] == ']' )       continue;
02890         // variable definition ? --> not a real nominus
02891         bool continue_f = false;
02892         unsigned i=0;
02893         for(; i<arg.length() ; i++)
02894             if( arg[i] == '=' ) { continue_f = true; break; }
02895         if( continue_f )                                        continue;
02896 
02897         // real nominuses are compared with the given list
02898         if( Knowns.find(arg) == Knowns.end() )
02899             ufos.push_back(*it);
02900     }
02901     return ufos;
02902 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( unsigned  Number,
const char *  Known,
  ... 
) const [inline]

Definition at line 2831 of file getpot.h.

References unidentified_nominuses().

02832 {
02833     std::set<std::string> known_nominuses;
02834 
02835     // create vector of known arguments
02836     if( Number == 0 ) return STRING_VECTOR();
02837 
02838     va_list ap;
02839     va_start(ap, Known);
02840     known_nominuses.insert(std::string(Known));
02841     unsigned i=1;
02842     for(; i<Number; i++) {
02843         std::string tmp = std::string(va_arg(ap, char *));
02844         if( tmp.length() == 0 ) continue;
02845         known_nominuses.insert(tmp);
02846     }
02847     va_end(ap);
02848 
02849     return unidentified_nominuses(known_nominuses);
02850 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options (  )  const [inline]

Definition at line 2629 of file getpot.h.

References _requested_arguments, and unidentified_arguments().

Referenced by unidentified_options().

02630 {
02631     // -- every option is an argument.
02632     // -- the set of requested arguments contains the set of requested options.
02633     // -- IF the set of requested arguments contains unrequested options,
02634     //    THEN they were requested as 'follow' and 'next' arguments and not as real options.
02635     //
02636     // => it is not necessary to separate requested options from the list
02637     return unidentified_arguments(_requested_arguments);
02638 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( const std::vector< std::string > &  Knowns  )  const [inline]

Definition at line 2641 of file getpot.h.

References unidentified_options().

02642 {
02643     // We use set for efficiency, but want to support vector inputs for
02644     // backwards compatibility.
02645     return unidentified_options(std::set<std::string> (Knowns.begin(), Knowns.end()));
02646 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( const std::set< std::string > &  Knowns  )  const [inline]

Definition at line 2649 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

02650 {
02651     STRING_VECTOR ufos;
02652     STRING_VECTOR::const_iterator it = argv.begin();
02653     ++it; // forget about argv[0] (application or filename)
02654     for(; it != argv.end(); ++it) {
02655         // -- argument belongs to prefixed section ?
02656         const std::string arg = _get_remaining_string(*it, prefix);
02657         if( arg == "" ) continue;
02658 
02659         // is argument really an option (starting with '-') ?
02660         if( arg.length() < 1 || arg[0] != '-' ) continue;
02661 
02662         if( Knowns.find(arg) == Knowns.end() )
02663             ufos.push_back(*it);
02664     }
02665 
02666     return ufos;
02667 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( unsigned  Number,
const char *  Known,
  ... 
) const [inline]

Definition at line 2609 of file getpot.h.

References unidentified_options().

02611 {
02612     std::set<std::string> known_options;
02613 
02614     // (1) create a vector of known arguments
02615     if( Number == 0 ) return STRING_VECTOR();
02616 
02617     va_list ap;
02618     va_start(ap, KnownOption1);
02619     known_options.insert(std::string(KnownOption1));
02620     unsigned i=1;
02621     for(; i<Number; i++)
02622         known_options.insert(std::string(va_arg(ap, char *)));
02623     va_end(ap);
02624 
02625     return unidentified_options(known_options);
02626 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections (  )  const [inline]

Definition at line 2800 of file getpot.h.

References _requested_sections.

Referenced by unidentified_sections().

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( const std::vector< std::string > &  Knowns  )  const [inline]

Definition at line 2804 of file getpot.h.

References unidentified_sections().

02805 {
02806     // We use set for efficiency, but want to support vector inputs for
02807     // backwards compatibility.
02808     return unidentified_sections(std::set<std::string> (Knowns.begin(), Knowns.end()));
02809 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( const std::set< std::string > &  Knowns  )  const [inline]

Definition at line 2812 of file getpot.h.

References _get_remaining_string(), prefix, and section_list.

02813 {
02814     STRING_VECTOR ufos;
02815 
02816     victorate(std::string, section_list, it) {
02817         // -- check if section conform to prefix
02818         const std::string sec_name = _get_remaining_string(*it, prefix);
02819         if( sec_name == "" ) continue;
02820 
02821         // -- check if section is known
02822         if( Knowns.find(sec_name) == Knowns.end() )
02823             ufos.push_back(*it);
02824     }
02825 
02826     return ufos;
02827 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( unsigned  Number,
const char *  Known,
  ... 
) const [inline]

Definition at line 2776 of file getpot.h.

References unidentified_sections().

02778 {
02779     std::set<std::string> known_sections;
02780 
02781     // (1) create a vector of known arguments
02782     if( Number == 0 ) return STRING_VECTOR();
02783 
02784     va_list ap;
02785     va_start(ap, KnownSection1);
02786     known_sections.insert(std::string(KnownSection1));
02787     unsigned i=1;
02788     for(; i<Number; i++) {
02789         std::string tmp = std::string(va_arg(ap, char *));
02790         if( tmp.length() == 0 ) continue;
02791         if( tmp[tmp.length()-1] != '/' ) tmp += '/';
02792         known_sections.insert(tmp);
02793     }
02794     va_end(ap);
02795 
02796     return unidentified_sections(known_sections);
02797 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables (  )  const [inline]

Definition at line 2771 of file getpot.h.

References _requested_variables.

Referenced by unidentified_variables().

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( const std::vector< std::string > &  Knowns  )  const [inline]

Definition at line 2746 of file getpot.h.

References unidentified_variables().

02747 {
02748     // We use set for efficiency, but want to support vector inputs for
02749     // backwards compatibility.
02750     return unidentified_variables(std::set<std::string> (Knowns.begin(), Knowns.end()));
02751 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( const std::set< std::string > &  Knowns  )  const [inline]

Definition at line 2754 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

02755 {
02756     STRING_VECTOR ufos;
02757 
02758     victorate(GetPot::variable, variables, it) {
02759         // -- check if variable has specific prefix
02760         const std::string var_name = _get_remaining_string((*it).name, prefix);
02761         if( var_name == "" ) continue;
02762 
02763         // -- check if variable is known
02764         if( Knowns.find(var_name) == Knowns.end() )
02765             ufos.push_back((*it).name);
02766     }
02767     return ufos;
02768 }

STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( unsigned  Number,
const char *  Known,
  ... 
) const [inline]

Definition at line 2726 of file getpot.h.

References unidentified_variables().

02728 {
02729     std::set<std::string> known_variables;
02730 
02731     // create vector of known arguments
02732     if( Number == 0 ) return STRING_VECTOR();
02733 
02734     va_list ap;
02735     va_start(ap, KnownVariable1);
02736     known_variables.insert(std::string(KnownVariable1));
02737     unsigned i=1;
02738     for(; i<Number; i++)
02739         known_variables.insert(std::string(va_arg(ap, char *)));
02740     va_end(ap);
02741 
02742     return unidentified_variables(known_variables);
02743 }

unsigned GETPOT_NAMESPACE::GetPot::vector_variable_size ( const std::string &  VarName  )  const [inline]

Definition at line 1900 of file getpot.h.

References vector_variable_size().

01901 {
01902     return vector_variable_size(VarName.c_str());
01903 }

unsigned GETPOT_NAMESPACE::GetPot::vector_variable_size ( const char *  VarName  )  const [inline]

Definition at line 1892 of file getpot.h.

References _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::value.

Referenced by vector_variable_size().

01893 {
01894     const variable*  sv = _request_variable(VarName);
01895     if( sv == 0 ) return 0;
01896     return (unsigned)(sv->value.size());
01897 }


Member Data Documentation

Definition at line 348 of file getpot.h.

Referenced by operator=().

std::set<const char*, ltstr> GETPOT_NAMESPACE::GetPot::_internal_string_container [mutable, private]

Definition at line 357 of file getpot.h.

Referenced by _internal_managed_copy(), GetPot(), operator=(), and ~GetPot().

std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_variables [mutable, private]
std::vector<unsigned> GETPOT_NAMESPACE::GetPot::idx_nominus [private]
std::set<std::string> GETPOT_NAMESPACE::GetPot::overridden_vars [private]

Definition at line 319 of file getpot.h.

Referenced by _set_variable(), get_overridden_variables(), and operator=().


The documentation for this class was generated from the following file:

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:06 UTC

Hosted By:
SourceForge.net Logo