$extrastylesheet
#include <getpot.h>
Classes | |
| struct | ltstr |
| struct | variable |
Public Member Functions | |
| GetPot () | |
| GetPot (const GetPot &) | |
| GetPot (const int argc_, const char *const *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 () | |
| GetPot & | operator= (const GetPot &) |
| void | parse_command_line (const int argc_, const char *const *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 > | |
| 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 |
| bool | have_section (const char *section_name) const |
| bool | have_section (const std::string §ion_name) const |
| template<typename T > | |
| T | operator() (const char *VarName, const T &Default) const |
| template<typename T > | |
| 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 > | |
| T | operator() (const char *VarName, const T &Default, unsigned Idx) const |
| template<typename T > | |
| 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 > | |
| T | get_value_no_default (const char *VarName, const T &Default) const |
| template<typename T > | |
| 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 > | |
| T | get_value_no_default (const char *VarName, const T &Default, unsigned Idx) const |
| template<typename T > | |
| 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 > | |
| T | next (const T &Default) |
| const char * | next (const char *Default) |
| template<typename T > | |
| T | follow (const T &Default, const char *Option) |
| const char * | follow (const char *Default, const char *Option) |
| template<typename T > | |
| T | follow (const T &Default, unsigned No, const char *Option,...) |
| const char * | follow (const char *Default, unsigned No, const char *Option,...) |
| template<typename T > | |
| 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 () |
| std::string | next_nominus_string () |
| 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 > | |
| T | get (unsigned int Idx, const T &Default) const |
| template<typename T > | |
| T | follow (const T &Default, unsigned int No, const char *P,...) |
| template<typename T > | |
| T | operator() (const char *VarName, const T &Default, unsigned int Idx) const |
| template<typename T > | |
| T | operator() (const std::string &VarName, const T &Default, unsigned int Idx) const |
| template<typename T > | |
| T | get_value_no_default (const char *VarName, const T &Default, unsigned int Idx) const |
| template<typename T > | |
| 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 > | |
| 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 > | |
| 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 §ion_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< variable > | variables |
| 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 |
GetPot - A class for parsing comand line arguments and configuration files.
| GETPOT_NAMESPACE::GetPot::GetPot | ( | ) | [inline] |
constructors, destructor, assignment operator
Definition at line 683 of file getpot.h.
References _basic_initialization().
: prefix(), section(), section_list(), argv(), cursor(), search_loop_f(), search_failed_f(), nominus_cursor(), idx_nominus(), variables(), _comment_start(), _comment_end(), _field_separator(), #if !defined(GETPOT_DISABLE_MUTEX) _getpot_mtx(), #endif _internal_string_container(), _requested_arguments(), _requested_variables(), _requested_sections(), request_recording_f() { _basic_initialization(); }
| GETPOT_NAMESPACE::GetPot::GetPot | ( | const GetPot & | Other | ) | [inline] |
Definition at line 868 of file getpot.h.
References _internal_string_container, and end.
: prefix(Other.prefix), section(Other.section), section_list(Other.section_list), argv(Other.argv), cursor(Other.cursor), search_loop_f(Other.search_loop_f), search_failed_f(Other.search_failed_f), overridden_vars(), nominus_cursor(Other.nominus_cursor), idx_nominus(Other.idx_nominus), variables(Other.variables), _comment_start(Other._comment_start), _comment_end(Other._comment_end), _field_separator(Other._field_separator), // #if !defined(GETPOT_DISABLE_MUTEX) // _getpot_mtx(Other._getpot_mtx), // #endif _internal_string_container(), _requested_arguments(Other._requested_arguments), _requested_variables(Other._requested_variables), _requested_sections(Other._requested_sections), request_recording_f(Other.request_recording_f) { std::set<const char*,ltstr>::const_iterator it = Other._internal_string_container.begin(); const std::set<const char*,ltstr>::const_iterator end = Other._internal_string_container.end(); for (; it != end; ++it) { const char* otherstr = *it; char* newcopy = new char[strlen(otherstr)+1]; strncpy(newcopy, otherstr, strlen(otherstr)+1); this->_internal_string_container.insert(newcopy); } }
| GETPOT_NAMESPACE::GetPot::GetPot | ( | const int | argc_, |
| const char *const * | argv_, | ||
| const char * | FieldSeparator = 0x0 |
||
| ) | [inline] |
Definition at line 712 of file getpot.h.
References parse_command_line().
: // leave 'char**' non-const to honor less capable compilers ... prefix(), section(), section_list(), argv(), cursor(), search_loop_f(), search_failed_f(), nominus_cursor(), idx_nominus(), variables(), _comment_start(), _comment_end(), _field_separator(), #if !defined(GETPOT_DISABLE_MUTEX) _getpot_mtx(), #endif _internal_string_container(), _requested_arguments(), _requested_variables(), _requested_sections(), request_recording_f() { this->parse_command_line(argc_, argv_, FieldSeparator); }
| GETPOT_NAMESPACE::GetPot::GetPot | ( | const char * | FileName, |
| const char * | CommentStart = 0x0, |
||
| const char * | CommentEnd = 0x0, |
||
| const char * | FieldSeparator = 0x0 |
||
| ) | [inline] |
Definition at line 773 of file getpot.h.
References parse_input_file().
: prefix(), section(), section_list(), argv(), cursor(), search_loop_f(), search_failed_f(), nominus_cursor(), idx_nominus(), variables(), _comment_start(), _comment_end(), _field_separator(), #if !defined(GETPOT_DISABLE_MUTEX) _getpot_mtx(), #endif _internal_string_container(), _requested_arguments(), _requested_variables(), _requested_sections(), request_recording_f() { const std::string& StrCommentStart = CommentStart ? CommentStart : std::string("#"); const std::string& StrCommentEnd = CommentEnd ? CommentEnd : std::string("\n"); const std::string& StrFieldSeparator = FieldSeparator ? FieldSeparator : std::string(" \t\n"); this->parse_input_file(FileName, StrCommentStart, StrCommentEnd, StrFieldSeparator); }
| 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 807 of file getpot.h.
References parse_input_file().
: prefix(), section(), section_list(), argv(), cursor(), search_loop_f(), search_failed_f(), nominus_cursor(), idx_nominus(), variables(), _comment_start(), _comment_end(), _field_separator(), #if !defined(GETPOT_DISABLE_MUTEX) _getpot_mtx(), #endif _internal_string_container(), _requested_arguments(), _requested_variables(), _requested_sections(), request_recording_f() { this->parse_input_file(FileName, CommentStart, CommentEnd, FieldSeparator); }
| GETPOT_NAMESPACE::GetPot::~GetPot | ( | ) | [inline] |
Definition at line 910 of file getpot.h.
References _internal_string_container, and end.
{
// may be some return strings had to be created, delete now !
std::set<const char*, ltstr>::const_iterator it = _internal_string_container.begin();
const std::set<const char*, ltstr>::const_iterator end = _internal_string_container.end();
for (; it != end; ++it)
delete [] *it;
}
| void GETPOT_NAMESPACE::GetPot::_basic_initialization | ( | ) | [inline, private] |
Definition at line 660 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().
{
cursor = 0;
nominus_cursor = -1;
search_failed_f = true;
search_loop_f = true;
prefix = "";
section = "";
// automatic request recording for later ufo detection
request_recording_f = true;
// comment start and end strings
_comment_start = std::string("#");
_comment_end = std::string("\n");
// default: separate vector elements by whitespaces
_field_separator = " \t\n";
}
| bool GETPOT_NAMESPACE::GetPot::_check_flags | ( | const std::string & | Str, |
| const char * | FlagList | ||
| ) | const [inline, private] |
support search for flags in a specific argument
Definition at line 2063 of file getpot.h.
Referenced by argument_contains(), and options_contain().
{
for (const char* p=FlagList; *p != '\0' ; p++)
if (Str.find(*p) != std::string::npos)
return true; // found something
return false;
}
| static std::string GETPOT_NAMESPACE::GetPot::_convert_from_type | ( | const T & | Value | ) | [inline, static, private] |
Definition at line 630 of file getpot.h.
Referenced by _DBE_expand().
{
std::ostringstream out_string;
out_string << Value;
return out_string.str();
}
| T GETPOT_NAMESPACE::GetPot::_convert_to_type | ( | const std::string & | String, |
| const T & | Default | ||
| ) | const [inline, private] |
type conversion if possible
Definition at line 1475 of file getpot.h.
Referenced by _DBE_expand(), direct_follow(), get(), next(), and operator()().
{
std::istringstream in_string(String);
T retval;
in_string >> retval;
if (in_string.fail())
retval = Default;
return retval;
}
| std::string GETPOT_NAMESPACE::GetPot::_convert_to_type | ( | const std::string & | String, |
| const char * | Default | ||
| ) | const [inline, private] |
| std::string GETPOT_NAMESPACE::GetPot::_convert_to_type | ( | const std::string & | String, |
| const std::string & | |||
| ) | const [inline] |
| bool GETPOT_NAMESPACE::GetPot::_convert_to_type | ( | const std::string & | String, |
| const bool & | Default | ||
| ) | const [inline, private] |
Definition at line 1509 of file getpot.h.
{
std::string newstring(String);
//std::transform(newstring.begin(), newstring.end(), newstring.begin(), std::toupper);
for (unsigned int i=0; i<newstring.length(); ++i)
newstring[i] = getpot_cast_int<char>(toupper(newstring[i]));
// "true"/"True"/"TRUE" should work
if (newstring.find("TRUE")!=std::string::npos)
return true;
if (newstring.find("FALSE")!=std::string::npos)
return false;
// And if we don't find that, let's search for an integer and use C unsigned
// int->bool conversion before giving up; i.e. a user could specify "0" for
// false or "1" for true
std::istringstream in_string(String);
unsigned int retval;
in_string >> retval;
if (in_string.fail())
return Default;
return retval;
}
| 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 1540 of file getpot.h.
References libMesh::Quality::name().
Referenced by get_value_no_default().
{
std::istringstream in_string(String);
T retval;
in_string >> retval;
if (in_string.fail())
{
getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
getpot_cerr <<" value = "<<String<<" expected type = "<<typeid(T).name()<<std::endl;
getpot_error();
}
return retval;
}
| std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default | ( | const char * | VarName, |
| const std::string & | String, | ||
| const char * | Default | ||
| ) | const [inline, private] |
| std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default | ( | const char * | , |
| const std::string & | String, | ||
| const std::string & | |||
| ) | const [inline] |
| bool GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default | ( | const char * | VarName, |
| const std::string & | String, | ||
| const bool & | |||
| ) | const [inline, private] |
Definition at line 1578 of file getpot.h.
References libMesh::Quality::name().
{
std::string newstring(String);
//std::transform(newstring.begin(), newstring.end(), newstring.begin(), std::toupper);
for (unsigned int i=0; i<newstring.length(); ++i)
{
newstring[i]=getpot_cast_int<char>(toupper(newstring[i]));
}
// "true"/"True"/"TRUE" should work
if (newstring.find("TRUE")!=std::string::npos)
return true;
if (newstring.find("FALSE")!=std::string::npos)
return false;
// And if we don't find that, let's search for an integer and use C unsigned
// int->bool conversion before giving up; i.e. a user could specify "0" for
// false or "1" for true
std::istringstream in_string(String);
unsigned int retval;
in_string >> retval;
if (in_string.fail())
{
getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
getpot_cerr <<" value = "<<String<<" expected type = "<<typeid(bool).name()<<std::endl;
getpot_error();
}
return retval;
}
| std::string GETPOT_NAMESPACE::GetPot::_DBE_expand | ( | const std::string & | str | ) | [inline, private] |
Definition at line 2784 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(), size(), and x.
Referenced by _DBE_expand_string(), and _DBE_get_expr_list().
{
// ${: } pure text
if (expr[0] == ':')
return expr.substr(1);
// ${& expr expr ... } text concatination
else if (expr[0] == '&')
{
const STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 1);
STRING_VECTOR::const_iterator it = A.begin();
std::string result = *it++;
for (; it != A.end(); ++it) result += *it;
return result;
}
// ${<-> expr expr expr} text replacement
else if (expr.length() >= 3 && expr.substr(0, 3) == "<->")
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(3), 3);
size_t tmp = 0;
const size_t L = A[1].length();
while ((tmp = A[0].find(A[1])) != std::string::npos)
A[0].replace(tmp, L, A[2]);
return A[0];
}
// ${=func [expr...] } function evaluation
else if (expr.length() >= 2 &&
expr.substr(0, 1) == "=" &&
expr.substr(0, 2) != "==")
{
size_t funcnamestart = expr.find_first_not_of(" \t", 1);
if (funcnamestart != std::string::npos)
{
size_t funcnameend = expr.find_first_of(" \t",funcnamestart);
std::string funcname = expr.substr(funcnamestart,
funcnameend-funcnamestart);
if (funcname == "log")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::log(arg));
}
else if (funcname == "log10")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::log10(arg));
}
else if (funcname == "exp")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::exp(arg));
}
else if (funcname == "sin")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::sin(arg));
}
else if (funcname == "cos")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::cos(arg));
}
else if (funcname == "tan")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::tan(arg));
}
else if (funcname == "asin")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::asin(arg));
}
else if (funcname == "acos")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::acos(arg));
}
else if (funcname == "atan")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::atan(arg));
}
else if (funcname == "atan2")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 2);
double arg1 = _convert_to_type(A[0], 0.0);
double arg2 = _convert_to_type(A[1], 0.0);
return _convert_from_type(std::atan2(arg1, arg2));
}
else if (funcname == "sinh")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::sinh(arg));
}
else if (funcname == "cosh")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::cosh(arg));
}
else if (funcname == "tanh")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::tanh(arg));
}
#ifdef HAVE_INVERSE_HYPERBOLIC_SINE
else if (funcname == "asinh")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::asinh(arg));
}
#endif
#ifdef HAVE_INVERSE_HYPERBOLIC_COSINE
else if (funcname == "acosh")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::acosh(arg));
}
#endif
#ifdef HAVE_INVERSE_HYPERBOLIC_TANGENT
else if (funcname == "atanh")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::atanh(arg));
}
#endif
else if (funcname == "sqrt")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::sqrt(arg));
}
else if (funcname == "abs")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::abs(arg));
}
else if (funcname == "max")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
for (; it != A.end(); ++it)
result = std::max(result, _convert_to_type(*it, 0.0));
return _convert_from_type(result);
}
else if (funcname == "min")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
for (; it != A.end(); ++it)
result = std::min(result, _convert_to_type(*it, 0.0));
return _convert_from_type(result);
}
else if (funcname == "ceil")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::ceil(arg));
}
else if (funcname == "floor")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
double arg = _convert_to_type(A[0], 0.0);
return _convert_from_type(std::floor(arg));
}
else if (funcname == "fmod")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 2);
double arg1 = _convert_to_type(A[0], 0.0);
double arg2 = _convert_to_type(A[1], 0.0);
return _convert_from_type(std::fmod(arg1, arg2));
}
else if (funcname == "srand")
{
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
unsigned int arg = _convert_to_type(A[0], 0u);
std::srand(arg);
return A[0];
}
// ${=rand range} with default range==RAND_MAX
else if (funcname == "rand")
{
if (funcnameend >= expr.length() ||
expr.find_first_not_of(" \t", funcnameend) == std::string::npos)
return _convert_from_type(std::rand());
STRING_VECTOR A =
_DBE_get_expr_list(expr.substr(funcnameend), 1);
unsigned int range = _convert_to_type(A[0],0u);
if (!range)
return _convert_from_type(0);
const unsigned int x = (RAND_MAX + 1u) / range;
const unsigned int y = x * range;
unsigned int returnval;
do
{
returnval = rand();
} while (returnval >= y);
return _convert_from_type(returnval / x);
}
else if (funcname == "time")
return _convert_from_type(std::time(NULL));
else
{
getpot_cerr << "ERROR: unrecognized function "
<< funcname << std::endl;
getpot_error();
}
}
}
// ${+ ...}, ${- ...}, ${* ...}, ${/ ...} expressions
else if (expr[0] == '+')
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
for (; it != A.end(); ++it)
result += _convert_to_type(*it, 0.0);
return _convert_from_type(result);
}
else if (expr[0] == '-')
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
for (; it != A.end(); ++it)
result -= _convert_to_type(*it, 0.0);
return _convert_from_type(result);
}
else if (expr[0] == '*')
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
for (; it != A.end(); ++it)
result *= _convert_to_type(*it, 0.0);
return _convert_from_type(result);
}
else if (expr[0] == '/')
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
if (result == 0)
return "0.0";
for (; it != A.end(); ++it)
{
const double Q = _convert_to_type(*it, 0.0);
result /= Q;
}
return _convert_from_type(result);
}
// ${^ ... } power expressions
else if (expr[0] == '^')
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
STRING_VECTOR::const_iterator it = A.begin();
double result = _convert_to_type(*it++, 0.0);
for (; it != A.end(); ++it)
result = pow(result, _convert_to_type(*it, 0.0));
return _convert_from_type(result);
}
// ${== } ${<= } ${>= } comparisons (return the number of the first 'match'
else if (expr.length() >= 2 &&
(expr.substr(0,2) == "==" || expr.substr(0,2) == ">=" ||
expr.substr(0,2) == "<=" || expr[0] == '>' || expr[0] == '<'))
{
// differentiate between two and one sign operators
unsigned op = 0;
enum { EQ, GEQ, LEQ, GT, LT };
if (expr.substr(0, 2) == "==")
op = EQ;
else if (expr.substr(0, 2) == ">=")
op = GEQ;
else if (expr.substr(0, 2) == "<=")
op = LEQ;
else if (expr[0] == '>')
op = GT;
else
op = LT;
STRING_VECTOR a;
if (op == GT || op == LT)
a = _DBE_get_expr_list(expr.substr(1), 2);
else
a = _DBE_get_expr_list(expr.substr(2), 2);
std::string x_orig = a[0];
double x = _convert_to_type(x_orig, 1e37);
unsigned i = 1;
STRING_VECTOR::const_iterator y_orig = a.begin();
for (y_orig++; y_orig != a.end(); ++y_orig)
{
double y = _convert_to_type(*y_orig, 1e37);
// set the strings as reference if one wasn't a number
if (x == 1e37 || y == 1e37)
{
// it's a string comparison
if ((op == EQ && x_orig == *y_orig) || (op == GEQ && x_orig >= *y_orig) ||
(op == LEQ && x_orig <= *y_orig) || (op == GT && x_orig > *y_orig) ||
(op == LT && x_orig < *y_orig))
return _convert_from_type(i);
}
else
{
// it's a number comparison
if ((op == EQ && x == y) || (op == GEQ && x >= y) ||
(op == LEQ && x <= y) || (op == GT && x > y) ||
(op == LT && x < y))
return _convert_from_type(i);
}
i++;
}
// nothing fulfills the condition => return 0
return "0";
}
// ${?? expr expr} select
else if (expr.length() >= 2 && expr.substr(0, 2) == "??")
{
STRING_VECTOR a = _DBE_get_expr_list(expr.substr(2), 2);
double x = _convert_to_type(a[0], 1e37);
// last element is always the default argument
if (x == 1e37 || x < 0 || x >= a.size() - 1)
return a[a.size()-1];
// round x to closest integer
return a[int(x+0.5)];
}
// ${? expr expr expr} if then else conditions
else if (expr[0] == '?')
{
STRING_VECTOR a = _DBE_get_expr_list(expr.substr(1), 2);
if (_convert_to_type(a[0], 0.0) == 1.0)
return a[1];
else if (a.size() > 2)
return a[2];
}
// ${! expr} maxro expansion
else if (expr[0] == '!')
{
const GetPot::variable* Var = _DBE_get_variable(expr.substr(1));
// error
if (Var->name == "")
return std::string(Var->original);
const STRING_VECTOR A = _DBE_get_expr_list(Var->original, 2);
return A[0];
}
// ${@: } - string subscription
else if (expr.length() >= 2 && expr.substr(0,2) == "@:")
{
const STRING_VECTOR A = _DBE_get_expr_list(expr.substr(2), 2);
double x = _convert_to_type(A[1], 1e37);
// last element is always the default argument
if (x == 1e37 || x < 0 || x >= A[0].size() - 1)
return "<<1st index out of range>>";
if (A.size() > 2)
{
double y = _convert_to_type(A[2], 1e37);
if (y != 1e37 && y > 0 && y <= A[0].size() - 1 && y > x)
return A[0].substr(int(x+0.5), int(y+1.5) - int(x+0.5));
else if (y == -1)
return A[0].substr(int(x+0.5));
return "<<2nd index out of range>>";
}
else
{
char* tmp = new char[2];
tmp[0] = A[0][int(x+0.5)]; tmp[1] = '\0';
std::string result(tmp);
delete [] tmp;
return result;
}
}
// ${@ } - vector subscription
else if (expr[0] == '@')
{
STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
const GetPot::variable* Var = _DBE_get_variable(A[0]);
// error
if (Var->name == "")
{
// make a copy of the string if an error occured
// (since the error variable is a static variable inside get_variable())
return std::string(Var->original);
}
double x = _convert_to_type(A[1], 1e37);
// last element is always the default argument
if (x == 1e37 || x < 0 || x >= Var->value.size())
return "<<1st index out of range>>";
if (A.size() > 2)
{
double y = _convert_to_type(A[2], 1e37);
int begin = int(x+0.5);
int end = 0;
if (y != 1e37 && y > 0 && y <= Var->value.size() && y > x)
end = int(y+1.5);
else if (y == -1)
end = int(Var->value.size());
else
return "<<2nd index out of range>>";
std::string result = *(Var->get_element(begin));
for (int i = begin+1; i < end; i++)
result += std::string(" ") + *(Var->get_element(i));
return result;
}
else
return *(Var->get_element(int(x+0.5)));
}
const STRING_VECTOR A = _DBE_get_expr_list(expr, 1);
const GetPot::variable* B = _DBE_get_variable(A[0]);
// make a copy of the string if an error occured
// (since the error variable is a static variable inside get_variable())
if (B->name == "")
return std::string(B->original);
// (psuggs@pobox.com mentioned to me the warning MSVC++6.0 produces
// with: else return B->original (thanks))
return B->original;
}
| std::string GETPOT_NAMESPACE::GetPot::_DBE_expand_string | ( | const std::string & | str | ) | [inline, private] |
dollar bracket expressions
Definition at line 2626 of file getpot.h.
References _DBE_expand().
Referenced by _parse_argument_vector().
{
// Parses for closing operators '${ }' and expands them letting
// white spaces and other letters as they are.
std::string new_string = "";
unsigned open_brackets = 0;
unsigned first = 0;
for (unsigned i = 0; i<str.size(); i++)
{
if (i < str.size() - 2 && str.substr(i, 2) == "${")
{
if (open_brackets == 0)
first = i+2;
open_brackets++;
}
else if (str[i] == '}' && open_brackets > 0)
{
open_brackets -= 1;
if (open_brackets == 0)
{
const std::string Replacement = _DBE_expand(str.substr(first, i - first));
new_string += Replacement;
}
}
else if (open_brackets == 0)
new_string += str[i];
}
return new_string;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::_DBE_get_expr_list | ( | const std::string & | str, |
| const unsigned | ExpectedNumber | ||
| ) | [inline, private] |
Definition at line 2659 of file getpot.h.
References _DBE_expand().
Referenced by _DBE_expand().
{
// ensures that the resulting vector has the expected number
// of arguments, but they may contain an error message
std::string str = str_;
// Separates expressions by non-bracketed whitespaces, expands them
// and puts them into a list.
unsigned i=0;
// (1) eat initial whitespaces
for (; i < str.size(); i++)
if (!isspace(str[i]))
break;
STRING_VECTOR expr_list;
unsigned open_brackets = 0;
std::vector<unsigned> start_idx;
unsigned start_new_string = i;
unsigned l = (unsigned)(str.size());
// (2) search for ${ } expressions ...
while (i < l)
{
const char letter = str[i];
// whitespace -> end of expression
if (isspace(letter) && open_brackets == 0)
{
expr_list.push_back(str.substr(start_new_string, i - start_new_string));
bool no_breakout_f = true;
for (i++; i < l ; i++)
{
if (!isspace(str[i]))
{
no_breakout_f = false;
start_new_string = i;
break;
}
}
if (no_breakout_f)
{
// end of expression list
if (expr_list.size() < ExpectedNumber)
{
const std::string pre_tmp("<< ${ }: missing arguments>>");
STRING_VECTOR tmp(ExpectedNumber - expr_list.size(), pre_tmp);
expr_list.insert(expr_list.end(), tmp.begin(), tmp.end());
}
return expr_list;
}
}
// dollar-bracket expression
if (str.length() >= i+2 && str.substr(i, 2) == "${")
{
open_brackets++;
start_idx.push_back(i+2);
}
else if (letter == '}' && open_brackets > 0)
{
int start = start_idx[start_idx.size()-1];
start_idx.pop_back();
const std::string Replacement = _DBE_expand(str.substr(start, i-start));
if (start - 3 < (int)0)
str = Replacement + str.substr(i+1);
else
str = str.substr(0, start-2) + Replacement + str.substr(i+1);
l = (int)(str.size());
i = start + (int)(Replacement.size()) - 3;
open_brackets--;
}
i++;
}
// end of expression list
expr_list.push_back(str.substr(start_new_string, i-start_new_string));
if (expr_list.size() < ExpectedNumber)
{
const std::string pre_tmp("<< ${ }: missing arguments>>");
STRING_VECTOR tmp(ExpectedNumber - expr_list.size(), pre_tmp);
expr_list.insert(expr_list.end(), tmp.begin(), tmp.end());
}
return expr_list;
}
| const GetPot::variable * GETPOT_NAMESPACE::GetPot::_DBE_get_variable | ( | const std::string & | str | ) | [inline, private] |
Definition at line 2750 of file getpot.h.
References _request_variable(), GETPOT_NAMESPACE::GetPot::variable::original, prefix, and section.
Referenced by _DBE_expand().
{
static GetPot::variable ev;
std::string secure_Prefix = prefix;
prefix = section;
// (1) first search in currently active section
const GetPot::variable* var = _request_variable(VarName.c_str());
if (var != 0)
{
prefix = secure_Prefix;
return var;
}
// (2) search in root name space
prefix = "";
var = _request_variable(VarName.c_str());
if (var != 0)
{
prefix = secure_Prefix;
return var;
}
prefix = secure_Prefix;
// error occured => variable name == ""
ev.original = "<<${ } variable '";
ev.original += VarName + "' undefined>>";
return &ev;
}
| const GetPot::variable * GETPOT_NAMESPACE::GetPot::_find_variable | ( | const char * | VarName | ) | const [inline, private] |
helpers for argument list processing search for a variable in 'variables' array
Definition at line 2513 of file getpot.h.
References prefix, and variables.
Referenced by _request_variable(), and _set_variable().
| const std::string GETPOT_NAMESPACE::GetPot::_get_next_token | ( | std::istream & | istr | ) | [inline, private] |
Definition at line 1274 of file getpot.h.
References _get_string(), _get_until_closing_bracket(), and _get_until_closing_square_bracket().
Referenced by _read_in_stream().
{
// get next concatenates string token. consider quotes that embrace
// whitespaces
std::string token;
int tmp = 0;
while (true)
{
int last_letter = tmp;
tmp = istr.get();
if (tmp == '=')
{
// Always break at '='.
// This separates '=' at the beginning of a word into its own word.
token += getpot_cast_int<char>(tmp);
return token;
}
else if (tmp == EOF || ((tmp == ' ' || tmp == '\t' || tmp == '\n') && last_letter != '\\'))
return token;
else if (tmp == '\'' && last_letter != '\\')
{
// QUOTES: un-backslashed quotes => it's a string
token += _get_string(istr);
continue;
}
else if (tmp == '{' && last_letter == '$')
{
token += '{' + _get_until_closing_bracket(istr);
continue;
}
else if (tmp == '[')
{
token += '[' + _get_until_closing_square_bracket(istr);
continue;
}
else if (tmp == '$' && last_letter == '\\')
{
token += getpot_cast_int<char>(tmp); tmp = 0; // so that last_letter will become = 0, not '$';
continue;
}
else if (tmp == '\\' && last_letter != '\\')
continue; // don't append un-backslashed backslashes
token += getpot_cast_int<char>(tmp);
}
}
| const std::string GETPOT_NAMESPACE::GetPot::_get_remaining_string | ( | const std::string & | String, |
| const std::string & | Start | ||
| ) | const [inline, private] |
prefix extraction
Definition at line 1644 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().
{
if (Start == "")
return String;
// note: java.lang.String: substring(a,b) = from a to b-1
// C++ string: substr(a,b) = from a to a + b
if (String.find(Start) == 0)
return String.substr(Start.length());
else
return "";
}
| static STRING_VECTOR GETPOT_NAMESPACE::GetPot::_get_section_tree | ( | const std::string & | FullPath | ) | [inline, static, private] |
cuts a variable name into a tree of sub-sections. this is requested for recording requested sections when dealing with 'ufo' detection.
Definition at line 641 of file getpot.h.
Referenced by _record_argument_request(), and _record_variable_request().
{
STRING_VECTOR result;
for (std::size_t pos = 0; pos != FullPath.size(); ++pos)
{
if (FullPath[pos] == '/')
result.push_back(FullPath.substr(0,pos));
}
return result;
}
| const std::string GETPOT_NAMESPACE::GetPot::_get_string | ( | std::istream & | istr | ) | [inline, private] |
Definition at line 1331 of file getpot.h.
Referenced by _get_next_token().
{
// parse input until next matching '
std::string str;
int tmp = 0;
while (true)
{
int last_letter = tmp;
tmp = istr.get();
if (tmp == EOF)
return str;
// un-backslashed quotes => it's the end of the string
else if (tmp == '\'' && last_letter != '\\')
return str;
else if (tmp == '\\' && last_letter != '\\')
continue; // don't append
str += getpot_cast_int<char>(tmp);
}
}
| const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_bracket | ( | std::istream & | istr | ) | [inline, private] |
Definition at line 1357 of file getpot.h.
Referenced by _get_next_token().
{
// parse input until next matching }
std::string str = "";
int tmp = 0;
int brackets = 1;
while (true)
{
int last_letter = tmp;
tmp = istr.get();
if (tmp == EOF)
return str;
else if (tmp == '{' && last_letter == '$')
brackets += 1;
else if (tmp == '}')
{
brackets -= 1;
// un-backslashed brackets => it's the end of the string
if (brackets == 0)
return str + '}';
else if (tmp == '\\' && last_letter != '\\')
continue; // do not append an unbackslashed backslash
}
str += getpot_cast_int<char>(tmp);
}
}
| const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_square_bracket | ( | std::istream & | istr | ) | [inline, private] |
Definition at line 1390 of file getpot.h.
Referenced by _get_next_token().
{
// parse input until next matching ]
std::string str = "";
int brackets = 1;
while (true)
{
int tmp = istr.get();
if (tmp == EOF)
return str;
else if (tmp == '[')
brackets += 1;
else if (tmp == ']')
{
brackets -= 1;
if (brackets == 0)
return str + ']';
}
str += getpot_cast_int<char>(tmp);
}
}
| const char * GETPOT_NAMESPACE::GetPot::_internal_managed_copy | ( | const std::string & | Arg | ) | const [inline, private] |
some functions return a char pointer to a temporarily existing string this function adds them to our container
Definition at line 1613 of file getpot.h.
References _internal_string_container.
Referenced by direct_follow(), follow(), get_value_no_default(), next(), next_nominus(), and operator()().
{
const char* arg = Arg.c_str();
// Get a lock before touching anything mutable
SCOPED_MUTEX;
// See if there's already an identical string saved
std::set<const char*,ltstr>::const_iterator it =
_internal_string_container.find(arg);
// If so, return it
if (it != _internal_string_container.end())
return *it;
// Otherwise, create a new one
char* newcopy = new char[strlen(arg)+1];
strncpy(newcopy, arg, strlen(arg)+1);
_internal_string_container.insert(newcopy);
return newcopy;
}
| const char * GETPOT_NAMESPACE::GetPot::_match_starting_string | ( | const char * | StartString | ) | [inline, private] |
support finding directly followed arguments
Definition at line 1965 of file getpot.h.
References argv, cursor, search_failed_f, and search_loop_f.
Referenced by direct_follow().
{
const unsigned N =
getpot_cast_int<unsigned>(strlen(StartString));
unsigned OldCursor = cursor;
if (OldCursor >= argv.size())
OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
search_failed_f = true;
// (*) first loop from cursor position until end
for (unsigned c = cursor; c < argv.size(); c++)
{
if (strncmp(StartString, argv[c].c_str(), N) == 0)
{
cursor = c;
search_failed_f = false;
return &(argv[c].c_str()[N]);
}
}
if (!search_loop_f)
return NULL;
// (*) second loop from 0 to old cursor position
for (unsigned c = 1; c < OldCursor; c++)
{
if (strncmp(StartString, argv[c].c_str(), N) == 0)
{
cursor = c;
search_failed_f = false;
return &(argv[c].c_str()[N]);
}
}
return 0;
}
| void GETPOT_NAMESPACE::GetPot::_parse_argument_vector | ( | const STRING_VECTOR & | ARGV | ) | [inline, private] |
produce three basic data vectors:
Definition at line 1021 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().
{
if (ARGV.empty())
return;
// build internal databases:
// 1) array with no-minus arguments (usually used as filenames)
// 2) variable assignments:
// 'variable name' '=' number | string
STRING_VECTOR section_stack;
STRING_VECTOR::const_iterator it = ARGV.begin();
section = "";
// -- do not parse the first argument, so that this parsing source
// name is not interpreted a s a nominus or so. If we already
// have parsed arguments, don't bother adding another parsing
// source name
if (argv.empty())
argv.push_back(*it);
++it;
// -- loop over remaining arguments
for (; it != ARGV.end(); ++it)
{
std::string arg = *it;
if (arg.length() == 0)
continue;
// -- [section] labels and [include file] directives
if (arg.length() > 1 && arg[0] == '[' && arg[arg.length()-1] == ']')
{
// Is this an include file directive?
std::size_t include_pos = arg.find("include ", 1);
if (include_pos != std::string::npos)
{
const std::string includefile =
_DBE_expand_string(arg.substr(9, arg.length()-9-include_pos));
this->parse_input_file
(includefile, _comment_start, _comment_end, _field_separator);
}
else
{
// (*) sections are considered 'requested arguments'
if (request_recording_f)
{
// Get a lock before touching anything mutable
SCOPED_MUTEX;
_requested_arguments.insert(arg);
}
const std::string Name = _DBE_expand_string(arg.substr(1, arg.length()-2));
section = _process_section_label(Name, section_stack);
// new section --> append to list of sections
if (find(section_list.begin(), section_list.end(), section) == section_list.end())
if (section.length() != 0) section_list.push_back(section);
argv.push_back(arg);
}
}
else
{
arg = section + _DBE_expand_string(arg);
argv.push_back(arg);
}
// -- separate array for nominus arguments
if (arg[0] != '-')
idx_nominus.push_back(getpot_cast_int<unsigned>(argv.size()-1));
// -- variables: does arg contain a '=' operator ?
const std::size_t equals_pos = arg.find_first_of('=');
if (equals_pos != std::string::npos)
{
// (*) record for later ufo detection
// arguments carriying variables are always treated as 'requested' arguments.
// unrequested variables have to be detected with the ufo-variable
// detection routine.
if (request_recording_f)
{
// Get a lock before touching anything mutable
SCOPED_MUTEX;
_requested_arguments.insert(arg);
}
// => arg (from start to '=') = Name of variable
// (from '=' to end) = value of variable
_set_variable(arg.substr(0,equals_pos),
arg.substr(equals_pos+1), false);
}
}
}
| std::string GETPOT_NAMESPACE::GetPot::_process_section_label | ( | const std::string & | Section, |
| STRING_VECTOR & | section_stack | ||
| ) | [inline, private] |
Definition at line 1418 of file getpot.h.
Referenced by _parse_argument_vector().
{
std::string sname = Section;
// 1) subsection of actual section ('./' prefix)
if (sname.length() >= 2 && sname.substr(0, 2) == "./")
sname = sname.substr(2);
// 2) subsection of parent section ('../' prefix)
else if (sname.length() >= 3 && sname.substr(0, 3) == "../")
{
do
{
if (section_stack.end() != section_stack.begin())
section_stack.pop_back();
sname = sname.substr(3);
} while (sname.substr(0, 3) == "../");
}
// 3) subsection of the root-section
else
// [] => back to root section
section_stack.erase(section_stack.begin(), section_stack.end());
if (sname != "")
{
// parse section name for 'slashes'
unsigned i=0;
while (i < sname.length())
{
if (sname[i] == '/')
{
section_stack.push_back(sname.substr(0,i));
if (i+1 < sname.length())
sname = sname.substr(i+1);
i = 0;
}
else
i++;
}
section_stack.push_back(sname);
}
std::string section_label = "";
if (!section_stack.empty())
{
victorate(std::string, section_stack, it)
section_label += *it + "/";
}
return section_label;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::_read_in_file | ( | const std::string & | FileName | ) | [inline, private] |
Definition at line 1124 of file getpot.h.
References _read_in_stream().
Referenced by parse_input_file().
{
std::ifstream i(FileName.c_str());
// if (!i) return STRING_VECTOR();
if (!i)
libmesh_file_error(FileName);
// argv[0] == the filename of the file that was read in
return _read_in_stream(i);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::_read_in_stream | ( | std::istream & | istr | ) | [inline, private] |
Definition at line 1140 of file getpot.h.
References _comment_start, _get_next_token(), and _skip_whitespace().
Referenced by _read_in_file().
{
STRING_VECTOR brute_tokens;
while (istr)
{
_skip_whitespace(istr);
const std::string Token = _get_next_token(istr);
// Allow 'keyword =' to parse with an empty string as value.
// Only break at EOF.
// if (Token.length() == 0 || Token[0] == EOF) break;
if (Token[0] == EOF)
break;
brute_tokens.push_back(Token);
}
// -- reduce expressions of token1'='token2 to a single
// string 'token1=token2'
// -- copy everything into 'argv'
// -- arguments preceded by something like '[' name ']' (section)
// produce a second copy of each argument with a prefix '[name]argument'
unsigned i1 = 0;
unsigned i2 = 1;
unsigned i3 = 2;
STRING_VECTOR arglist;
while (i1 < brute_tokens.size())
{
// 1) concatenate 'abcdef' '=' 'efgasdef' to 'abcdef=efgasdef'
// note: java.lang.String: substring(a,b) = from a to b-1
// C++ string: substr(a,b) = from a to a + b
std::string result;
if (i2 < brute_tokens.size() && brute_tokens[i2] == "=")
{
if (i3 >= brute_tokens.size())
result = brute_tokens[i1] + brute_tokens[i2];
else
result = brute_tokens[i1] + brute_tokens[i2] + brute_tokens[i3];
i1 = i3+1; i2 = i3+2; i3 = i3+3;
}
else if (i2 < brute_tokens.size() &&
brute_tokens[i2].length() > 0 &&
brute_tokens[i2][0] == '=')
{
// This case should not be hit if '=' at the beginning of a word
// is always separated into its own word
result = brute_tokens[i1] + brute_tokens[i2];
i1 = i3; i2 = i3+1; i3 = i3+2;
}
else if (i2 < brute_tokens.size() && brute_tokens[i1][brute_tokens[i1].size()-1] == '=')
{
result = brute_tokens[i1] + brute_tokens[i2];
i1 = i3; i2 = i3+1; i3 = i3+2;
}
else
{
result = brute_tokens[i1];
i1=i2; i2=i3; i3++;
}
// Now strip out any comment
size_t comment_start_loc = result.find(_comment_start, 0);
if (comment_start_loc != std::string::npos)
result = result.substr(0, comment_start_loc);
arglist.push_back(result);
}
return arglist;
}
| void GETPOT_NAMESPACE::GetPot::_record_argument_request | ( | const std::string & | Arg | ) | const [inline, private] |
if an argument is requested record it and the 'tag' the section branch to which it belongs. Caution: both functions mark the sections as 'tagged'. These are "const" functions but they do modify the mutable _requested_* members
Definition at line 2362 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(), next_nominus_string(), nominus_vector(), and search().
{
if (!request_recording_f)
return;
// Get a lock before touching anything mutable
SCOPED_MUTEX;
// (*) record requested variable for later ufo detection
_requested_arguments.insert(Name);
// (*) record considered section for ufo detection
STRING_VECTOR STree = _get_section_tree(Name);
victorate(std::string, STree, it)
if (_requested_sections.find(*it) == _requested_sections.end())
if (section.length() != 0)
_requested_sections.insert(*it);
}
| void GETPOT_NAMESPACE::GetPot::_record_variable_request | ( | const std::string & | Arg | ) | const [inline, private] |
Definition at line 2384 of file getpot.h.
References _get_section_tree(), _requested_sections, _requested_variables, request_recording_f, and section.
Referenced by _request_variable().
{
if (!request_recording_f)
return;
// Get a lock before touching anything mutable
SCOPED_MUTEX;
// (*) record requested variable for later ufo detection
_requested_variables.insert(Name);
// (*) record considered section for ufo detection
STRING_VECTOR STree = _get_section_tree(Name);
victorate(std::string, STree, it)
if (_requested_sections.find(*it) == _requested_sections.end())
if (section.length() != 0)
_requested_sections.insert(*it);
}
| const GetPot::variable * GETPOT_NAMESPACE::GetPot::_request_variable | ( | const char * | VarName | ) | const [inline, private] |
search (and record request) for a variable in 'variables' array
Definition at line 2529 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().
{
// (*) record requested variable for later ufo detection
this->_record_variable_request(VarName);
return this->_find_variable(VarName);
}
| bool GETPOT_NAMESPACE::GetPot::_search_string_vector | ( | const STRING_VECTOR & | Vec, |
| const std::string & | Str | ||
| ) | const [inline, private] |
| void GETPOT_NAMESPACE::GetPot::_set_variable | ( | const std::string & | VarName, |
| const std::string & | Value, | ||
| const bool | Requested | ||
| ) | [inline, private] |
helper functions set variable from inside GetPot (no prefix considered)
Definition at line 2408 of file getpot.h.
References _field_separator, _find_variable(), _request_variable(), overridden_vars, and variables.
Referenced by _parse_argument_vector(), and set().
{
const GetPot::variable* Var = Requested ?
_request_variable(VarName.c_str()) :
_find_variable(VarName.c_str());
if (Var == 0)
variables.push_back(variable(VarName.c_str(), Value.c_str(), _field_separator.c_str()));
else
{
overridden_vars.insert(VarName.c_str());
(const_cast<GetPot::variable*>(Var))->take(Value.c_str(), _field_separator.c_str());
}
}
| void GETPOT_NAMESPACE::GetPot::_skip_whitespace | ( | std::istream & | istr | ) | [inline, private] |
helpers to parse input file create an argument vector based on data found in an input file, i.e.: 1) delete comments (in between '_comment_start' '_comment_end') 2) contract assignment expressions, such as my-variable = '007 J. B.' into my-variable='007 J. B.' 3) interprete sections like '[../my-section]' etc.
Definition at line 1212 of file getpot.h.
References _comment_end, and _comment_start.
Referenced by _read_in_stream().
{
// find next non-whitespace while deleting comments
int tmp = istr.get();
do {
// -- search a non whitespace
while (isspace(tmp))
{
tmp = istr.get();
if (!istr)
return;
}
// -- look if characters match the comment starter string
for (unsigned i=0; i<_comment_start.length() ; i++)
{
if (tmp != _comment_start[i])
{
// -- one step more backwards, since 'tmp' already at non-whitespace
istr.unget();
return;
}
// RHS: Why is this here? It breaks on empty comments
// tmp = istr.get();
// if (!istr) { istr.unget(); return; }
}
// 'tmp' contains last character of _comment_starter
// -- comment starter found -> search for comment ender
unsigned match_no=0;
while (true)
{
tmp = istr.get();
if (!istr)
{
istr.unget();
return;
}
if (tmp == _comment_end[match_no])
{
match_no++;
if (match_no == _comment_end.length())
{
istr.unget();
break; // shuffle more whitespace, end of comment found
}
}
else
match_no = 0;
}
tmp = istr.get();
} while (istr);
istr.unget();
}
| void GETPOT_NAMESPACE::GetPot::absorb | ( | const GetPot & | Other | ) | [inline] |
absorbing contents of another GetPot object
Definition at line 978 of file getpot.h.
References _requested_arguments, _requested_sections, _requested_variables, argv, request_recording_f, and variables.
{
if (&Other == this)
return;
// variables that are not influenced by absorption:
// _comment_start
// _comment_end
// cursor
// nominus_cursor
// search_failed
// idx_nominus
// search_loop_f
argv = Other.argv;
variables = Other.variables;
if (request_recording_f)
{
// Get a lock before touching anything mutable
SCOPED_MUTEX;
_requested_arguments.insert(Other._requested_arguments.begin(), Other._requested_arguments.end());
_requested_variables.insert(Other._requested_variables.begin(), Other._requested_variables.end());
_requested_sections.insert(Other._requested_sections.begin(), Other._requested_sections.end());
}
}
| bool GETPOT_NAMESPACE::GetPot::argument_contains | ( | unsigned | Idx, |
| const char * | FlagList | ||
| ) | const [inline] |
Definition at line 2028 of file getpot.h.
References _check_flags(), _get_remaining_string(), _record_argument_request(), argv, and prefix.
{
if (Idx >= argv.size())
return false;
// (*) record requested of argument for later ufo-detection
// an argument that is checked for flags is considered to be 'requested'
_record_argument_request(argv[Idx]);
if (prefix == "")
// search argument for any flag in flag list
return _check_flags(argv[Idx], FlagList);
// if a prefix is set, then the argument index is the index
// inside the 'namespace'
// => only check list of arguments that start with prefix
unsigned no_matches = 0;
for (unsigned i=0; i<argv.size(); i++)
{
const std::string Remain = _get_remaining_string(argv[i], prefix);
if (Remain != "")
{
no_matches += 1;
if (no_matches == Idx)
return _check_flags(Remain, FlagList);
}
}
// no argument in this namespace
return false;
}
| void GETPOT_NAMESPACE::GetPot::clear_requests | ( | ) | [inline] |
for ufo detection: recording requested arguments, options etc.
Definition at line 1008 of file getpot.h.
References _requested_arguments, _requested_sections, and _requested_variables.
{
// Get a lock before touching anything mutable
SCOPED_MUTEX;
_requested_arguments.clear();
_requested_variables.clear();
_requested_sections.clear();
}
| T GETPOT_NAMESPACE::GetPot::direct_follow | ( | const T & | Default, |
| const char * | Option | ||
| ) | [inline] |
directly followed arguments
Definition at line 1936 of file getpot.h.
References _convert_to_type(), _match_starting_string(), _record_argument_request(), argv, and cursor.
Referenced by direct_follow().
{
const char* FollowStr = _match_starting_string(Option);
// (*) record requested of argument for later ufo-detection
_record_argument_request(std::string(Option) + FollowStr);
if (FollowStr == 0)
return Default;
if (++cursor >= argv.size())
cursor = getpot_cast_int<unsigned>(argv.size());
return _convert_to_type(FollowStr, Default);
}
| const char * GETPOT_NAMESPACE::GetPot::direct_follow | ( | const char * | Default, |
| const char * | Option | ||
| ) | [inline] |
Definition at line 1954 of file getpot.h.
References _internal_managed_copy(), and direct_follow().
{
return _internal_managed_copy(direct_follow(std::string(Default), Option));
}
| void GETPOT_NAMESPACE::GetPot::disable_loop | ( | ) | [inline] |
enable/disable search for an option in loop
Definition at line 304 of file getpot.h.
References search_loop_f.
Referenced by init_multiple_occurrence().
{ search_loop_f = false; }
| void GETPOT_NAMESPACE::GetPot::disable_request_recording | ( | ) | [inline] |
Definition at line 174 of file getpot.h.
References request_recording_f.
{ request_recording_f = false; }
| void GETPOT_NAMESPACE::GetPot::enable_loop | ( | ) | [inline] |
| void GETPOT_NAMESPACE::GetPot::enable_request_recording | ( | ) | [inline] |
Definition at line 175 of file getpot.h.
References request_recording_f.
{ request_recording_f = true; }
| T GETPOT_NAMESPACE::GetPot::follow | ( | const T & | Default, |
| const char * | Option | ||
| ) | [inline] |
| const char * GETPOT_NAMESPACE::GetPot::follow | ( | const char * | Default, |
| const char * | Option | ||
| ) | [inline] |
Definition at line 1866 of file getpot.h.
References _internal_managed_copy(), and follow().
{
return _internal_managed_copy(follow(std::string(Default), Option));
}
| T GETPOT_NAMESPACE::GetPot::follow | ( | const T & | Default, |
| unsigned | No, | ||
| const char * | Option, | ||
| ... | |||
| ) | [inline] |
search for one of the given options and get argument that follows it
| const char * GETPOT_NAMESPACE::GetPot::follow | ( | const char * | Default, |
| unsigned | No, | ||
| const char * | Option, | ||
| ... | |||
| ) | [inline] |
Definition at line 1904 of file getpot.h.
References next(), and search().
{
// (*) record requested of argument is entirely handled in 'search()' and 'next()'
if (No == 0)
return Default;
if (search(P) == true)
return next(Default);
va_list ap;
va_start(ap, P);
for (unsigned i=1; i<No; i++)
{
char* Opt = va_arg(ap, char *);
if (search(Opt) == true)
{
va_end(ap);
return next(Default);
}
}
va_end(ap);
return Default;
}
| T GETPOT_NAMESPACE::GetPot::follow | ( | const T & | Default, |
| unsigned int | No, | ||
| const char * | P, | ||
| ... | |||
| ) | [inline] |
Definition at line 1877 of file getpot.h.
References next(), and search().
{
// (*) record requested of argument is entirely handled in 'search()' and 'next()'
if (No == 0)
return Default;
if (search(P) == true)
return next(Default);
va_list ap;
va_start(ap, P);
for (unsigned i=1; i<No; i++)
{
char* Opt = va_arg(ap, char *);
if (search(Opt) == true)
{
va_end(ap);
return next(Default);
}
}
va_end(ap);
return Default;
}
| T GETPOT_NAMESPACE::GetPot::get | ( | unsigned | Idx, |
| const T & | Default | ||
| ) | const [inline] |
| const char* GETPOT_NAMESPACE::GetPot::get | ( | unsigned | Idx, |
| const char * | Default | ||
| ) | const [inline] |
| T GETPOT_NAMESPACE::GetPot::get | ( | unsigned int | Idx, |
| const T & | Default | ||
| ) | const [inline] |
Definition at line 1791 of file getpot.h.
References _convert_to_type(), and argv.
{
if (Idx >= argv.size())
return Default;
return _convert_to_type(argv[Idx], Default);
}
| std::set< std::string > GETPOT_NAMESPACE::GetPot::get_overridden_variables | ( | ) | const [inline] |
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_section_names | ( | ) | const [inline] |
| T GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const char * | VarName, |
| const T & | Default | ||
| ) | const [inline] |
access varibles, but error out if not present scalar values
Definition at line 2274 of file getpot.h.
References _convert_to_type_no_default(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::original.
Referenced by get_value_no_default().
{
// (*) recording of requested variables happens in '_request_variable()'
const variable* sv = _request_variable(VarName);
if (sv == 0)
{
getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
getpot_error();
}
return _convert_to_type_no_default(VarName, sv->original, Default);
}
| T GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const std::string & | VarName, |
| const T & | Default | ||
| ) | const [inline] |
Definition at line 2290 of file getpot.h.
References get_value_no_default().
{
return get_value_no_default(VarName.c_str(),Default);
}
| const char * GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const char * | VarName, |
| const char * | Default | ||
| ) | const [inline] |
Definition at line 2298 of file getpot.h.
References _internal_managed_copy(), and get_value_no_default().
{
return _internal_managed_copy(get_value_no_default(VarName, Default));
}
| const char * GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const std::string & | VarName, |
| const char * | Default | ||
| ) | const [inline] |
Definition at line 2306 of file getpot.h.
References get_value_no_default().
{
return get_value_no_default(VarName.c_str(),Default);
}
| T GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const char * | VarName, |
| const T & | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
vectors
| T GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const std::string & | VarName, |
| const T & | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
| const char* GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const char * | VarName, |
| const char * | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
| const char* GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const std::string & | VarName, |
| const char * | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
| T GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const char * | VarName, |
| const T & | Default, | ||
| unsigned int | Idx | ||
| ) | const [inline] |
Definition at line 2315 of file getpot.h.
References _convert_to_type_no_default(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::get_element().
{
// (*) recording of requested variables happens in '_request_variable()'
const variable* sv = _request_variable(VarName);
if (sv == 0)
{
getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
getpot_error();
}
const std::string* element = sv->get_element(Idx);
if (element == 0)
{
getpot_cerr << "ERROR: cannot find index "<<Idx<<" of variable "<<VarName<<std::endl;
getpot_error();
}
return _convert_to_type_no_default(VarName, *element, Default);
}
| T GETPOT_NAMESPACE::GetPot::get_value_no_default | ( | const std::string & | VarName, |
| const T & | Default, | ||
| unsigned int | Idx | ||
| ) | const [inline] |
Definition at line 2338 of file getpot.h.
References get_value_no_default().
{
return get_value_no_default(VarName.c_str(), Default, Idx);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_variable_names | ( | ) | const [inline] |
Definition at line 2481 of file getpot.h.
References _get_remaining_string(), prefix, and variables.
{
STRING_VECTOR result;
std::vector<GetPot::variable>::const_iterator it = variables.begin();
for (; it != variables.end(); ++it)
{
const std::string Tmp = _get_remaining_string((*it).name, prefix);
if (Tmp != "")
result.push_back(Tmp);
}
return result;
}
| bool GETPOT_NAMESPACE::GetPot::have_section | ( | const char * | section_name | ) | const [inline] |
Check for a section name. When querying, the section_name can be of the form Section1 or Section1/
Section1/Section2 or Section1/Section2/
etc.
Definition at line 2163 of file getpot.h.
{
std::string s = std::string(section_name);
return this->have_section(s);
}
| bool GETPOT_NAMESPACE::GetPot::have_section | ( | const std::string & | section_name | ) | const [inline] |
Check for a section name. When querying, the section_name can be of the form Section1 or Section1/
Section1/Section2 or Section1/Section2/
etc.
Definition at line 2170 of file getpot.h.
References section_list.
{
const char slash('/');
std::string::const_reverse_iterator it = section_name.rbegin();
bool found_section = false;
/* Check if section_name ends with a "/". If not, append it for the search since
the section names are stored with a "/" at the end.*/
if( (*it) != slash )
/* We need to use a linear search because we can't sort section_list
without violating some assumptions. See libMesh #481 for more discussion. */
found_section = ( std::find(section_list.begin(), section_list.end(), section_name+slash) != section_list.end() );
else
found_section = ( std::find(section_list.begin(), section_list.end(), section_name) != section_list.end() );
return found_section;
}
| bool GETPOT_NAMESPACE::GetPot::have_variable | ( | const char * | VarName | ) | const [inline] |
variables check for a variable
Definition at line 2144 of file getpot.h.
References _request_variable().
Referenced by have_variable().
{
const variable* sv = _request_variable(VarName);
if (sv == 0)
return false;
return true;
}
| bool GETPOT_NAMESPACE::GetPot::have_variable | ( | const std::string & | VarName | ) | const [inline] |
Definition at line 2157 of file getpot.h.
References have_variable().
{
return have_variable(VarName.c_str());
}
| void GETPOT_NAMESPACE::GetPot::init_multiple_occurrence | ( | ) | [inline] |
Definition at line 1769 of file getpot.h.
References disable_loop(), and reset_cursor().
{
disable_loop();
reset_cursor();
}
| T GETPOT_NAMESPACE::GetPot::next | ( | const T & | Default | ) | [inline] |
get argument at cursor++
Definition at line 1821 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().
{
if (search_failed_f)
return Default;
cursor++;
if (cursor >= argv.size())
{
cursor = getpot_cast_int<unsigned>(argv.size());
return Default;
}
// (*) record requested argument for later ufo detection
_record_argument_request(argv[cursor]);
const std::string Remain = _get_remaining_string(argv[cursor], prefix);
return Remain != "" ? _convert_to_type(Remain, Default) : Default;
}
| const char * GETPOT_NAMESPACE::GetPot::next | ( | const char * | Default | ) | [inline] |
Definition at line 1843 of file getpot.h.
References _internal_managed_copy(), and next().
{
return _internal_managed_copy(next(std::string(Default)));
}
| const char * GETPOT_NAMESPACE::GetPot::next_nominus | ( | ) | [inline] |
Definition at line 2097 of file getpot.h.
References _internal_managed_copy(), _record_argument_request(), argv, idx_nominus, and nominus_cursor.
{
if (nominus_cursor < int(idx_nominus.size()) - 1)
{
const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
// (*) record for later ufo-detection
_record_argument_request(Tmp);
return _internal_managed_copy(Tmp);
}
return 0;
}
| std::string GETPOT_NAMESPACE::GetPot::next_nominus_string | ( | ) | [inline] |
Definition at line 2114 of file getpot.h.
References _record_argument_request(), argv, idx_nominus, and nominus_cursor.
{
if (nominus_cursor < int(idx_nominus.size()) - 1)
{
const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
// (*) record for later ufo-detection
_record_argument_request(Tmp);
return Tmp;
}
return "";
}
| unsigned GETPOT_NAMESPACE::GetPot::nominus_size | ( | ) | const [inline] |
Definition at line 357 of file getpot.h.
References idx_nominus.
{ return getpot_cast_int<unsigned>(idx_nominus.size()); }
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::nominus_vector | ( | ) | const [inline] |
Definition at line 2078 of file getpot.h.
References _record_argument_request(), argv, and idx_nominus.
{
STRING_VECTOR nv;
std::vector<unsigned>::const_iterator it = idx_nominus.begin();
for (; it != idx_nominus.end(); ++it)
{
nv.push_back(argv[*it]);
// (*) record for later ufo-detection
// when a nominus vector is requested, the entire set of nominus arguments are
// tagged as 'requested'
_record_argument_request(argv[*it]);
}
return nv;
}
| T GETPOT_NAMESPACE::GetPot::operator() | ( | const char * | VarName, |
| const T & | Default | ||
| ) | const [inline] |
scalar values
Definition at line 2192 of file getpot.h.
References _convert_to_type(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::original.
Referenced by operator()().
{
// (*) recording of requested variables happens in '_request_variable()'
const variable* sv = _request_variable(VarName);
if (sv == 0)
return Default;
return _convert_to_type(sv->original, Default);
}
| T GETPOT_NAMESPACE::GetPot::operator() | ( | const std::string & | VarName, |
| const T & | Default | ||
| ) | const [inline] |
Definition at line 2207 of file getpot.h.
References operator()().
{
return operator()(VarName.c_str(), Default);
}
| const char * GETPOT_NAMESPACE::GetPot::operator() | ( | const char * | VarName, |
| const char * | Default | ||
| ) | const [inline] |
Definition at line 2215 of file getpot.h.
References _internal_managed_copy().
{
return _internal_managed_copy(operator()(VarName, std::string(Default)));
}
| const char * GETPOT_NAMESPACE::GetPot::operator() | ( | const std::string & | VarName, |
| const char * | Default | ||
| ) | const [inline] |
Definition at line 2223 of file getpot.h.
References operator()().
{
return operator()(VarName.c_str(), Default);
}
| T GETPOT_NAMESPACE::GetPot::operator() | ( | const char * | VarName, |
| const T & | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
vectors
| T GETPOT_NAMESPACE::GetPot::operator() | ( | const std::string & | VarName, |
| const T & | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
| const char* GETPOT_NAMESPACE::GetPot::operator() | ( | const char * | VarName, |
| const char * | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
| const char* GETPOT_NAMESPACE::GetPot::operator() | ( | const std::string & | VarName, |
| const char * | Default, | ||
| unsigned | Idx | ||
| ) | const [inline] |
| T GETPOT_NAMESPACE::GetPot::operator() | ( | const char * | VarName, |
| const T & | Default, | ||
| unsigned int | Idx | ||
| ) | const [inline] |
Definition at line 2232 of file getpot.h.
References _convert_to_type(), _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::get_element().
{
// (*) recording of requested variables happens in '_request_variable()'
const variable* sv = _request_variable(VarName);
if (sv == 0)
return Default;
const std::string* element = sv->get_element(Idx);
if (element == 0)
return Default;
return _convert_to_type(*element, Default);
}
| T GETPOT_NAMESPACE::GetPot::operator() | ( | const std::string & | VarName, |
| const T & | Default, | ||
| unsigned int | Idx | ||
| ) | const [inline] |
Definition at line 2249 of file getpot.h.
References operator()().
{
return operator()(VarName.c_str(), Default, Idx);
}
Definition at line 922 of file getpot.h.
References _comment_end, _comment_start, _field_separator, _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.
Referenced by GETPOT_NAMESPACE::GetPot::variable::variable().
{
if (&Other == this)
return *this;
prefix = Other.prefix;
section = Other.section;
section_list = Other.section_list;
argv = Other.argv;
cursor = Other.cursor;
search_loop_f = Other.search_loop_f;
search_failed_f = Other.search_failed_f;
nominus_cursor = Other.nominus_cursor;
overridden_vars = Other.overridden_vars;
idx_nominus = Other.idx_nominus;
variables = Other.variables;
_comment_start = Other._comment_start;
_comment_end = Other._comment_end;
_field_separator = Other._field_separator;
// #if !defined(GETPOT_DISABLE_MUTEX)
// _getpot_mtx = Other._getpot_mtx;
// #endif
_requested_arguments = Other._requested_arguments;
_requested_variables = Other._requested_variables;
_requested_sections = Other._requested_sections;
request_recording_f = Other.request_recording_f;
std::set<const char*, ltstr>::const_iterator my_it =
_internal_string_container.begin();
const std::set<const char*, ltstr>::const_iterator my_end =
_internal_string_container.end();
for (; my_it != my_end; ++my_it)
delete [] *my_it;
_internal_string_container.clear();
std::set<const char*,ltstr>::const_iterator it =
Other._internal_string_container.begin();
const std::set<const char*,ltstr>::const_iterator end =
Other._internal_string_container.end();
for (; it != end; ++it)
{
const char* otherstr = *it;
char* newcopy = new char[strlen(otherstr)+1];
strncpy(newcopy, otherstr, strlen(otherstr)+1);
this->_internal_string_container.insert(newcopy);
}
return *this;
}
| const char * GETPOT_NAMESPACE::GetPot::operator[] | ( | unsigned | Idx | ) | const [inline] |
| bool GETPOT_NAMESPACE::GetPot::options_contain | ( | const char * | FlagList | ) | const [inline] |
flags
Definition at line 2009 of file getpot.h.
References _check_flags(), _get_remaining_string(), argv, and prefix.
{
// go through all arguments that start with a '-' (but not '--')
std::string str;
STRING_VECTOR::const_iterator it = argv.begin();
for (; it != argv.end(); ++it)
{
str = _get_remaining_string(*it, prefix);
if (str.length() >= 2 && str[0] == '-' && str[1] != '-')
if (_check_flags(str, FlagList))
return true;
}
return false;
}
| void GETPOT_NAMESPACE::GetPot::parse_command_line | ( | const int | argc_, |
| const char *const * | argv_, | ||
| const char * | FieldSeparator = 0x0 |
||
| ) | [inline] |
Re-initialization methods
Definition at line 744 of file getpot.h.
References _basic_initialization(), _field_separator, and _parse_argument_vector().
Referenced by GetPot().
{
_basic_initialization();
// if specified -> overwrite default string
if (FieldSeparator)
_field_separator = std::string(FieldSeparator);
// -- make an internal copy of the argument list:
STRING_VECTOR _apriori_argv;
// -- for the sake of clarity: we do want to include the first
// argument of the first parsing source in the argument vector!
// it will not be a nominus argument, though. This gives us a
// minimum vector size of one which facilitates error checking
// in many functions. Also the user will be able to retrieve
// the name of his application or input file by "get[0]"
_apriori_argv.push_back(std::string(argv_[0]));
for (int i=1; i<argc_; i++)
{
std::string tmp(argv_[i]); // recall the problem with temporaries,
_apriori_argv.push_back(tmp); // reference counting in arguement lists ...
}
_parse_argument_vector(_apriori_argv);
}
| 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 839 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().
{
_basic_initialization();
// overwrite default strings
_comment_start = std::string(CommentStart);
_comment_end = std::string(CommentEnd);
_field_separator = FieldSeparator;
STRING_VECTOR _apriori_argv;
// -- the first element of the argument vector stores the name of
// the first parsing source; however, this element is not
// parsed for variable assignments or nominuses.
//
// Regardless, we don't add more than one name to the argument
// vector.
_apriori_argv.push_back(FileName);
STRING_VECTOR args = _read_in_file(FileName);
_apriori_argv.insert(_apriori_argv.begin()+1, args.begin(), args.end());
_parse_argument_vector(_apriori_argv);
}
| int GETPOT_NAMESPACE::GetPot::print | ( | std::ostream & | out_stream = std::cout | ) | const [inline] |
| int GETPOT_NAMESPACE::GetPot::print | ( | const char * | custom_prefix, |
| std::ostream & | out_stream = std::cout, |
||
| unsigned int | skip_count = 1 |
||
| ) | const [inline] |
| void GETPOT_NAMESPACE::GetPot::reset_cursor | ( | ) | [inline] |
reset cursor to position '1'
Definition at line 1760 of file getpot.h.
References cursor, and search_failed_f.
Referenced by init_multiple_occurrence().
{
search_failed_f = false;
cursor = 0;
}
| void GETPOT_NAMESPACE::GetPot::reset_nominus_cursor | ( | ) | [inline] |
nominus arguments
Definition at line 2132 of file getpot.h.
References nominus_cursor.
{
nominus_cursor = -1;
}
| bool GETPOT_NAMESPACE::GetPot::search | ( | const char * | option | ) | [inline] |
search for a certain option and set cursor to position
Definition at line 1671 of file getpot.h.
References _record_argument_request(), argv, cursor, prefix, search_failed_f, and search_loop_f.
Referenced by follow(), and search().
{
unsigned OldCursor = cursor;
const std::string SearchTerm = prefix + Option;
// (*) record requested arguments for later ufo detection
_record_argument_request(SearchTerm);
if (OldCursor >= argv.size())
OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
search_failed_f = true;
// (*) first loop from cursor position until end
for (unsigned c = cursor; c < argv.size(); c++)
{
if (argv[c] == SearchTerm)
{
cursor = c;
search_failed_f = false;
return true;
}
}
if (!search_loop_f)
return false;
// (*) second loop from 0 to old cursor position
for (unsigned c = 1; c < OldCursor; c++)
{
if (argv[c] == SearchTerm)
{
cursor = c;
search_failed_f = false;
return true;
}
}
// in case nothing is found the cursor stays where it was
return false;
}
| bool GETPOT_NAMESPACE::GetPot::search | ( | const std::string & | option | ) | [inline] |
| bool GETPOT_NAMESPACE::GetPot::search | ( | unsigned | No, |
| const char * | P, | ||
| ... | |||
| ) | [inline] |
Definition at line 1714 of file getpot.h.
References _record_argument_request(), and search().
{
// (*) recording the requested arguments happens in subroutine 'search'
if (No == 0)
return false;
// search for the first argument
if (search(P) == true)
return true;
// start interpreting variable argument list
va_list ap;
va_start(ap, P);
unsigned i = 1;
for (; i < No; i++)
{
char* Opt = va_arg(ap, char *);
// (*) search records itself for later ufo detection
if (search(Opt) == true)
break;
}
if (i < No)
{
i++;
// loop was left before end of array --> hit but
// make sure that the rest of the search terms is marked
// as requested.
for (; i < No; i++)
{
char* Opt = va_arg(ap, char *);
// (*) record requested arguments for later ufo detection
_record_argument_request(Opt);
}
va_end(ap);
return true;
}
va_end(ap);
// loop was left normally --> no hit
return false;
}
| bool GETPOT_NAMESPACE::GetPot::search_failed | ( | ) | const [inline] |
| void GETPOT_NAMESPACE::GetPot::set | ( | const char * | VarName, |
| const T & | Value, | ||
| const bool | Requested = true |
||
| ) | [inline] |
setting variables i) from outside of GetPot (considering prefix etc.) ii) from inside, use '_set_variable()' below
Definition at line 2427 of file getpot.h.
References _set_variable().
{
std::ostringstream string_value;
string_value << Value;
_set_variable(VarName, string_value.str().c_str(), Requested);
}
| void GETPOT_NAMESPACE::GetPot::set | ( | const std::string & | VarName, |
| const T & | Value, | ||
| const bool | Requested = true |
||
| ) | [inline] |
| void GETPOT_NAMESPACE::GetPot::set | ( | const char * | VarName, |
| const char * | Value, | ||
| const bool | Requested = true |
||
| ) | [inline] |
Definition at line 2446 of file getpot.h.
References _set_variable().
{
_set_variable(VarName, Value, Requested);
}
| void GETPOT_NAMESPACE::GetPot::set | ( | const std::string & | VarName, |
| const char * | Value, | ||
| const bool | Requested = true |
||
| ) | [inline] |
| void GETPOT_NAMESPACE::GetPot::set_prefix | ( | const char * | Prefix | ) | [inline] |
| unsigned GETPOT_NAMESPACE::GetPot::size | ( | ) | const [inline] |
Definition at line 1811 of file getpot.h.
References argv.
Referenced by _DBE_expand().
{
return getpot_cast_int<unsigned>(argv.size());
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments | ( | unsigned | Number, |
| const char * | Known, | ||
| ... | |||
| ) | const [inline] |
unidentified flying objects
Definition at line 3302 of file getpot.h.
References unidentified_arguments().
{
std::set<std::string> known_arguments;
// (1) create a vector of known arguments
if (Number == 0)
return STRING_VECTOR();
va_list ap;
va_start(ap, KnownArgument1);
known_arguments.insert(std::string(KnownArgument1));
for (unsigned i=1; i<Number; i++)
known_arguments.insert(std::string(va_arg(ap, char *)));
va_end(ap);
return unidentified_arguments(known_arguments);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments | ( | const std::set< std::string > & | Knowns | ) | const [inline] |
Definition at line 3342 of file getpot.h.
References _get_remaining_string(), argv, and prefix.
{
STRING_VECTOR ufos;
STRING_VECTOR::const_iterator it = argv.begin();
++it; // forget about argv[0] (application or filename)
for (; it != argv.end(); ++it)
{
// -- argument belongs to prefixed section ?
const std::string arg = _get_remaining_string(*it, prefix);
if (arg == "")
continue;
// -- check if in list
if (Knowns.find(arg) == Knowns.end())
ufos.push_back(*it);
}
return ufos;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments | ( | const std::vector< std::string > & | Knowns | ) | const [inline] |
Definition at line 3332 of file getpot.h.
References unidentified_arguments().
{
// We use set for efficiency, but want to support vector inputs for
// backwards compatibility.
return unidentified_arguments(std::set<std::string> (Knowns.begin(), Knowns.end()));
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments | ( | ) | const [inline] |
Definition at line 3324 of file getpot.h.
References _requested_arguments.
Referenced by unidentified_arguments(), and unidentified_options().
{
return unidentified_arguments(_requested_arguments);
}
| std::string GETPOT_NAMESPACE::GetPot::unidentified_flags | ( | const char * | Known, |
| int | ArgumentNumber = -1 |
||
| ) | const [inline] |
Definition at line 3440 of file getpot.h.
References _get_remaining_string(), argv, and prefix.
{
std::string ufos;
// STRING_VECTOR known_arguments;
std::string KFL(KnownFlagList);
// (2) iteration over '-' arguments (options)
if (ArgumentNumber == -1)
{
STRING_VECTOR::const_iterator it = argv.begin();
++it; // forget about argv[0] (application or filename)
for (; it != argv.end(); ++it)
{
// -- argument belongs to prefixed section ?
const std::string arg = _get_remaining_string(*it, prefix);
if (arg == "") continue;
// -- does arguments start with '-' (but not '--')
if (arg.length() < 2)
continue;
else if (arg[0] != '-')
continue;
else if (arg[1] == '-')
continue;
// -- check out if flags inside option are contained in KnownFlagList
const char* p=arg.c_str();
p++; // skip starting minus
for (; *p != '\0' ; p++)
if (KFL.find(*p) == std::string::npos) ufos += *p;
}
}
// (1) check specific argument
else
{
// -- only check arguments that start with prefix
int no_matches = 0;
for (unsigned i=1; i<argv.size(); i++)
{
const std::string Remain = _get_remaining_string(argv[i], prefix);
if (Remain != "")
{
no_matches++;
if (no_matches == ArgumentNumber)
{
// -- the right argument number inside the section is found
// => check it for flags
const char* p = Remain.c_str();
p++; // skip starting minus
for (; *p != '\0' ; p++)
if (KFL.find(*p) == std::string::npos) ufos += *p;
return ufos;
}
}
}
}
return ufos;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses | ( | unsigned | Number, |
| const char * | Known, | ||
| ... | |||
| ) | const [inline] |
Definition at line 3637 of file getpot.h.
References unidentified_nominuses().
{
std::set<std::string> known_nominuses;
// create vector of known arguments
if (Number == 0)
return STRING_VECTOR();
va_list ap;
va_start(ap, Known);
known_nominuses.insert(std::string(Known));
for (unsigned i=1; i<Number; i++)
{
std::string tmp = std::string(va_arg(ap, char *));
if (tmp.length() == 0)
continue;
known_nominuses.insert(tmp);
}
va_end(ap);
return unidentified_nominuses(known_nominuses);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses | ( | const std::set< std::string > & | Knowns | ) | const [inline] |
Definition at line 3688 of file getpot.h.
References _get_remaining_string(), argv, and prefix.
{
STRING_VECTOR ufos;
// (2) iterate over all arguments
STRING_VECTOR::const_iterator it = argv.begin();
++it; // forget about argv[0] (application or filename)
for (; it != argv.end(); ++it)
{
// -- check if nominus part of prefix
const std::string arg = _get_remaining_string(*it, prefix);
if (arg == "")
continue;
if (arg.length() < 1)
continue;
// option ? --> not a nomius
if (arg[0] == '-')
continue;
// section ? --> not a real nominus
if (arg[0] == '[' && arg[arg.length()-1] == ']')
continue;
// variable definition ? --> not a real nominus
bool continue_f = false;
for (unsigned i=0; i<arg.length() ; i++)
if (arg[i] == '=')
{
continue_f = true;
break;
}
if (continue_f)
continue;
// real nominuses are compared with the given list
if (Knowns.find(arg) == Knowns.end())
ufos.push_back(*it);
}
return ufos;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses | ( | const std::vector< std::string > & | Knowns | ) | const [inline] |
Definition at line 3678 of file getpot.h.
References unidentified_nominuses().
{
// We use set for efficiency, but want to support vector inputs for
// backwards compatibility.
return unidentified_nominuses(std::set<std::string> (Knowns.begin(), Knowns.end()));
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses | ( | ) | const [inline] |
Definition at line 3663 of file getpot.h.
References _requested_arguments.
Referenced by unidentified_nominuses().
{
// -- every nominus is an argument.
// -- the set of requested arguments contains the set of requested nominuss.
// -- IF the set of requested arguments contains unrequested nominuss,
// THEN they were requested as 'follow' and 'next' arguments and not as real nominuses.
//
// => it is not necessary to separate requested nominus from the list
return unidentified_nominuses(_requested_arguments);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options | ( | unsigned | Number, |
| const char * | Known, | ||
| ... | |||
| ) | const [inline] |
Definition at line 3364 of file getpot.h.
References unidentified_options().
{
std::set<std::string> known_options;
// (1) create a vector of known arguments
if (Number == 0)
return STRING_VECTOR();
va_list ap;
va_start(ap, KnownOption1);
known_options.insert(std::string(KnownOption1));
for (unsigned i=1; i<Number; i++)
known_options.insert(std::string(va_arg(ap, char *)));
va_end(ap);
return unidentified_options(known_options);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options | ( | const std::set< std::string > & | Knowns | ) | const [inline] |
Definition at line 3410 of file getpot.h.
References _get_remaining_string(), argv, and prefix.
{
STRING_VECTOR ufos;
STRING_VECTOR::const_iterator it = argv.begin();
++it; // forget about argv[0] (application or filename)
for (; it != argv.end(); ++it)
{
// -- argument belongs to prefixed section ?
const std::string arg = _get_remaining_string(*it, prefix);
if (arg == "")
continue;
// is argument really an option (starting with '-') ?
if (arg.length() < 1 || arg[0] != '-')
continue;
if (Knowns.find(arg) == Knowns.end())
ufos.push_back(*it);
}
return ufos;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options | ( | const std::vector< std::string > & | Knowns | ) | const [inline] |
Definition at line 3400 of file getpot.h.
References unidentified_options().
{
// We use set for efficiency, but want to support vector inputs for
// backwards compatibility.
return unidentified_options(std::set<std::string> (Knowns.begin(), Knowns.end()));
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options | ( | ) | const [inline] |
Definition at line 3386 of file getpot.h.
References _requested_arguments, and unidentified_arguments().
Referenced by unidentified_options().
{
// -- every option is an argument.
// -- the set of requested arguments contains the set of requested options.
// -- IF the set of requested arguments contains unrequested options,
// THEN they were requested as 'follow' and 'next' arguments and not as real options.
//
// => it is not necessary to separate requested options from the list
return unidentified_arguments(_requested_arguments);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections | ( | unsigned | Number, |
| const char * | Known, | ||
| ... | |||
| ) | const [inline] |
Definition at line 3565 of file getpot.h.
References unidentified_sections().
{
std::set<std::string> known_sections;
// (1) create a vector of known arguments
if (Number == 0)
return STRING_VECTOR();
va_list ap;
va_start(ap, KnownSection1);
known_sections.insert(std::string(KnownSection1));
for (unsigned i=1; i<Number; i++)
{
std::string tmp = std::string(va_arg(ap, char *));
if (tmp.length() == 0)
continue;
if (tmp[tmp.length()-1] != '/')
tmp += '/';
known_sections.insert(tmp);
}
va_end(ap);
return unidentified_sections(known_sections);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections | ( | const std::set< std::string > & | Knowns | ) | const [inline] |
Definition at line 3615 of file getpot.h.
References _get_remaining_string(), prefix, and section_list.
{
STRING_VECTOR ufos;
victorate(std::string, section_list, it)
{
// -- check if section conform to prefix
const std::string sec_name = _get_remaining_string(*it, prefix);
if (sec_name == "")
continue;
// -- check if section is known
if (Knowns.find(sec_name) == Knowns.end())
ufos.push_back(*it);
}
return ufos;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections | ( | const std::vector< std::string > & | Knowns | ) | const [inline] |
Definition at line 3605 of file getpot.h.
References unidentified_sections().
{
// We use set for efficiency, but want to support vector inputs for
// backwards compatibility.
return unidentified_sections(std::set<std::string> (Knowns.begin(), Knowns.end()));
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections | ( | ) | const [inline] |
Definition at line 3597 of file getpot.h.
References _requested_sections.
Referenced by unidentified_sections().
{
return unidentified_sections(_requested_sections);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables | ( | unsigned | Number, |
| const char * | Known, | ||
| ... | |||
| ) | const [inline] |
Definition at line 3504 of file getpot.h.
References unidentified_variables().
{
std::set<std::string> known_variables;
// create vector of known arguments
if (Number == 0)
return STRING_VECTOR();
va_list ap;
va_start(ap, KnownVariable1);
known_variables.insert(std::string(KnownVariable1));
for (unsigned i=1; i<Number; i++)
known_variables.insert(std::string(va_arg(ap, char *)));
va_end(ap);
return unidentified_variables(known_variables);
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables | ( | const std::set< std::string > & | Knowns | ) | const [inline] |
Definition at line 3536 of file getpot.h.
References _get_remaining_string(), prefix, and variables.
{
STRING_VECTOR ufos;
victorate(GetPot::variable, variables, it)
{
// -- check if variable has specific prefix
const std::string var_name = _get_remaining_string((*it).name, prefix);
if (var_name == "")
continue;
// -- check if variable is known
if (Knowns.find(var_name) == Knowns.end())
ufos.push_back((*it).name);
}
return ufos;
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables | ( | const std::vector< std::string > & | Knowns | ) | const [inline] |
Definition at line 3526 of file getpot.h.
References unidentified_variables().
{
// We use set for efficiency, but want to support vector inputs for
// backwards compatibility.
return unidentified_variables(std::set<std::string> (Knowns.begin(), Knowns.end()));
}
| STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables | ( | ) | const [inline] |
Definition at line 3557 of file getpot.h.
References _requested_variables.
Referenced by unidentified_variables().
{
return unidentified_variables(_requested_variables);
}
| unsigned GETPOT_NAMESPACE::GetPot::vector_variable_size | ( | const char * | VarName | ) | const [inline] |
Definition at line 2462 of file getpot.h.
References _request_variable(), and GETPOT_NAMESPACE::GetPot::variable::value.
Referenced by vector_variable_size().
{
const variable* sv = _request_variable(VarName);
if (sv == 0)
return 0;
return (unsigned)(sv->value.size());
}
| unsigned GETPOT_NAMESPACE::GetPot::vector_variable_size | ( | const std::string & | VarName | ) | const [inline] |
Definition at line 2473 of file getpot.h.
References vector_variable_size().
{
return vector_variable_size(VarName.c_str());
}
std::string GETPOT_NAMESPACE::GetPot::_comment_end [private] |
Definition at line 473 of file getpot.h.
Referenced by _basic_initialization(), _parse_argument_vector(), _skip_whitespace(), operator=(), and parse_input_file().
std::string GETPOT_NAMESPACE::GetPot::_comment_start [private] |
comment delimiters
Definition at line 472 of file getpot.h.
Referenced by _basic_initialization(), _parse_argument_vector(), _read_in_stream(), _skip_whitespace(), operator=(), and parse_input_file().
std::string GETPOT_NAMESPACE::GetPot::_field_separator [private] |
field separator (separating elements of a vector)
Definition at line 478 of file getpot.h.
Referenced by _basic_initialization(), _parse_argument_vector(), _set_variable(), operator=(), parse_command_line(), and parse_input_file().
libMesh::Threads::spin_mutex GETPOT_NAMESPACE::GetPot::_getpot_mtx [mutable, private] |
std::set<const char*, ltstr> GETPOT_NAMESPACE::GetPot::_internal_string_container [mutable, private] |
some functions return a char pointer to a string created on the fly. this container makes them 'available' until the getpot object is destroyed. user codes are recommended to instead request std::string values. We use char* here because c_str() results are only guaranteed to remain valid until a non-const string method is called
Definition at line 506 of file getpot.h.
Referenced by _internal_managed_copy(), GetPot(), operator=(), and ~GetPot().
std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_arguments [mutable, private] |
keeping track about arguments that are requested, so that the UFO detection can be simplified
Definition at line 518 of file getpot.h.
Referenced by _parse_argument_vector(), _record_argument_request(), absorb(), clear_requests(), operator=(), unidentified_arguments(), unidentified_nominuses(), and unidentified_options().
std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_sections [mutable, private] |
Definition at line 520 of file getpot.h.
Referenced by _record_argument_request(), _record_variable_request(), absorb(), clear_requests(), operator=(), and unidentified_sections().
std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_variables [mutable, private] |
Definition at line 519 of file getpot.h.
Referenced by _record_variable_request(), absorb(), clear_requests(), operator=(), and unidentified_variables().
STRING_VECTOR GETPOT_NAMESPACE::GetPot::argv [private] |
argument vector
Definition at line 452 of file getpot.h.
Referenced by _match_starting_string(), _parse_argument_vector(), absorb(), argument_contains(), direct_follow(), get(), next(), next_nominus(), next_nominus_string(), nominus_vector(), operator=(), operator[](), options_contain(), print(), search(), size(), unidentified_arguments(), unidentified_flags(), unidentified_nominuses(), and unidentified_options().
unsigned GETPOT_NAMESPACE::GetPot::cursor [private] |
Definition at line 453 of file getpot.h.
Referenced by _basic_initialization(), _match_starting_string(), direct_follow(), next(), operator=(), reset_cursor(), and search().
std::vector<unsigned> GETPOT_NAMESPACE::GetPot::idx_nominus [private] |
Definition at line 462 of file getpot.h.
Referenced by _parse_argument_vector(), next_nominus(), next_nominus_string(), nominus_size(), nominus_vector(), and operator=().
int GETPOT_NAMESPACE::GetPot::nominus_cursor [private] |
nominus vector
Definition at line 461 of file getpot.h.
Referenced by _basic_initialization(), next_nominus(), next_nominus_string(), operator=(), and reset_nominus_cursor().
std::set<std::string> GETPOT_NAMESPACE::GetPot::overridden_vars [private] |
Definition at line 456 of file getpot.h.
Referenced by _set_variable(), get_overridden_variables(), and operator=().
std::string GETPOT_NAMESPACE::GetPot::prefix [private] |
member variables
Definition at line 445 of file getpot.h.
Referenced by _basic_initialization(), _DBE_get_variable(), _find_variable(), argument_contains(), get_variable_names(), next(), operator=(), options_contain(), search(), set_prefix(), unidentified_arguments(), unidentified_flags(), unidentified_nominuses(), unidentified_options(), unidentified_sections(), and unidentified_variables().
bool GETPOT_NAMESPACE::GetPot::request_recording_f [private] |
Definition at line 522 of file getpot.h.
Referenced by _basic_initialization(), _parse_argument_vector(), _record_argument_request(), _record_variable_request(), absorb(), disable_request_recording(), enable_request_recording(), and operator=().
bool GETPOT_NAMESPACE::GetPot::search_failed_f [private] |
Definition at line 455 of file getpot.h.
Referenced by _basic_initialization(), _match_starting_string(), next(), operator=(), reset_cursor(), search(), and search_failed().
bool GETPOT_NAMESPACE::GetPot::search_loop_f [private] |
Definition at line 454 of file getpot.h.
Referenced by _basic_initialization(), _match_starting_string(), disable_loop(), enable_loop(), operator=(), and search().
std::string GETPOT_NAMESPACE::GetPot::section [private] |
Definition at line 446 of file getpot.h.
Referenced by _basic_initialization(), _DBE_get_variable(), _parse_argument_vector(), _record_argument_request(), _record_variable_request(), and operator=().
Definition at line 447 of file getpot.h.
Referenced by _parse_argument_vector(), get_section_names(), have_section(), operator=(), and unidentified_sections().
std::vector<variable> GETPOT_NAMESPACE::GetPot::variables [private] |
variables (arguments of the form "variable=value")
Definition at line 467 of file getpot.h.
Referenced by _find_variable(), _set_variable(), absorb(), get_variable_names(), operator=(), and unidentified_variables().