libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
| Public 成员函数 | Private 成员函数 | 静态 Private 成员函数 | Private 属性 | 所有成员列表
GETPOT_NAMESPACE::GetPot类 参考

GetPot - A class for parsing command line arguments and configuration files. 更多...

#include <getpot.h>

struct  ltstr
 helper functor for creating sets of C-style strings 更多...
 
struct  variable
 Variable to be specified on the command line or in input files. 更多...
 

Public 成员函数

 GetPot ()
 constructors, destructor, assignment operator 更多...
 
 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 (std::istream &FileStream, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\n"), const std::string &FieldSeparator=std::string(" \t\n"))
 This constructor is mainly for testing. 更多...
 
 ~GetPot ()
 
GetPotoperator= (const GetPot &)
 
void parse_command_line (const int argc_, const char *const *argv_, const char *FieldSeparator=0x0)
 Re-initialization methods. 更多...
 
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 parse_input_stream (std::istream &FileStream, const std::string &FileName=std::string("ParsedFromStream"), 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)
 absorbing contents of another GetPot object 更多...
 
void clear_requests ()
 for ufo detection: recording requested arguments, options etc. 更多...
 
void disable_request_recording ()
 
void enable_request_recording ()
 
const char * operator[] (unsigned Idx) const
 direct access to command line arguments 更多...
 
template<typename T >
get (unsigned Idx, const T &Default) const
 
const char * get (unsigned Idx, const char *Default) const
 
unsigned size () const
 
bool options_contain (const char *FlagList) const
 flags 更多...
 
bool argument_contains (unsigned Idx, const char *FlagList) const
 
bool have_variable (const char *VarName) const
 variables 更多...
 
bool have_variable (const std::string &VarName) const
 
bool have_section (const char *section_name) const
 Check for a section name. 更多...
 
bool have_section (const std::string &section_name) const
 Check for a section name. 更多...
 
template<typename T >
operator() (const char *VarName, const T &Default) const
 scalar values 更多...
 
template<typename T >
operator() (const std::string &VarName, const T &Default) const
 
const char * operator() (const char *VarName, const char *Default) const
 
const char * operator() (const std::string &VarName, const char *Default) const
 
template<typename T >
operator() (const char *VarName, const T &Default, unsigned Idx) const
 vectors 更多...
 
template<typename T >
operator() (const std::string &VarName, const T &Default, unsigned Idx) const
 
const char * operator() (const char *VarName, const char *Default, unsigned Idx) const
 
const char * operator() (const std::string &VarName, const char *Default, unsigned Idx) const
 
template<typename T >
get_value_no_default (const char *VarName, const T &Default) const
 access variables, but error out if not present scalar values 更多...
 
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default) const
 
const char * get_value_no_default (const char *VarName, const char *Default) const
 
const char * get_value_no_default (const std::string &VarName, const char *Default) const
 
template<typename T >
get_value_no_default (const char *VarName, const T &Default, unsigned Idx) const
 vectors 更多...
 
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default, unsigned Idx) const
 
const char * get_value_no_default (const char *VarName, const char *Default, unsigned Idx) const
 
const char * get_value_no_default (const std::string &VarName, const char *Default, unsigned Idx) const
 
template<typename T >
void set (const char *VarName, const T &Value, const bool Requested=true)
 setting variables i) from outside of GetPot (considering prefix etc.) ii) from inside, use '_set_variable()' below 更多...
 
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
 
STRING_VECTOR get_subsection_names (const std::string &section_name) const
 
std::set< std::string > get_overridden_variables () const
 
void set_prefix (const char *Prefix)
 cursor oriented functions 更多...
 
bool search_failed () const
 
void disable_loop ()
 enable/disable search for an option in loop 更多...
 
void enable_loop ()
 
void reset_cursor ()
 reset cursor to position '1' 更多...
 
void init_multiple_occurrence ()
 
bool search (const char *option)
 search for a certain option and set cursor to position 更多...
 
bool search (const std::string &option)
 
bool search (unsigned No, const char *P,...)
 
template<typename T >
next (const T &Default)
 get argument at cursor++ 更多...
 
const char * next (const char *Default)
 
template<typename T >
follow (const T &Default, const char *Option)
 search for option and get argument at cursor++ 更多...
 
const char * follow (const char *Default, const char *Option)
 
template<typename T >
follow (const T &Default, unsigned No, const char *Option,...)
 search for one of the given options and get argument that follows it 更多...
 
const char * follow (const char *Default, unsigned No, const char *Option,...)
 
template<typename T >
direct_follow (const T &Default, const char *Option)
 directly followed arguments 更多...
 
const char * direct_follow (const char *Default, const char *Option)
 
void reset_nominus_cursor ()
 nominus arguments 更多...
 
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
 unidentified flying objects 更多...
 
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
 
std::set< std::string > get_requested_arguments () const
 Accessors for requested variables. 更多...
 
std::set< std::string > get_requested_variables () const
 
std::set< std::string > get_requested_sections () const
 
int print (std::ostream &out_stream=std::cout) const
 output 更多...
 
int print (const char *custom_prefix, std::ostream &out_stream=std::cout, unsigned int skip_count=1) const
 Print everything after skipping skip_count arguments, with a custom prefix. 更多...
 
template<>
std::string _convert_to_type (const std::string &String, const std::string &) const
 
template<>
std::string _convert_to_type_no_default (const char *, const std::string &String, const std::string &) const
 
template<typename T >
get (unsigned int Idx, const T &Default) const
 
template<typename T >
follow (const T &Default, unsigned int No, const char *P,...)
 
template<typename T >
operator() (const char *VarName, const T &Default, unsigned int Idx) const
 
template<typename T >
operator() (const std::string &VarName, const T &Default, unsigned int Idx) const
 
template<typename T >
get_value_no_default (const char *VarName, const T &Default, unsigned int Idx) const
 
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default, unsigned int Idx) const
 

Private 成员函数

void _basic_initialization ()
 
const char * _internal_managed_copy (const std::string &Arg) const
 some functions return a char pointer to a temporarily existing string this function adds them to our container 更多...
 
void _record_argument_request (const std::string &Arg) const
 if an argument is requested record it and the 'tag' the section branch to which it belongs. 更多...
 
void _record_variable_request (const std::string &Arg) const
 
void _set_variable (const std::string &VarName, const std::string &Value, const bool Requested)
 helper functions 更多...
 
void _parse_argument_vector (const STRING_VECTOR &ARGV)
 produce three basic data vectors: 更多...
 
const variable_find_variable (const char *) const
 helpers for argument list processing 更多...
 
const variable_request_variable (const char *) const
 search (and record request) for a variable in 'variables' array 更多...
 
const char * _match_starting_string (const char *StartString)
 support finding directly followed arguments 更多...
 
bool _check_flags (const std::string &Str, const char *FlagList) const
 support search for flags in a specific argument 更多...
 
template<typename T >
_convert_to_type (const std::string &String, const T &Default) const
 type conversion if possible 更多...
 
std::string _convert_to_type (const std::string &String, const char *Default) const
 
template<typename T >
_convert_to_type_no_default (const char *VarName, const std::string &String, const T &Default) const
 
std::string _convert_to_type_no_default (const char *VarName, const std::string &String, const char *Default) const
 
const std::string _get_remaining_string (const std::string &String, const std::string &Start) const
 prefix extraction 更多...
 
bool _search_string_vector (const STRING_VECTOR &Vec, const std::string &Str) const
 search for a specific string 更多...
 
void _skip_whitespace (std::istream &istr)
 helpers to parse input file create an argument vector based on data found in an input file, i.e. 更多...
 
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)
 
std::string _process_section_label (const std::string &Section, STRING_VECTOR &section_stack)
 
std::string _DBE_expand_string (const std::string &str)
 dollar bracket expressions 更多...
 
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
 

静态 Private 成员函数

template<typename T >
static std::string _convert_from_type (const T &Value)
 
static STRING_VECTOR _get_section_tree (const std::string &FullPath)
 cuts a variable name into a tree of sub-sections. 更多...
 

Private 属性

std::string prefix
 member variables 更多...
 
std::string section
 
STRING_VECTOR section_list
 
STRING_VECTOR argv
 argument vector 更多...
 
unsigned cursor
 
bool search_loop_f
 
bool search_failed_f
 
std::set< std::string > overridden_vars
 
int nominus_cursor
 nominus vector 更多...
 
std::vector< unsigned > idx_nominus
 
std::vector< variablevariables
 variables (arguments of the form "variable=value") 更多...
 
std::string _comment_start
 comment delimiters 更多...
 
std::string _comment_end
 
std::string _field_separator
 field separator (separating elements of a vector) 更多...
 
 GETPOT_MUTEX_DECLARE
 we have some mutable non-thread-safe members, but we want to be able to call const member functions from multiple threads at once, so we'll wrap access to mutable objects in a mutex. 更多...
 
std::set< const char *, ltstr_internal_string_container
 some functions return a char pointer to a string created on the fly. 更多...
 
std::set< std::string > _requested_arguments
 keeping track about arguments that are requested, so that the UFO detection can be simplified 更多...
 
std::set< std::string > _requested_variables
 
std::set< std::string > _requested_sections
 
bool request_recording_f
 

详细描述

GetPot - A class for parsing command line arguments and configuration files.

作者
Frank R. Schaefer
日期
(C) 2001-2002

在文件 getpot.h154 行定义.

构造及析构函数说明

GETPOT_NAMESPACE::GetPot::GetPot ( )
inline

constructors, destructor, assignment operator

在文件 getpot.h744 行定义.

参考 _basic_initialization().

744  :
745  prefix(),
746  section(),
747  section_list(),
748  argv(),
749  cursor(),
750  search_loop_f(),
751  search_failed_f(),
752  nominus_cursor(),
753  idx_nominus(),
754  variables(),
755  _comment_start(),
756  _comment_end(),
758 #if !defined(GETPOT_DISABLE_MUTEX)
759  _getpot_mtx(),
760 #endif
766 {
768 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
void _basic_initialization()
Definition: getpot.h:721
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
GETPOT_NAMESPACE::GetPot::GetPot ( const GetPot Other)
inline

在文件 getpot.h977 行定义.

参考 _internal_string_container.

977  :
978  prefix(Other.prefix),
979  section(Other.section),
980  section_list(Other.section_list),
981  argv(Other.argv),
982  cursor(Other.cursor),
983  search_loop_f(Other.search_loop_f),
984  search_failed_f(Other.search_failed_f),
985  overridden_vars(),
986  nominus_cursor(Other.nominus_cursor),
987  idx_nominus(Other.idx_nominus),
988  variables(Other.variables),
989  _comment_start(Other._comment_start),
990  _comment_end(Other._comment_end),
991  _field_separator(Other._field_separator),
992  // #if !defined(GETPOT_DISABLE_MUTEX)
993  // _getpot_mtx(Other._getpot_mtx),
994  // #endif
996  _requested_arguments(Other._requested_arguments),
997  _requested_variables(Other._requested_variables),
998  _requested_sections(Other._requested_sections),
999  request_recording_f(Other.request_recording_f)
1000 {
1001  std::set<const char*,ltstr>::const_iterator it =
1002  Other._internal_string_container.begin();
1003 
1004  const std::set<const char*,ltstr>::const_iterator end =
1005  Other._internal_string_container.end();
1006 
1007  for (; it != end; ++it)
1008  {
1009  const char* otherstr = *it;
1010  char* newcopy = new char[strlen(otherstr)+1];
1011  strncpy(newcopy, otherstr, strlen(otherstr)+1);
1012  this->_internal_string_container.insert(newcopy);
1013  }
1014 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > overridden_vars
Definition: getpot.h:520
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
GETPOT_NAMESPACE::GetPot::GetPot ( const int  argc_,
const char *const *  argv_,
const char *  FieldSeparator = 0x0 
)
inline

在文件 getpot.h773 行定义.

参考 parse_command_line().

774  :
775  // leave 'char**' non-const to honor less capable compilers ...
776  prefix(),
777  section(),
778  section_list(),
779  argv(),
780  cursor(),
781  search_loop_f(),
782  search_failed_f(),
783  nominus_cursor(),
784  idx_nominus(),
785  variables(),
786  _comment_start(),
787  _comment_end(),
789 #if !defined(GETPOT_DISABLE_MUTEX)
790  _getpot_mtx(),
791 #endif
797 {
798  this->parse_command_line(argc_, argv_, FieldSeparator);
799 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
void parse_command_line(const int argc_, const char *const *argv_, const char *FieldSeparator=0x0)
Re-initialization methods.
Definition: getpot.h:805
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
GETPOT_NAMESPACE::GetPot::GetPot ( const char *  FileName,
const char *  CommentStart = 0x0,
const char *  CommentEnd = 0x0,
const char *  FieldSeparator = 0x0 
)
inline

在文件 getpot.h834 行定义.

参考 parse_input_file().

836  :
837  prefix(),
838  section(),
839  section_list(),
840  argv(),
841  cursor(),
842  search_loop_f(),
843  search_failed_f(),
844  nominus_cursor(),
845  idx_nominus(),
846  variables(),
847  _comment_start(),
848  _comment_end(),
850 #if !defined(GETPOT_DISABLE_MUTEX)
851  _getpot_mtx(),
852 #endif
858 {
859  const std::string& StrCommentStart = CommentStart ? CommentStart : std::string("#");
860  const std::string& StrCommentEnd = CommentEnd ? CommentEnd : std::string("\n");
861  const std::string& StrFieldSeparator = FieldSeparator ? FieldSeparator : std::string(" \t\n");
862  this->parse_input_file(FileName, StrCommentStart, StrCommentEnd, StrFieldSeparator);
863 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
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"))
Definition: getpot.h:898
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
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

在文件 getpot.h868 行定义.

参考 parse_input_file().

871  :
872  prefix(),
873  section(),
874  section_list(),
875  argv(),
876  cursor(),
877  search_loop_f(),
878  search_failed_f(),
879  nominus_cursor(),
880  idx_nominus(),
881  variables(),
882  _comment_start(),
883  _comment_end(),
885 #if !defined(GETPOT_DISABLE_MUTEX)
886  _getpot_mtx(),
887 #endif
893 {
894  this->parse_input_file(FileName, CommentStart, CommentEnd, FieldSeparator);
895 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
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"))
Definition: getpot.h:898
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
GETPOT_NAMESPACE::GetPot::GetPot ( std::istream &  FileStream,
const std::string &  CommentStart = std::string("#"),
const std::string &  CommentEnd = std::string("\n"),
const std::string &  FieldSeparator = std::string(" \t\n") 
)
inline

This constructor is mainly for testing.

The std::string based constructor should be preferred.

在文件 getpot.h913 行定义.

参考 parse_input_stream().

916  :
917  prefix(),
918  section(),
919  section_list(),
920  argv(),
921  cursor(),
922  search_loop_f(),
923  search_failed_f(),
924  nominus_cursor(),
925  idx_nominus(),
926  variables(),
927  _comment_start(),
928  _comment_end(),
930 #if !defined(GETPOT_DISABLE_MUTEX)
931  _getpot_mtx(),
932 #endif
938 {
939  this->parse_input_stream(FileStream,
940  std::string("ParsedFromStream"),// We don't have a filename here
941  CommentStart, CommentEnd, FieldSeparator);
942 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
void parse_input_stream(std::istream &FileStream, const std::string &FileName=std::string("ParsedFromStream"), const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\n"), const std::string &FieldSeparator=std::string(" \t\n"))
Definition: getpot.h:946
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
GETPOT_NAMESPACE::GetPot::~GetPot ( )
inline

在文件 getpot.h1019 行定义.

参考 _internal_string_container.

1020 {
1021  // may be some return strings had to be created, delete now !
1022  std::set<const char*, ltstr>::const_iterator it = _internal_string_container.begin();
1023  const std::set<const char*, ltstr>::const_iterator end = _internal_string_container.end();
1024  for (; it != end; ++it)
1025  delete [] *it;
1026 }
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568

成员函数说明

void GETPOT_NAMESPACE::GetPot::_basic_initialization ( )
inlineprivate

在文件 getpot.h721 行定义.

参考 _comment_end, _comment_start, _field_separator, cursor, nominus_cursor, prefix, request_recording_f, search_failed_f, search_loop_f , 以及 section.

参考自 GetPot(), parse_command_line() , 以及 parse_input_stream().

722 {
723  cursor = 0;
724  nominus_cursor = -1;
725  search_failed_f = true;
726  search_loop_f = true;
727  prefix = "";
728  section = "";
729 
730  // automatic request recording for later ufo detection
731  request_recording_f = true;
732 
733  // comment start and end strings
734  _comment_start = std::string("#");
735  _comment_end = std::string("\n");
736 
737  // default: separate vector elements by whitespaces
738  _field_separator = " \t\n";
739 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::string prefix
member variables
Definition: getpot.h:509
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
std::string _comment_start
comment delimiters
Definition: getpot.h:536
bool GETPOT_NAMESPACE::GetPot::_check_flags ( const std::string &  Str,
const char *  FlagList 
) const
inlineprivate

support search for flags in a specific argument

在文件 getpot.h2158 行定义.

参考自 argument_contains() , 以及 options_contain().

2159 {
2160  for (const char* p=FlagList; *p != '\0' ; p++)
2161  if (Str.find(*p) != std::string::npos)
2162  return true; // found something
2163  return false;
2164 }
template<typename T >
static std::string GETPOT_NAMESPACE::GetPot::_convert_from_type ( const T &  Value)
inlinestaticprivate

在文件 getpot.h691 行定义.

参考自 _DBE_expand().

692  {
693  std::ostringstream out_string;
694  out_string << Value;
695  return out_string.str();
696  }
template<typename T >
T GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const T &  Default 
) const
inlineprivate

type conversion if possible

在文件 getpot.h1569 行定义.

参考自 _DBE_expand(), direct_follow(), get(), next() , 以及 operator()().

1570 {
1571  std::istringstream in_string(String);
1572  T retval;
1573  in_string >> retval;
1574  if (in_string.fail())
1575  retval = Default;
1576  return retval;
1577 }
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const char *  Default 
) const
inlineprivate

在文件 getpot.h1593 行定义.

1594 {
1595  return String;
1596 }
template<>
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const std::string &   
) const
inline

在文件 getpot.h1584 行定义.

1585 {
1586  return String;
1587 }
template<>
bool GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const bool &  Default 
) const
inlineprivate

在文件 getpot.h1603 行定义.

1604 {
1605  std::string newstring(String);
1606  //std::transform(newstring.begin(), newstring.end(), newstring.begin(), std::toupper);
1607  for (unsigned int i=0; i<newstring.length(); ++i)
1608  newstring[i] = getpot_cast_int<char>(toupper(newstring[i]));
1609 
1610  // "true"/"True"/"TRUE" should work
1611  if (newstring.find("TRUE")!=std::string::npos)
1612  return true;
1613 
1614  if (newstring.find("FALSE")!=std::string::npos)
1615  return false;
1616 
1617  // And if we don't find that, let's search for an integer and use C unsigned
1618  // int->bool conversion before giving up; i.e. a user could specify "0" for
1619  // false or "1" for true
1620  std::istringstream in_string(String);
1621  unsigned int retval;
1622  in_string >> retval;
1623  if (in_string.fail())
1624  return Default;
1625 
1626  return retval;
1627 }
template<typename T >
T GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const T &  Default 
) const
inlineprivate

在文件 getpot.h1634 行定义.

参考自 get_value_no_default().

1635 {
1636  std::istringstream in_string(String);
1637  T retval;
1638  in_string >> retval;
1639  if (in_string.fail())
1640  {
1641  getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
1642  getpot_cerr <<" value = "<<String<<" expected type = "<<typeid(T).name()<<std::endl;
1643  getpot_error();
1644  }
1645  return retval;
1646 }
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const char *  Default 
) const
inlineprivate

在文件 getpot.h1662 行定义.

1663 {
1664  return String;
1665 }
template<>
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  ,
const std::string &  String,
const std::string &   
) const
inline

在文件 getpot.h1653 行定义.

1654 {
1655  return String;
1656 }
template<>
bool GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const bool &   
) const
inlineprivate

在文件 getpot.h1672 行定义.

1673 {
1674  std::string newstring(String);
1675  //std::transform(newstring.begin(), newstring.end(), newstring.begin(), std::toupper);
1676  for (unsigned int i=0; i<newstring.length(); ++i)
1677  {
1678  newstring[i]=getpot_cast_int<char>(toupper(newstring[i]));
1679  }
1680 
1681  // "true"/"True"/"TRUE" should work
1682  if (newstring.find("TRUE")!=std::string::npos)
1683  return true;
1684 
1685  if (newstring.find("FALSE")!=std::string::npos)
1686  return false;
1687 
1688  // And if we don't find that, let's search for an integer and use C unsigned
1689  // int->bool conversion before giving up; i.e. a user could specify "0" for
1690  // false or "1" for true
1691  std::istringstream in_string(String);
1692  unsigned int retval;
1693  in_string >> retval;
1694  if (in_string.fail())
1695  {
1696  getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
1697  getpot_cerr <<" value = "<<String<<" expected type = "<<typeid(bool).name()<<std::endl;
1698  getpot_error();
1699  }
1700 
1701  return retval;
1702 }
std::string GETPOT_NAMESPACE::GetPot::_DBE_expand ( const std::string &  str)
inlineprivate

在文件 getpot.h2929 行定义.

参考 _convert_from_type(), _convert_to_type(), _DBE_get_expr_list(), _DBE_get_variable(), std::abs(), GETPOT_NAMESPACE::GetPot::variable::name, GETPOT_NAMESPACE::GetPot::variable::original, size() , 以及 std::sqrt().

参考自 _DBE_expand_string() , 以及 _DBE_get_expr_list().

2930 {
2931  // ${: } pure text
2932  if (expr[0] == ':')
2933  return expr.substr(1);
2934 
2935  // ${& expr expr ... } text concatenation
2936  else if (expr[0] == '&')
2937  {
2938  const STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 1);
2939 
2940  STRING_VECTOR::const_iterator it = A.begin();
2941  std::string result = *it++;
2942  for (; it != A.end(); ++it) result += *it;
2943 
2944  return result;
2945  }
2946 
2947  // ${<-> expr expr expr} text replacement
2948  else if (expr.length() >= 3 && expr.substr(0, 3) == "<->")
2949  {
2950  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(3), 3);
2951  size_t tmp = 0;
2952  const size_t L = A[1].length();
2953 
2954  while ((tmp = A[0].find(A[1])) != std::string::npos)
2955  A[0].replace(tmp, L, A[2]);
2956 
2957  return A[0];
2958  }
2959 
2960  // ${=func [expr...] } function evaluation
2961  else if (expr.length() >= 2 &&
2962  expr.substr(0, 1) == "=" &&
2963  expr.substr(0, 2) != "==")
2964  {
2965  size_t funcnamestart = expr.find_first_not_of(" \t", 1);
2966  if (funcnamestart != std::string::npos)
2967  {
2968  size_t funcnameend = expr.find_first_of(" \t",funcnamestart);
2969  std::string funcname = expr.substr(funcnamestart,
2970  funcnameend-funcnamestart);
2971  if (funcname == "log")
2972  {
2973  STRING_VECTOR A =
2974  _DBE_get_expr_list(expr.substr(funcnameend), 1);
2975  double arg = _convert_to_type(A[0], 0.0);
2976  return _convert_from_type(std::log(arg));
2977  }
2978  else if (funcname == "log10")
2979  {
2980  STRING_VECTOR A =
2981  _DBE_get_expr_list(expr.substr(funcnameend), 1);
2982  double arg = _convert_to_type(A[0], 0.0);
2983  return _convert_from_type(std::log10(arg));
2984  }
2985  else if (funcname == "exp")
2986  {
2987  STRING_VECTOR A =
2988  _DBE_get_expr_list(expr.substr(funcnameend), 1);
2989  double arg = _convert_to_type(A[0], 0.0);
2990  return _convert_from_type(std::exp(arg));
2991  }
2992  else if (funcname == "sin")
2993  {
2994  STRING_VECTOR A =
2995  _DBE_get_expr_list(expr.substr(funcnameend), 1);
2996  double arg = _convert_to_type(A[0], 0.0);
2997  return _convert_from_type(std::sin(arg));
2998  }
2999  else if (funcname == "cos")
3000  {
3001  STRING_VECTOR A =
3002  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3003  double arg = _convert_to_type(A[0], 0.0);
3004  return _convert_from_type(std::cos(arg));
3005  }
3006  else if (funcname == "tan")
3007  {
3008  STRING_VECTOR A =
3009  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3010  double arg = _convert_to_type(A[0], 0.0);
3011  return _convert_from_type(std::tan(arg));
3012  }
3013  else if (funcname == "asin")
3014  {
3015  STRING_VECTOR A =
3016  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3017  double arg = _convert_to_type(A[0], 0.0);
3018  return _convert_from_type(std::asin(arg));
3019  }
3020  else if (funcname == "acos")
3021  {
3022  STRING_VECTOR A =
3023  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3024  double arg = _convert_to_type(A[0], 0.0);
3025  return _convert_from_type(std::acos(arg));
3026  }
3027  else if (funcname == "atan")
3028  {
3029  STRING_VECTOR A =
3030  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3031  double arg = _convert_to_type(A[0], 0.0);
3032  return _convert_from_type(std::atan(arg));
3033  }
3034  else if (funcname == "atan2")
3035  {
3036  STRING_VECTOR A =
3037  _DBE_get_expr_list(expr.substr(funcnameend), 2);
3038  double arg1 = _convert_to_type(A[0], 0.0);
3039  double arg2 = _convert_to_type(A[1], 0.0);
3040  return _convert_from_type(std::atan2(arg1, arg2));
3041  }
3042  else if (funcname == "sinh")
3043  {
3044  STRING_VECTOR A =
3045  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3046  double arg = _convert_to_type(A[0], 0.0);
3047  return _convert_from_type(std::sinh(arg));
3048  }
3049  else if (funcname == "cosh")
3050  {
3051  STRING_VECTOR A =
3052  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3053  double arg = _convert_to_type(A[0], 0.0);
3054  return _convert_from_type(std::cosh(arg));
3055  }
3056  else if (funcname == "tanh")
3057  {
3058  STRING_VECTOR A =
3059  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3060  double arg = _convert_to_type(A[0], 0.0);
3061  return _convert_from_type(std::tanh(arg));
3062  }
3063 #ifdef HAVE_INVERSE_HYPERBOLIC_SINE
3064  else if (funcname == "asinh")
3065  {
3066  STRING_VECTOR A =
3067  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3068  double arg = _convert_to_type(A[0], 0.0);
3069  return _convert_from_type(std::asinh(arg));
3070  }
3071 #endif
3072 #ifdef HAVE_INVERSE_HYPERBOLIC_COSINE
3073  else if (funcname == "acosh")
3074  {
3075  STRING_VECTOR A =
3076  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3077  double arg = _convert_to_type(A[0], 0.0);
3078  return _convert_from_type(std::acosh(arg));
3079  }
3080 #endif
3081 #ifdef HAVE_INVERSE_HYPERBOLIC_TANGENT
3082  else if (funcname == "atanh")
3083  {
3084  STRING_VECTOR A =
3085  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3086  double arg = _convert_to_type(A[0], 0.0);
3087  return _convert_from_type(std::atanh(arg));
3088  }
3089 #endif
3090  else if (funcname == "sqrt")
3091  {
3092  STRING_VECTOR A =
3093  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3094  double arg = _convert_to_type(A[0], 0.0);
3095  return _convert_from_type(std::sqrt(arg));
3096  }
3097  else if (funcname == "abs")
3098  {
3099  STRING_VECTOR A =
3100  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3101  double arg = _convert_to_type(A[0], 0.0);
3102  return _convert_from_type(std::abs(arg));
3103  }
3104  else if (funcname == "max")
3105  {
3106  STRING_VECTOR A =
3107  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3108  STRING_VECTOR::const_iterator it = A.begin();
3109  double result = _convert_to_type(*it++, 0.0);
3110  for (; it != A.end(); ++it)
3111  result = std::max(result, _convert_to_type(*it, 0.0));
3112  return _convert_from_type(result);
3113  }
3114  else if (funcname == "min")
3115  {
3116  STRING_VECTOR A =
3117  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3118  STRING_VECTOR::const_iterator it = A.begin();
3119  double result = _convert_to_type(*it++, 0.0);
3120  for (; it != A.end(); ++it)
3121  result = std::min(result, _convert_to_type(*it, 0.0));
3122  return _convert_from_type(result);
3123  }
3124  else if (funcname == "ceil")
3125  {
3126  STRING_VECTOR A =
3127  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3128  double arg = _convert_to_type(A[0], 0.0);
3129  return _convert_from_type(std::ceil(arg));
3130  }
3131  else if (funcname == "floor")
3132  {
3133  STRING_VECTOR A =
3134  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3135  double arg = _convert_to_type(A[0], 0.0);
3136  return _convert_from_type(std::floor(arg));
3137  }
3138  else if (funcname == "fmod")
3139  {
3140  STRING_VECTOR A =
3141  _DBE_get_expr_list(expr.substr(funcnameend), 2);
3142  double arg1 = _convert_to_type(A[0], 0.0);
3143  double arg2 = _convert_to_type(A[1], 0.0);
3144  return _convert_from_type(std::fmod(arg1, arg2));
3145  }
3146  else if (funcname == "srand")
3147  {
3148  STRING_VECTOR A =
3149  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3150  unsigned int arg = _convert_to_type(A[0], 0u);
3151  std::srand(arg);
3152  return A[0];
3153  }
3154  // ${=rand range} with default range==RAND_MAX
3155  else if (funcname == "rand")
3156  {
3157  if (funcnameend >= expr.length() ||
3158  expr.find_first_not_of(" \t", funcnameend) == std::string::npos)
3159  return _convert_from_type(std::rand());
3160 
3161  STRING_VECTOR A =
3162  _DBE_get_expr_list(expr.substr(funcnameend), 1);
3163  unsigned int range = _convert_to_type(A[0],0u);
3164  if (!range)
3165  return _convert_from_type(0);
3166  const unsigned int x = (RAND_MAX + 1u) / range;
3167  const unsigned int y = x * range;
3168  unsigned int returnval;
3169  do
3170  {
3171  returnval = rand();
3172  } while (returnval >= y);
3173  return _convert_from_type(returnval / x);
3174  }
3175  else if (funcname == "time")
3176  return _convert_from_type(std::time(NULL));
3177  else
3178  {
3179  getpot_cerr << "ERROR: unrecognized function "
3180  << funcname << std::endl;
3181  getpot_error();
3182  }
3183  }
3184  }
3185 
3186  // ${+ ...}, ${- ...}, ${* ...}, ${/ ...} expressions
3187  else if (expr[0] == '+')
3188  {
3189  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
3190  STRING_VECTOR::const_iterator it = A.begin();
3191  double result = _convert_to_type(*it++, 0.0);
3192  for (; it != A.end(); ++it)
3193  result += _convert_to_type(*it, 0.0);
3194 
3195  return _convert_from_type(result);
3196  }
3197  else if (expr[0] == '-')
3198  {
3199  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
3200  STRING_VECTOR::const_iterator it = A.begin();
3201  double result = _convert_to_type(*it++, 0.0);
3202  for (; it != A.end(); ++it)
3203  result -= _convert_to_type(*it, 0.0);
3204 
3205  return _convert_from_type(result);
3206  }
3207  else if (expr[0] == '*')
3208  {
3209  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
3210  STRING_VECTOR::const_iterator it = A.begin();
3211  double result = _convert_to_type(*it++, 0.0);
3212  for (; it != A.end(); ++it)
3213  result *= _convert_to_type(*it, 0.0);
3214 
3215  return _convert_from_type(result);
3216  }
3217  else if (expr[0] == '/')
3218  {
3219  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
3220  STRING_VECTOR::const_iterator it = A.begin();
3221  double result = _convert_to_type(*it++, 0.0);
3222  if (result == 0)
3223  return "0.0";
3224 
3225  for (; it != A.end(); ++it)
3226  {
3227  const double Q = _convert_to_type(*it, 0.0);
3228  result /= Q;
3229  }
3230  return _convert_from_type(result);
3231  }
3232 
3233  // ${^ ... } power expressions
3234  else if (expr[0] == '^')
3235  {
3236  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
3237  STRING_VECTOR::const_iterator it = A.begin();
3238  double result = _convert_to_type(*it++, 0.0);
3239  for (; it != A.end(); ++it)
3240  result = pow(result, _convert_to_type(*it, 0.0));
3241  return _convert_from_type(result);
3242  }
3243 
3244  // ${== } ${<= } ${>= } comparisons (return the number of the first 'match'
3245  else if (expr.length() >= 2 &&
3246  (expr.substr(0,2) == "==" || expr.substr(0,2) == ">=" ||
3247  expr.substr(0,2) == "<=" || expr[0] == '>' || expr[0] == '<'))
3248  {
3249  // differentiate between two and one sign operators
3250  unsigned op = 0;
3251  enum { EQ, GEQ, LEQ, GT, LT };
3252 
3253  if (expr.substr(0, 2) == "==")
3254  op = EQ;
3255 
3256  else if (expr.substr(0, 2) == ">=")
3257  op = GEQ;
3258 
3259  else if (expr.substr(0, 2) == "<=")
3260  op = LEQ;
3261 
3262  else if (expr[0] == '>')
3263  op = GT;
3264 
3265  else
3266  op = LT;
3267 
3268  STRING_VECTOR a;
3269  if (op == GT || op == LT)
3270  a = _DBE_get_expr_list(expr.substr(1), 2);
3271 
3272  else
3273  a = _DBE_get_expr_list(expr.substr(2), 2);
3274 
3275  std::string x_orig = a[0];
3276  double x = _convert_to_type(x_orig, 1e37);
3277  unsigned i = 1;
3278 
3279  STRING_VECTOR::const_iterator y_orig = a.begin();
3280  for (y_orig++; y_orig != a.end(); ++y_orig)
3281  {
3282  double y = _convert_to_type(*y_orig, 1e37);
3283 
3284  // set the strings as reference if one wasn't a number
3285  if (x == 1e37 || y == 1e37)
3286  {
3287  // it's a string comparison
3288  if ((op == EQ && x_orig == *y_orig) || (op == GEQ && x_orig >= *y_orig) ||
3289  (op == LEQ && x_orig <= *y_orig) || (op == GT && x_orig > *y_orig) ||
3290  (op == LT && x_orig < *y_orig))
3291  return _convert_from_type(i);
3292  }
3293  else
3294  {
3295  // it's a number comparison
3296  if ((op == EQ && x == y) || (op == GEQ && x >= y) ||
3297  (op == LEQ && x <= y) || (op == GT && x > y) ||
3298  (op == LT && x < y))
3299  return _convert_from_type(i);
3300  }
3301  i++;
3302  }
3303 
3304  // nothing fulfills the condition => return 0
3305  return "0";
3306  }
3307 
3308  // ${?? expr expr} select
3309  else if (expr.length() >= 2 && expr.substr(0, 2) == "??")
3310  {
3311  STRING_VECTOR a = _DBE_get_expr_list(expr.substr(2), 2);
3312  double x = _convert_to_type(a[0], 1e37);
3313 
3314  // last element is always the default argument
3315  if (x == 1e37 || x < 0 || x >= double(a.size() - 1))
3316  return a[a.size()-1];
3317 
3318  // round x to closest integer
3319  return a[int(x+0.5)];
3320  }
3321 
3322  // ${? expr expr expr} if then else conditions
3323  else if (expr[0] == '?')
3324  {
3325  STRING_VECTOR a = _DBE_get_expr_list(expr.substr(1), 2);
3326 
3327  if (_convert_to_type(a[0], 0.0) == 1.0)
3328  return a[1];
3329 
3330  else if (a.size() > 2)
3331  return a[2];
3332  }
3333  // ${! expr} maxro expansion
3334  else if (expr[0] == '!')
3335  {
3336  const GetPot::variable* Var = _DBE_get_variable(expr.substr(1));
3337  // error
3338  if (Var->name == "")
3339  return std::string(Var->original);
3340 
3341  const STRING_VECTOR A = _DBE_get_expr_list(Var->original, 2);
3342  return A[0];
3343  }
3344  // ${@: } - string subscription
3345  else if (expr.length() >= 2 && expr.substr(0,2) == "@:")
3346  {
3347  const STRING_VECTOR A = _DBE_get_expr_list(expr.substr(2), 2);
3348  double x = _convert_to_type(A[1], 1e37);
3349 
3350  // last element is always the default argument
3351  if (x == 1e37 || x < 0 || x >= double(A[0].size() - 1))
3352  return "<<1st index out of range>>";
3353 
3354  if (A.size() > 2)
3355  {
3356  double y = _convert_to_type(A[2], 1e37);
3357  if (y != 1e37 && y > 0 && y <= double(A[0].size() - 1) && y > x)
3358  return A[0].substr(int(x+0.5), int(y+1.5) - int(x+0.5));
3359 
3360  else if (y == -1)
3361  return A[0].substr(int(x+0.5));
3362 
3363  return "<<2nd index out of range>>";
3364  }
3365  else
3366  {
3367  char* tmp = new char[2];
3368  tmp[0] = A[0][int(x+0.5)]; tmp[1] = '\0';
3369  std::string result(tmp);
3370  delete [] tmp;
3371  return result;
3372  }
3373  }
3374  // ${@ } - vector subscription
3375  else if (expr[0] == '@')
3376  {
3377  STRING_VECTOR A = _DBE_get_expr_list(expr.substr(1), 2);
3378  const GetPot::variable* Var = _DBE_get_variable(A[0]);
3379  // error
3380  if (Var->name == "")
3381  {
3382  // make a copy of the string if an error occurred
3383  // (since the error variable is a static variable inside get_variable())
3384  return std::string(Var->original);
3385  }
3386 
3387  double x = _convert_to_type(A[1], 1e37);
3388 
3389  // last element is always the default argument
3390  if (x == 1e37 || x < 0 || x >= double(Var->value.size()))
3391  return "<<1st index out of range>>";
3392 
3393  if (A.size() > 2)
3394  {
3395  double y = _convert_to_type(A[2], 1e37);
3396  int begin = int(x+0.5);
3397  int end = 0;
3398  if (y != 1e37 && y > 0 && y <= double(Var->value.size()) && y > x)
3399  end = int(y+1.5);
3400  else if (y == -1)
3401  end = int(Var->value.size());
3402  else
3403  return "<<2nd index out of range>>";
3404 
3405  std::string result = *(Var->get_element(begin));
3406  for (int i = begin+1; i < end; i++)
3407  result += std::string(" ") + *(Var->get_element(i));
3408  return result;
3409  }
3410  else
3411  return *(Var->get_element(int(x+0.5)));
3412  }
3413 
3414  const STRING_VECTOR A = _DBE_get_expr_list(expr, 1);
3415  const GetPot::variable* B = _DBE_get_variable(A[0]);
3416 
3417  // make a copy of the string if an error occurred
3418  // (since the error variable is a static variable inside get_variable())
3419  if (B->name == "")
3420  return std::string(B->original);
3421 
3422  // (psuggs@pobox.com mentioned to me the warning MSVC++6.0 produces
3423  // with: else return B->original (thanks))
3424  return B->original;
3425 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1569
static std::string _convert_from_type(const T &Value)
Definition: getpot.h:691
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的平方根。
Definition: type_vector.h:88
STRING_VECTOR _DBE_get_expr_list(const std::string &str, const unsigned ExpectedNumber)
Definition: getpot.h:2804
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
const GetPot::variable * _DBE_get_variable(const std::string &str)
Definition: getpot.h:2895
unsigned size() const
Definition: getpot.h:1906
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
std::string GETPOT_NAMESPACE::GetPot::_DBE_expand_string ( const std::string &  str)
inlineprivate

dollar bracket expressions

在文件 getpot.h2771 行定义.

参考 _DBE_expand().

参考自 _parse_argument_vector().

2772 {
2773  // Parses for closing operators '${ }' and expands them letting
2774  // white spaces and other letters as they are.
2775  std::string new_string = "";
2776  unsigned open_brackets = 0;
2777  unsigned first = 0;
2778  for (unsigned i = 0; i<str.size(); i++)
2779  {
2780  if (i + 2 < str.size() && str.substr(i, 2) == "${")
2781  {
2782  if (open_brackets == 0)
2783  first = i+2;
2784  open_brackets++;
2785  }
2786  else if (str[i] == '}' && open_brackets > 0)
2787  {
2788  open_brackets -= 1;
2789  if (open_brackets == 0)
2790  {
2791  const std::string Replacement = _DBE_expand(str.substr(first, i - first));
2792  new_string += Replacement;
2793  }
2794  }
2795  else if (open_brackets == 0)
2796  new_string += str[i];
2797  }
2798  return new_string;
2799 }
std::string _DBE_expand(const std::string &str)
Definition: getpot.h:2929
STRING_VECTOR GETPOT_NAMESPACE::GetPot::_DBE_get_expr_list ( const std::string &  str,
const unsigned  ExpectedNumber 
)
inlineprivate

在文件 getpot.h2804 行定义.

参考 _DBE_expand().

参考自 _DBE_expand().

2805 {
2806  // ensures that the resulting vector has the expected number
2807  // of arguments, but they may contain an error message
2808  std::string str = str_;
2809  // Separates expressions by non-bracketed whitespaces, expands them
2810  // and puts them into a list.
2811 
2812  unsigned i=0;
2813  // (1) eat initial whitespaces
2814  for (; i < str.size(); i++)
2815  if (!std::isspace(str[i]))
2816  break;
2817 
2818  STRING_VECTOR expr_list;
2819  unsigned open_brackets = 0;
2820  std::vector<unsigned> start_idx;
2821  unsigned start_new_string = i;
2822  unsigned l = (unsigned)(str.size());
2823 
2824  // (2) search for ${ } expressions ...
2825  while (i < l)
2826  {
2827  const char letter = str[i];
2828  // whitespace -> end of expression
2829  if (std::isspace(letter) && open_brackets == 0)
2830  {
2831  expr_list.push_back(str.substr(start_new_string, i - start_new_string));
2832  bool no_breakout_f = true;
2833  for (i++; i < l ; i++)
2834  {
2835  if (!std::isspace(str[i]))
2836  {
2837  no_breakout_f = false;
2838  start_new_string = i;
2839  break;
2840  }
2841  }
2842 
2843  if (no_breakout_f)
2844  {
2845  // end of expression list
2846  if (expr_list.size() < ExpectedNumber)
2847  {
2848  const std::string pre_tmp("<< ${ }: missing arguments>>");
2849  STRING_VECTOR tmp(ExpectedNumber - expr_list.size(), pre_tmp);
2850  expr_list.insert(expr_list.end(), tmp.begin(), tmp.end());
2851  }
2852  return expr_list;
2853  }
2854  }
2855 
2856  // dollar-bracket expression
2857  if (str.length() >= i+2 && str.substr(i, 2) == "${")
2858  {
2859  open_brackets++;
2860  start_idx.push_back(i+2);
2861  }
2862 
2863  else if (letter == '}' && open_brackets > 0)
2864  {
2865  int start = start_idx[start_idx.size()-1];
2866  start_idx.pop_back();
2867  const std::string Replacement = _DBE_expand(str.substr(start, i-start));
2868  if (start - 3 < (int)0)
2869  str = Replacement + str.substr(i+1);
2870  else
2871  str = str.substr(0, start-2) + Replacement + str.substr(i+1);
2872  l = (int)(str.size());
2873  i = start + (int)(Replacement.size()) - 3;
2874  open_brackets--;
2875  }
2876  i++;
2877  }
2878 
2879  // end of expression list
2880  expr_list.push_back(str.substr(start_new_string, i-start_new_string));
2881 
2882  if (expr_list.size() < ExpectedNumber)
2883  {
2884  const std::string pre_tmp("<< ${ }: missing arguments>>");
2885  STRING_VECTOR tmp(ExpectedNumber - expr_list.size(), pre_tmp);
2886  expr_list.insert(expr_list.end(), tmp.begin(), tmp.end());
2887  }
2888 
2889  return expr_list;
2890 }
std::string _DBE_expand(const std::string &str)
Definition: getpot.h:2929
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
const GetPot::variable * GETPOT_NAMESPACE::GetPot::_DBE_get_variable ( const std::string &  str)
inlineprivate

在文件 getpot.h2895 行定义.

参考 _request_variable(), GETPOT_NAMESPACE::GetPot::variable::original, prefix , 以及 section.

参考自 _DBE_expand().

2896 {
2897  static GetPot::variable ev;
2898  std::string secure_Prefix = prefix;
2899 
2900  prefix = section;
2901  // (1) first search in currently active section
2902  const GetPot::variable* var = _request_variable(VarName.c_str());
2903  if (var != 0)
2904  {
2905  prefix = secure_Prefix;
2906  return var;
2907  }
2908 
2909  // (2) search in root name space
2910  prefix = "";
2911  var = _request_variable(VarName.c_str());
2912  if (var != 0)
2913  {
2914  prefix = secure_Prefix;
2915  return var;
2916  }
2917 
2918  prefix = secure_Prefix;
2919 
2920  // error occurred => variable name == ""
2921  ev.original = "<<${ } variable '";
2922  ev.original += VarName + "' undefined>>";
2923  return &ev;
2924 }
std::string section
Definition: getpot.h:510
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
std::string prefix
member variables
Definition: getpot.h:509
const GetPot::variable * GETPOT_NAMESPACE::GetPot::_find_variable ( const char *  VarName) const
inlineprivate

helpers for argument list processing

search for a variable in 'variables' array

在文件 getpot.h2658 行定义.

参考 prefix , 以及 variables.

参考自 _request_variable() , 以及 _set_variable().

2659 {
2660  const std::string Name = prefix + VarName;
2661 
2662  std::vector<variable>::const_iterator it = variables.begin();
2663  for (; it != variables.end(); ++it)
2664  {
2665  if ((*it).name == Name)
2666  return &(*it);
2667  }
2668  return 0;
2669 }
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
const std::string GETPOT_NAMESPACE::GetPot::_get_next_token ( std::istream &  istr)
inlineprivate

在文件 getpot.h1368 行定义.

参考 _get_string(), _get_until_closing_bracket() , 以及 _get_until_closing_square_bracket().

参考自 _read_in_stream().

1369 {
1370  // get next concatenates string token. consider quotes that embrace
1371  // whitespaces
1372  std::string token;
1373  int tmp = 0;
1374  while (true)
1375  {
1376  int last_letter = tmp;
1377  tmp = istr.get();
1378 
1379  if (tmp == '=')
1380  {
1381  // Always break at '='.
1382  // This separates '=' at the beginning of a word into its own word.
1383  token += getpot_cast_int<char>(tmp);
1384  return token;
1385  }
1386 
1387  else if (tmp == EOF || ((tmp == ' ' || tmp == '\t' || tmp == '\n') && last_letter != '\\'))
1388  return token;
1389 
1390  else if (tmp == '\'' && last_letter != '\\')
1391  {
1392  // QUOTES: un-backslashed quotes => it's a string
1393  token += _get_string(istr);
1394  continue;
1395  }
1396 
1397  else if (tmp == '{' && last_letter == '$')
1398  {
1399  token += '{' + _get_until_closing_bracket(istr);
1400  continue;
1401  }
1402 
1403  else if (tmp == '[')
1404  {
1405  token += '[' + _get_until_closing_square_bracket(istr);
1406  continue;
1407  }
1408 
1409  else if (tmp == '$' && last_letter == '\\')
1410  {
1411  token += getpot_cast_int<char>(tmp); tmp = 0; // so that last_letter will become = 0, not '$';
1412  continue;
1413  }
1414 
1415  else if (tmp == '\\' && last_letter != '\\')
1416  continue; // don't append un-backslashed backslashes
1417 
1418  token += getpot_cast_int<char>(tmp);
1419  }
1420 }
const std::string _get_string(std::istream &istr)
Definition: getpot.h:1425
const std::string _get_until_closing_bracket(std::istream &istr)
Definition: getpot.h:1451
const std::string _get_until_closing_square_bracket(std::istream &istr)
Definition: getpot.h:1484
const std::string GETPOT_NAMESPACE::GetPot::_get_remaining_string ( const std::string &  String,
const std::string &  Start 
) const
inlineprivate

prefix extraction

在文件 getpot.h1739 行定义.

参考自 argument_contains(), get_variable_names(), next(), options_contain(), unidentified_arguments(), unidentified_flags(), unidentified_nominuses(), unidentified_options(), unidentified_sections() , 以及 unidentified_variables().

1740 {
1741  if (Start == "")
1742  return String;
1743 
1744  // note: java.lang.String: substring(a,b) = from a to b-1
1745  // C++ string: substr(a,b) = from a to a + b
1746  if (String.find(Start) == 0)
1747  return String.substr(Start.length());
1748 
1749  else
1750  return "";
1751 }
static STRING_VECTOR GETPOT_NAMESPACE::GetPot::_get_section_tree ( const std::string &  FullPath)
inlinestaticprivate

cuts a variable name into a tree of sub-sections.

this is requested for recording requested sections when dealing with 'ufo' detection.

在文件 getpot.h702 行定义.

参考自 _record_argument_request() , 以及 _record_variable_request().

703  {
704  STRING_VECTOR result;
705  for (std::size_t pos = 0; pos != FullPath.size(); ++pos)
706  {
707  if (FullPath[pos] == '/')
708  result.push_back(FullPath.substr(0,pos));
709  }
710 
711  return result;
712  }
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
const std::string GETPOT_NAMESPACE::GetPot::_get_string ( std::istream &  istr)
inlineprivate

在文件 getpot.h1425 行定义.

参考自 _get_next_token().

1426 {
1427  // parse input until next matching '
1428  std::string str;
1429  int tmp = 0;
1430  while (true)
1431  {
1432  int last_letter = tmp;
1433  tmp = istr.get();
1434  if (tmp == EOF)
1435  return str;
1436 
1437  // un-backslashed quotes => it's the end of the string
1438  else if (tmp == '\'' && last_letter != '\\')
1439  return str;
1440 
1441  else if (tmp == '\\' && last_letter != '\\')
1442  continue; // don't append
1443 
1444  str += getpot_cast_int<char>(tmp);
1445  }
1446 }
const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_bracket ( std::istream &  istr)
inlineprivate

在文件 getpot.h1451 行定义.

参考自 _get_next_token().

1452 {
1453  // parse input until next matching }
1454  std::string str = "";
1455  int tmp = 0;
1456  int brackets = 1;
1457  while (true)
1458  {
1459  int last_letter = tmp;
1460  tmp = istr.get();
1461  if (tmp == EOF)
1462  return str;
1463 
1464  else if (tmp == '{' && last_letter == '$')
1465  brackets += 1;
1466 
1467  else if (tmp == '}')
1468  {
1469  brackets -= 1;
1470  // un-backslashed brackets => it's the end of the string
1471  if (brackets == 0)
1472  return str + '}';
1473 
1474  else if (tmp == '\\' && last_letter != '\\')
1475  continue; // do not append an unbackslashed backslash
1476  }
1477  str += getpot_cast_int<char>(tmp);
1478  }
1479 }
const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_square_bracket ( std::istream &  istr)
inlineprivate

在文件 getpot.h1484 行定义.

参考自 _get_next_token().

1485 {
1486  // parse input until next matching ]
1487  std::string str = "";
1488  int brackets = 1;
1489  while (true)
1490  {
1491  int tmp = istr.get();
1492  if (tmp == EOF)
1493  return str;
1494 
1495  else if (tmp == '[')
1496  brackets += 1;
1497 
1498  else if (tmp == ']')
1499  {
1500  brackets -= 1;
1501  if (brackets == 0)
1502  return str + ']';
1503  }
1504 
1505  str += getpot_cast_int<char>(tmp);
1506  }
1507 }
const char * GETPOT_NAMESPACE::GetPot::_internal_managed_copy ( const std::string &  Arg) const
inlineprivate

some functions return a char pointer to a temporarily existing string this function adds them to our container

在文件 getpot.h1707 行定义.

参考 _internal_string_container.

参考自 direct_follow(), follow(), get_value_no_default(), next(), next_nominus() , 以及 operator()().

1708 {
1709  const char* arg = Arg.c_str();
1710 
1711  // Get a lock before touching anything mutable
1712  SCOPED_MUTEX;
1713 
1714  // See if there's already an identical string saved
1715  std::set<const char*,ltstr>::const_iterator it =
1716  _internal_string_container.find(arg);
1717 
1718  // If so, return it
1719  if (it != _internal_string_container.end())
1720  return *it;
1721 
1722  // Otherwise, create a new one
1723  const std::size_t bufsize = strlen(arg)+1;
1724  char* newcopy = new char[bufsize];
1725  strncpy(newcopy, arg, bufsize);
1726  _internal_string_container.insert(newcopy);
1727  return newcopy;
1728 }
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
const char * GETPOT_NAMESPACE::GetPot::_match_starting_string ( const char *  StartString)
inlineprivate

support finding directly followed arguments

在文件 getpot.h2060 行定义.

参考 argv, cursor, search_failed_f , 以及 search_loop_f.

参考自 direct_follow().

2061 {
2062  const unsigned N =
2063  getpot_cast_int<unsigned>(strlen(StartString));
2064  unsigned OldCursor = cursor;
2065 
2066  if (OldCursor >= argv.size())
2067  OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
2068  search_failed_f = true;
2069 
2070  // (*) first loop from cursor position until end
2071  for (unsigned c = cursor; c < argv.size(); c++)
2072  {
2073  if (strncmp(StartString, argv[c].c_str(), N) == 0)
2074  {
2075  cursor = c;
2076  search_failed_f = false;
2077  return &(argv[c].c_str()[N]);
2078  }
2079  }
2080 
2081  if (!search_loop_f)
2082  return NULL;
2083 
2084  // (*) second loop from 0 to old cursor position
2085  for (unsigned c = 1; c < OldCursor; c++)
2086  {
2087  if (strncmp(StartString, argv[c].c_str(), N) == 0)
2088  {
2089  cursor = c;
2090  search_failed_f = false;
2091  return &(argv[c].c_str()[N]);
2092  }
2093  }
2094  return 0;
2095 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
void GETPOT_NAMESPACE::GetPot::_parse_argument_vector ( const STRING_VECTOR ARGV)
inlineprivate

produce three basic data vectors:

  • argument vector
  • nominus vector
  • variable dictionary

在文件 getpot.h1131 行定义.

参考 _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 , 以及 section_list.

参考自 parse_command_line() , 以及 parse_input_stream().

1132 {
1133  if (ARGV.empty())
1134  return;
1135 
1136  // build internal databases:
1137  // 1) array with no-minus arguments (usually used as filenames)
1138  // 2) variable assignments:
1139  // 'variable name' '=' number | string
1140  STRING_VECTOR section_stack;
1141  STRING_VECTOR::const_iterator it = ARGV.begin();
1142 
1143 
1144  section = "";
1145 
1146  // -- do not parse the first argument, so that this parsing source
1147  // name is not interpreted a s a nominus or so. If we already
1148  // have parsed arguments, don't bother adding another parsing
1149  // source name
1150  if (argv.empty())
1151  argv.push_back(*it);
1152  ++it;
1153 
1154  // -- loop over remaining arguments
1155  for (; it != ARGV.end(); ++it)
1156  {
1157  std::string arg = *it;
1158 
1159  if (arg.length() == 0)
1160  continue;
1161 
1162  // -- [section] labels and [include file] directives
1163  if (arg.length() > 1 && arg[0] == '[' && arg[arg.length()-1] == ']')
1164  {
1165 
1166  // Is this an include file directive?
1167  std::size_t include_pos = arg.find("include ", 1);
1168  if (include_pos != std::string::npos)
1169  {
1170 
1171  const std::string includefile =
1172  _DBE_expand_string(arg.substr(9, arg.length()-9-include_pos));
1173 
1174  this->parse_input_file
1175  (includefile, _comment_start, _comment_end, _field_separator);
1176  }
1177 
1178  else
1179  {
1180  // (*) sections are considered 'requested arguments'
1181  if (request_recording_f)
1182  {
1183  // Get a lock before touching anything mutable
1184  SCOPED_MUTEX;
1185 
1186  _requested_arguments.insert(arg);
1187  }
1188 
1189  const std::string Name = _DBE_expand_string(arg.substr(1, arg.length()-2));
1190  section = _process_section_label(Name, section_stack);
1191  // new section --> append to list of sections
1192  if (find(section_list.begin(), section_list.end(), section) == section_list.end())
1193  if (section.length() != 0) section_list.push_back(section);
1194  argv.push_back(arg);
1195  }
1196  }
1197  else
1198  {
1199  arg = section + _DBE_expand_string(arg);
1200  argv.push_back(arg);
1201  }
1202 
1203  // -- separate array for nominus arguments
1204  if (arg[0] != '-')
1205  idx_nominus.push_back(getpot_cast_int<unsigned>(argv.size()-1));
1206 
1207  // -- variables: does arg contain a '=' operator ?
1208  const std::size_t equals_pos = arg.find_first_of('=');
1209  if (equals_pos != std::string::npos)
1210  {
1211  // (*) record for later ufo detection
1212  // arguments carrying variables are always treated as 'requested' arguments.
1213  // unrequested variables have to be detected with the ufo-variable
1214  // detection routine.
1215  if (request_recording_f)
1216  {
1217  // Get a lock before touching anything mutable
1218  SCOPED_MUTEX;
1219 
1220  _requested_arguments.insert(arg);
1221  }
1222 
1223  // => arg (from start to '=') = Name of variable
1224  // (from '=' to end) = value of variable
1225  _set_variable(arg.substr(0,equals_pos),
1226  arg.substr(equals_pos+1), false);
1227  }
1228  }
1229 }
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
helper functions
Definition: getpot.h:2503
std::string _process_section_label(const std::string &Section, STRING_VECTOR &section_stack)
Definition: getpot.h:1512
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"))
Definition: getpot.h:898
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::string _DBE_expand_string(const std::string &str)
dollar bracket expressions
Definition: getpot.h:2771
std::string GETPOT_NAMESPACE::GetPot::_process_section_label ( const std::string &  Section,
STRING_VECTOR section_stack 
)
inlineprivate

在文件 getpot.h1512 行定义.

参考自 _parse_argument_vector().

1514 {
1515  std::string sname = Section;
1516  // 1) subsection of actual section ('./' prefix)
1517  if (sname.length() >= 2 && sname.substr(0, 2) == "./")
1518  sname = sname.substr(2);
1519 
1520  // 2) subsection of parent section ('../' prefix)
1521  else if (sname.length() >= 3 && sname.substr(0, 3) == "../")
1522  {
1523  do
1524  {
1525  if (section_stack.end() != section_stack.begin())
1526  section_stack.pop_back();
1527  sname = sname.substr(3);
1528  } while (sname.substr(0, 3) == "../");
1529  }
1530 
1531  // 3) subsection of the root-section
1532  else
1533  // [] => back to root section
1534  section_stack.erase(section_stack.begin(), section_stack.end());
1535 
1536  if (sname != "")
1537  {
1538  // parse section name for 'slashes'
1539  unsigned i=0;
1540  while (i < sname.length())
1541  {
1542  if (sname[i] == '/')
1543  {
1544  section_stack.push_back(sname.substr(0,i));
1545  if (i+1 < sname.length())
1546  sname = sname.substr(i+1);
1547  i = 0;
1548  }
1549  else
1550  i++;
1551  }
1552  section_stack.push_back(sname);
1553  }
1554 
1555  std::string section_label = "";
1556  if (!section_stack.empty())
1557  {
1558  victorate(std::string, section_stack, it)
1559  section_label += *it + "/";
1560  }
1561  return section_label;
1562 }
STRING_VECTOR GETPOT_NAMESPACE::GetPot::_read_in_stream ( std::istream &  istr)
inlineprivate

在文件 getpot.h1234 行定义.

参考 _comment_start, _get_next_token() , 以及 _skip_whitespace().

参考自 parse_input_stream().

1235 {
1236  STRING_VECTOR brute_tokens;
1237  while (istr)
1238  {
1239  _skip_whitespace(istr);
1240  const std::string Token = _get_next_token(istr);
1241  // Allow 'keyword =' to parse with an empty string as value.
1242  // Only break at EOF.
1243  // if (Token.length() == 0 || Token[0] == EOF) break;
1244  if (Token[0] == EOF)
1245  break;
1246  brute_tokens.push_back(Token);
1247  }
1248 
1249  // -- reduce expressions of token1'='token2 to a single
1250  // string 'token1=token2'
1251  // -- copy everything into 'argv'
1252  // -- arguments preceded by something like '[' name ']' (section)
1253  // produce a second copy of each argument with a prefix '[name]argument'
1254  unsigned i1 = 0;
1255  unsigned i2 = 1;
1256  unsigned i3 = 2;
1257 
1258  STRING_VECTOR arglist;
1259  while (i1 < brute_tokens.size())
1260  {
1261  // 1) concatenate 'abcdef' '=' 'efgasdef' to 'abcdef=efgasdef'
1262  // note: java.lang.String: substring(a,b) = from a to b-1
1263  // C++ string: substr(a,b) = from a to a + b
1264  std::string result;
1265  if (i2 < brute_tokens.size() && brute_tokens[i2] == "=")
1266  {
1267  if (i3 >= brute_tokens.size())
1268  result = brute_tokens[i1] + brute_tokens[i2];
1269  else
1270  result = brute_tokens[i1] + brute_tokens[i2] + brute_tokens[i3];
1271  i1 = i3+1; i2 = i3+2; i3 = i3+3;
1272  }
1273  else if (i2 < brute_tokens.size() &&
1274  brute_tokens[i2].length() > 0 &&
1275  brute_tokens[i2][0] == '=')
1276  {
1277  // This case should not be hit if '=' at the beginning of a word
1278  // is always separated into its own word
1279  result = brute_tokens[i1] + brute_tokens[i2];
1280  i1 = i3; i2 = i3+1; i3 = i3+2;
1281  }
1282  else if (i2 < brute_tokens.size() && brute_tokens[i1][brute_tokens[i1].size()-1] == '=')
1283  {
1284  result = brute_tokens[i1] + brute_tokens[i2];
1285  i1 = i3; i2 = i3+1; i3 = i3+2;
1286  }
1287  else
1288  {
1289  result = brute_tokens[i1];
1290  i1=i2; i2=i3; i3++;
1291  }
1292 
1293  // Now strip out any comment
1294  size_t comment_start_loc = result.find(_comment_start, 0);
1295  if (comment_start_loc != std::string::npos)
1296  result = result.substr(0, comment_start_loc);
1297 
1298  arglist.push_back(result);
1299  }
1300  return arglist;
1301 }
const std::string _get_next_token(std::istream &istr)
Definition: getpot.h:1368
void _skip_whitespace(std::istream &istr)
helpers to parse input file create an argument vector based on data found in an input file...
Definition: getpot.h:1306
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
std::string _comment_start
comment delimiters
Definition: getpot.h:536
void GETPOT_NAMESPACE::GetPot::_record_argument_request ( const std::string &  Arg) const
inlineprivate

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

在文件 getpot.h2457 行定义.

参考 _get_section_tree(), _requested_arguments, _requested_sections, request_recording_f , 以及 section.

参考自 argument_contains(), direct_follow(), next(), next_nominus(), next_nominus_string(), nominus_vector() , 以及 search().

2458 {
2459  if (!request_recording_f)
2460  return;
2461 
2462  // Get a lock before touching anything mutable
2463  SCOPED_MUTEX;
2464 
2465  // (*) record requested variable for later ufo detection
2466  _requested_arguments.insert(Name);
2467 
2468  // (*) record considered section for ufo detection
2469  STRING_VECTOR STree = _get_section_tree(Name);
2470  victorate(std::string, STree, it)
2471  if (_requested_sections.find(*it) == _requested_sections.end())
2472  if (section.length() != 0)
2473  _requested_sections.insert(*it);
2474 }
static STRING_VECTOR _get_section_tree(const std::string &FullPath)
cuts a variable name into a tree of sub-sections.
Definition: getpot.h:702
std::string section
Definition: getpot.h:510
std::set< std::string > _requested_sections
Definition: getpot.h:582
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
void GETPOT_NAMESPACE::GetPot::_record_variable_request ( const std::string &  Arg) const
inlineprivate

在文件 getpot.h2479 行定义.

参考 _get_section_tree(), _requested_sections, _requested_variables, request_recording_f , 以及 section.

参考自 _request_variable().

2480 {
2481  if (!request_recording_f)
2482  return;
2483 
2484  // Get a lock before touching anything mutable
2485  SCOPED_MUTEX;
2486 
2487  // (*) record requested variable for later ufo detection
2488  _requested_variables.insert(Name);
2489 
2490  // (*) record considered section for ufo detection
2491  STRING_VECTOR STree = _get_section_tree(Name);
2492  victorate(std::string, STree, it)
2493  if (_requested_sections.find(*it) == _requested_sections.end())
2494  if (section.length() != 0)
2495  _requested_sections.insert(*it);
2496 }
static STRING_VECTOR _get_section_tree(const std::string &FullPath)
cuts a variable name into a tree of sub-sections.
Definition: getpot.h:702
std::string section
Definition: getpot.h:510
std::set< std::string > _requested_sections
Definition: getpot.h:582
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
const GetPot::variable * GETPOT_NAMESPACE::GetPot::_request_variable ( const char *  VarName) const
inlineprivate

search (and record request) for a variable in 'variables' array

在文件 getpot.h2674 行定义.

参考 _find_variable() , 以及 _record_variable_request().

参考自 _DBE_get_variable(), _set_variable(), get_value_no_default(), have_variable(), operator()() , 以及 vector_variable_size().

2675 {
2676  // (*) record requested variable for later ufo detection
2677  this->_record_variable_request(VarName);
2678 
2679  return this->_find_variable(VarName);
2680 }
void _record_variable_request(const std::string &Arg) const
Definition: getpot.h:2479
const variable * _find_variable(const char *) const
helpers for argument list processing
Definition: getpot.h:2658
bool GETPOT_NAMESPACE::GetPot::_search_string_vector ( const STRING_VECTOR Vec,
const std::string &  Str 
) const
inlineprivate

search for a specific string

在文件 getpot.h3434 行定义.

3435 {
3436  victorate(std::string, VecStr, itk)
3437  {
3438  if (*itk == Str)
3439  return true;
3440  }
3441  return false;
3442 }
void GETPOT_NAMESPACE::GetPot::_set_variable ( const std::string &  VarName,
const std::string &  Value,
const bool  Requested 
)
inlineprivate

helper functions

set variable from inside GetPot (no prefix considered)

在文件 getpot.h2503 行定义.

参考 _field_separator, _find_variable(), _request_variable(), overridden_vars , 以及 variables.

参考自 _parse_argument_vector() , 以及 set().

2505 {
2506  const GetPot::variable* Var = Requested ?
2507  _request_variable(VarName.c_str()) :
2508  _find_variable(VarName.c_str());
2509  if (Var == 0)
2510  variables.push_back(variable(VarName.c_str(), Value.c_str(), _field_separator.c_str()));
2511  else
2512  {
2513  overridden_vars.insert(VarName.c_str());
2514  (const_cast<GetPot::variable*>(Var))->take(Value.c_str(), _field_separator.c_str());
2515  }
2516 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
const variable * _find_variable(const char *) const
helpers for argument list processing
Definition: getpot.h:2658
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::set< std::string > overridden_vars
Definition: getpot.h:520
void GETPOT_NAMESPACE::GetPot::_skip_whitespace ( std::istream &  istr)
inlineprivate

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) interpret sections like '[../my-section]' etc.

在文件 getpot.h1306 行定义.

参考 _comment_end , 以及 _comment_start.

参考自 _read_in_stream().

1307 {
1308  // find next non-whitespace while deleting comments
1309  int tmp = istr.get();
1310  do {
1311  // -- search a non whitespace
1312  while (std::isspace(tmp))
1313  {
1314  tmp = istr.get();
1315  if (!istr)
1316  return;
1317  }
1318 
1319  // -- look if characters match the comment starter string
1320  for (unsigned i=0; i<_comment_start.length() ; i++)
1321  {
1322  if (tmp != _comment_start[i])
1323  {
1324  // -- one step more backwards, since 'tmp' already at non-whitespace
1325  istr.unget();
1326  return;
1327  }
1328 
1329  // RHS: Why is this here? It breaks on empty comments
1330  // tmp = istr.get();
1331  // if (!istr) { istr.unget(); return; }
1332  }
1333  // 'tmp' contains last character of _comment_starter
1334 
1335  // -- comment starter found -> search for comment ender
1336  unsigned match_no=0;
1337  while (true)
1338  {
1339  tmp = istr.get();
1340  if (!istr)
1341  {
1342  istr.unget();
1343  return;
1344  }
1345 
1346  if (tmp == _comment_end[match_no])
1347  {
1348  match_no++;
1349  if (match_no == _comment_end.length())
1350  {
1351  istr.unget();
1352  break; // shuffle more whitespace, end of comment found
1353  }
1354  }
1355  else
1356  match_no = 0;
1357  }
1358 
1359  tmp = istr.get();
1360 
1361  } while (istr);
1362  istr.unget();
1363 }
std::string _comment_end
Definition: getpot.h:537
std::string _comment_start
comment delimiters
Definition: getpot.h:536
void GETPOT_NAMESPACE::GetPot::absorb ( const GetPot Other)
inline

absorbing contents of another GetPot object

在文件 getpot.h1088 行定义.

参考 _requested_arguments, _requested_sections, _requested_variables, argv, request_recording_f , 以及 variables.

1089 {
1090  if (&Other == this)
1091  return;
1092 
1093  // variables that are not influenced by absorption:
1094  // _comment_start
1095  // _comment_end
1096  // cursor
1097  // nominus_cursor
1098  // search_failed
1099  // idx_nominus
1100  // search_loop_f
1101  argv = Other.argv;
1102  variables = Other.variables;
1103 
1104  if (request_recording_f)
1105  {
1106  // Get a lock before touching anything mutable
1107  SCOPED_MUTEX;
1108 
1109  _requested_arguments.insert(Other._requested_arguments.begin(), Other._requested_arguments.end());
1110  _requested_variables.insert(Other._requested_variables.begin(), Other._requested_variables.end());
1111  _requested_sections.insert(Other._requested_sections.begin(), Other._requested_sections.end());
1112  }
1113 }
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
bool GETPOT_NAMESPACE::GetPot::argument_contains ( unsigned  Idx,
const char *  FlagList 
) const
inline

在文件 getpot.h2123 行定义.

参考 _check_flags(), _get_remaining_string(), _record_argument_request(), argv , 以及 prefix.

2124 {
2125  if (Idx >= argv.size())
2126  return false;
2127 
2128  // (*) record requested of argument for later ufo-detection
2129  // an argument that is checked for flags is considered to be 'requested'
2131 
2132  if (prefix == "")
2133  // search argument for any flag in flag list
2134  return _check_flags(argv[Idx], FlagList);
2135 
2136  // if a prefix is set, then the argument index is the index
2137  // inside the 'namespace'
2138  // => only check list of arguments that start with prefix
2139  unsigned no_matches = 0;
2140  for (unsigned i=0; i<argv.size(); i++)
2141  {
2142  const std::string Remain = _get_remaining_string(argv[i], prefix);
2143  if (Remain != "")
2144  {
2145  no_matches += 1;
2146  if (no_matches == Idx)
2147  return _check_flags(Remain, FlagList);
2148  }
2149  }
2150 
2151  // no argument in this namespace
2152  return false;
2153 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
bool _check_flags(const std::string &Str, const char *FlagList) const
support search for flags in a specific argument
Definition: getpot.h:2158
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
void GETPOT_NAMESPACE::GetPot::clear_requests ( )
inline

for ufo detection: recording requested arguments, options etc.

在文件 getpot.h1118 行定义.

参考 _requested_arguments, _requested_sections , 以及 _requested_variables.

1119 {
1120  // Get a lock before touching anything mutable
1121  SCOPED_MUTEX;
1122 
1123  _requested_arguments.clear();
1124  _requested_variables.clear();
1125  _requested_sections.clear();
1126 }
std::set< std::string > _requested_sections
Definition: getpot.h:582
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
template<typename T >
T GETPOT_NAMESPACE::GetPot::direct_follow ( const T &  Default,
const char *  Option 
)
inline

directly followed arguments

在文件 getpot.h2031 行定义.

参考 _convert_to_type(), _match_starting_string(), _record_argument_request(), argv , 以及 cursor.

参考自 direct_follow().

2032 {
2033  const char* FollowStr = _match_starting_string(Option);
2034 
2035  // (*) record requested of argument for later ufo-detection
2036  _record_argument_request(std::string(Option) + FollowStr);
2037 
2038  if (FollowStr == 0)
2039  return Default;
2040 
2041  if (++cursor >= argv.size())
2042  cursor = getpot_cast_int<unsigned>(argv.size());
2043  return _convert_to_type(FollowStr, Default);
2044 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1569
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
const char * _match_starting_string(const char *StartString)
support finding directly followed arguments
Definition: getpot.h:2060
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
const char * GETPOT_NAMESPACE::GetPot::direct_follow ( const char *  Default,
const char *  Option 
)
inline

在文件 getpot.h2049 行定义.

参考 _internal_managed_copy() , 以及 direct_follow().

2050 {
2051  return _internal_managed_copy(direct_follow(std::string(Default), Option));
2052 }
const char * _internal_managed_copy(const std::string &Arg) const
some functions return a char pointer to a temporarily existing string this function adds them to our ...
Definition: getpot.h:1707
T direct_follow(const T &Default, const char *Option)
directly followed arguments
Definition: getpot.h:2031
void GETPOT_NAMESPACE::GetPot::disable_loop ( )
inline

enable/disable search for an option in loop

在文件 getpot.h361 行定义.

参考 search_loop_f.

参考自 init_multiple_occurrence().

361 { search_loop_f = false; }
void GETPOT_NAMESPACE::GetPot::disable_request_recording ( )
inline

在文件 getpot.h210 行定义.

参考 request_recording_f.

210 { request_recording_f = false; }
void GETPOT_NAMESPACE::GetPot::enable_loop ( )
inline

在文件 getpot.h362 行定义.

参考 search_loop_f.

362 { search_loop_f = true; }
void GETPOT_NAMESPACE::GetPot::enable_request_recording ( )
inline

在文件 getpot.h211 行定义.

参考 request_recording_f.

211 { request_recording_f = true; }
template<typename T >
T GETPOT_NAMESPACE::GetPot::follow ( const T &  Default,
const char *  Option 
)
inline

search for option and get argument at cursor++

在文件 getpot.h1949 行定义.

参考 next() , 以及 search().

参考自 follow().

1950 {
1951  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1952  if (search(Option) == false)
1953  return Default;
1954 
1955  return next(Default);
1956 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1766
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1916
const char * GETPOT_NAMESPACE::GetPot::follow ( const char *  Default,
const char *  Option 
)
inline

在文件 getpot.h1961 行定义.

参考 _internal_managed_copy() , 以及 follow().

1962 {
1963  return _internal_managed_copy(follow(std::string(Default), Option));
1964 }
const char * _internal_managed_copy(const std::string &Arg) const
some functions return a char pointer to a temporarily existing string this function adds them to our ...
Definition: getpot.h:1707
T follow(const T &Default, const char *Option)
search for option and get argument at cursor++
Definition: getpot.h:1949
template<typename T >
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

在文件 getpot.h1999 行定义.

参考 next() , 以及 search().

2000 {
2001  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
2002  if (No == 0)
2003  return Default;
2004 
2005  if (search(P) == true)
2006  return next(Default);
2007 
2008  va_list ap;
2009  va_start(ap, P);
2010  for (unsigned i=1; i<No; i++)
2011  {
2012  char* Opt = va_arg(ap, char *);
2013  if (search(Opt) == true)
2014  {
2015  va_end(ap);
2016  return next(Default);
2017  }
2018  }
2019  va_end(ap);
2020  return Default;
2021 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1766
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1916
template<typename T >
T GETPOT_NAMESPACE::GetPot::follow ( const T &  Default,
unsigned int  No,
const char *  P,
  ... 
)
inline

在文件 getpot.h1972 行定义.

参考 next() , 以及 search().

1973 {
1974  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1975  if (No == 0)
1976  return Default;
1977 
1978  if (search(P) == true)
1979  return next(Default);
1980 
1981  va_list ap;
1982  va_start(ap, P);
1983  for (unsigned i=1; i<No; i++)
1984  {
1985  char* Opt = va_arg(ap, char *);
1986  if (search(Opt) == true)
1987  {
1988  va_end(ap);
1989  return next(Default);
1990  }
1991  }
1992  va_end(ap);
1993  return Default;
1994 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1766
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1916
template<typename T >
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
template<typename T >
T GETPOT_NAMESPACE::GetPot::get ( unsigned int  Idx,
const T &  Default 
) const
inline

在文件 getpot.h1886 行定义.

参考 _convert_to_type() , 以及 argv.

1887 {
1888  if (Idx >= argv.size())
1889  return Default;
1890  return _convert_to_type(argv[Idx], Default);
1891 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1569
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > GETPOT_NAMESPACE::GetPot::get_overridden_variables ( ) const
inline

在文件 getpot.h2650 行定义.

参考 overridden_vars.

2651 {
2652  return overridden_vars;
2653 }
std::set< std::string > overridden_vars
Definition: getpot.h:520
std::set< std::string > GETPOT_NAMESPACE::GetPot::get_requested_arguments ( ) const
inline

Accessors for requested variables.

在文件 getpot.h3884 行定义.

参考 _requested_arguments.

3885 {
3886  return _requested_arguments;
3887 }
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< std::string > GETPOT_NAMESPACE::GetPot::get_requested_sections ( ) const
inline

在文件 getpot.h3902 行定义.

参考 _requested_sections.

3903 {
3904  return _requested_sections;
3905 }
std::set< std::string > _requested_sections
Definition: getpot.h:582
std::set< std::string > GETPOT_NAMESPACE::GetPot::get_requested_variables ( ) const
inline

在文件 getpot.h3893 行定义.

参考 _requested_variables.

3894 {
3895  return _requested_variables;
3896 }
std::set< std::string > _requested_variables
Definition: getpot.h:581
STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_section_names ( ) const
inline

在文件 getpot.h2592 行定义.

参考 section_list.

2593 {
2594  return section_list;
2595 }
STRING_VECTOR section_list
Definition: getpot.h:511
STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_subsection_names ( const std::string &  section_name) const
inline

在文件 getpot.h2600 行定义.

参考 section_list.

2601 {
2602  // GetPot functions should understand user-provided section names
2603  // either with or without a trailing slash.
2604  const std::string full_prefix =
2605  *sec_prefix.rbegin() == '/' ? sec_prefix : sec_prefix + '/';
2606 
2607  const std::size_t full_prefix_len = full_prefix.size();
2608 
2609  // Subsections-of-subsections are in the section_list, so we'll be
2610  // adding subsections multiple times. Using std::set as an
2611  // intermediate data structure helps us check for duplicates with
2612  // O(N log N) rather than O(N^2) cost.
2613  std::set<std::string> subsections;
2614 
2615  STRING_VECTOR returnval;
2616 
2617  for (STRING_VECTOR::const_iterator it = section_list.begin();
2618  it != section_list.end(); ++it)
2619  {
2620  const std::string & section_name = *it;
2621 
2622  // If this section name begins with the prefix
2623  if (section_name.compare(0, full_prefix_len, full_prefix) == 0)
2624  {
2625  const std::size_t next_slash_len =
2626  section_name.find('/', full_prefix_len);
2627 
2628  const std::string subsection_name =
2629  section_name.substr(full_prefix_len,
2630  next_slash_len - full_prefix_len);
2631 
2632  // If there is a subsection, and if this is the first time
2633  // we've seen it, add the prefix-less, postfix-less
2634  // subsection name.
2635  if (!subsection_name.empty() &&
2636  !subsections.count(subsection_name))
2637  {
2638  returnval.push_back(subsection_name);
2639  subsections.insert(subsection_name);
2640  }
2641  }
2642  }
2643 
2644  return returnval;
2645 }
STRING_VECTOR section_list
Definition: getpot.h:511
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const T &  Default 
) const
inline

access variables, but error out if not present scalar values

在文件 getpot.h2369 行定义.

参考 _convert_to_type_no_default(), _request_variable() , 以及 GETPOT_NAMESPACE::GetPot::variable::original.

参考自 get_value_no_default().

2370 {
2371  // (*) recording of requested variables happens in '_request_variable()'
2372  const variable* sv = _request_variable(VarName);
2373  if (sv == 0)
2374  {
2375  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2376  getpot_error();
2377  }
2378  return _convert_to_type_no_default(VarName, sv->original, Default);
2379 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
T _convert_to_type_no_default(const char *VarName, const std::string &String, const T &Default) const
Definition: getpot.h:1634
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const T &  Default 
) const
inline

在文件 getpot.h2385 行定义.

参考 get_value_no_default().

2386 {
2387  return get_value_no_default(VarName.c_str(),Default);
2388 }
T get_value_no_default(const char *VarName, const T &Default) const
access variables, but error out if not present scalar values
Definition: getpot.h:2369
const char * GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const char *  Default 
) const
inline

在文件 getpot.h2393 行定义.

参考 _internal_managed_copy() , 以及 get_value_no_default().

2394 {
2395  return _internal_managed_copy(get_value_no_default(VarName, std::string(Default)));
2396 }
const char * _internal_managed_copy(const std::string &Arg) const
some functions return a char pointer to a temporarily existing string this function adds them to our ...
Definition: getpot.h:1707
T get_value_no_default(const char *VarName, const T &Default) const
access variables, but error out if not present scalar values
Definition: getpot.h:2369
const char * GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const char *  Default 
) const
inline

在文件 getpot.h2401 行定义.

参考 get_value_no_default().

2402 {
2403  return get_value_no_default(VarName.c_str(),Default);
2404 }
T get_value_no_default(const char *VarName, const T &Default) const
access variables, but error out if not present scalar values
Definition: getpot.h:2369
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const T &  Default,
unsigned  Idx 
) const
inline

vectors

template<typename T >
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
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const T &  Default,
unsigned int  Idx 
) const
inline

在文件 getpot.h2410 行定义.

参考 _convert_to_type_no_default(), _request_variable() , 以及 GETPOT_NAMESPACE::GetPot::variable::get_element().

2411 {
2412  // (*) recording of requested variables happens in '_request_variable()'
2413  const variable* sv = _request_variable(VarName);
2414  if (sv == 0)
2415  {
2416  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2417  getpot_error();
2418  }
2419 
2420  const std::string* element = sv->get_element(Idx);
2421  if (element == 0)
2422  {
2423  getpot_cerr << "ERROR: cannot find index "<<Idx<<" of variable "<<VarName<<std::endl;
2424  getpot_error();
2425  }
2426  return _convert_to_type_no_default(VarName, *element, Default);
2427 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
T _convert_to_type_no_default(const char *VarName, const std::string &String, const T &Default) const
Definition: getpot.h:1634
template<typename T >
T GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const T &  Default,
unsigned int  Idx 
) const
inline

在文件 getpot.h2433 行定义.

参考 get_value_no_default().

2434 {
2435  return get_value_no_default(VarName.c_str(), Default, Idx);
2436 }
T get_value_no_default(const char *VarName, const T &Default) const
access variables, but error out if not present scalar values
Definition: getpot.h:2369
STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_variable_names ( ) const
inline

在文件 getpot.h2576 行定义.

参考 _get_remaining_string(), prefix , 以及 variables.

2577 {
2578  STRING_VECTOR result;
2579  std::vector<GetPot::variable>::const_iterator it = variables.begin();
2580  for (; it != variables.end(); ++it)
2581  {
2582  const std::string Tmp = _get_remaining_string((*it).name, prefix);
2583  if (Tmp != "")
2584  result.push_back(Tmp);
2585  }
2586  return result;
2587 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
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.

在文件 getpot.h2258 行定义.

2259 {
2260  std::string s = std::string(section_name);
2261  return this->have_section(s);
2262 }
bool have_section(const char *section_name) const
Check for a section name.
Definition: getpot.h:2258
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.

在文件 getpot.h2265 行定义.

参考 section_list.

2266 {
2267  const char slash('/');
2268 
2269  std::string::const_reverse_iterator it = section_name.rbegin();
2270 
2271  bool found_section = false;
2272 
2273  // Check if section_name ends with a "/". If not, append it for the search since
2274  // the section names are stored with a "/" at the end.
2275  if( (*it) != slash )
2276  // We need to use a linear search because we can't sort section_list
2277  // without violating some assumptions. See libMesh #481 for more discussion.
2278  found_section = ( std::find(section_list.begin(), section_list.end(), section_name+slash) != section_list.end() );
2279  else
2280  found_section = ( std::find(section_list.begin(), section_list.end(), section_name) != section_list.end() );
2281 
2282  return found_section;
2283 }
STRING_VECTOR section_list
Definition: getpot.h:511
bool GETPOT_NAMESPACE::GetPot::have_variable ( const char *  VarName) const
inline

variables

check for a variable

在文件 getpot.h2239 行定义.

参考 _request_variable().

参考自 have_variable().

2240 {
2241  const variable* sv = _request_variable(VarName);
2242 
2243  if (sv == 0)
2244  return false;
2245 
2246  return true;
2247 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
bool GETPOT_NAMESPACE::GetPot::have_variable ( const std::string &  VarName) const
inline

在文件 getpot.h2252 行定义.

参考 have_variable().

2253 {
2254  return have_variable(VarName.c_str());
2255 }
bool have_variable(const char *VarName) const
variables
Definition: getpot.h:2239
void GETPOT_NAMESPACE::GetPot::init_multiple_occurrence ( )
inline

在文件 getpot.h1864 行定义.

参考 disable_loop() , 以及 reset_cursor().

1865 {
1866  disable_loop();
1867  reset_cursor();
1868 }
void disable_loop()
enable/disable search for an option in loop
Definition: getpot.h:361
void reset_cursor()
reset cursor to position &#39;1&#39;
Definition: getpot.h:1855
template<typename T >
T GETPOT_NAMESPACE::GetPot::next ( const T &  Default)
inline

get argument at cursor++

在文件 getpot.h1916 行定义.

参考 _convert_to_type(), _get_remaining_string(), _record_argument_request(), argv, cursor, prefix , 以及 search_failed_f.

参考自 follow() , 以及 next().

1917 {
1918  if (search_failed_f)
1919  return Default;
1920  cursor++;
1921  if (cursor >= argv.size())
1922  {
1923  cursor = getpot_cast_int<unsigned>(argv.size());
1924  return Default;
1925  }
1926 
1927  // (*) record requested argument for later ufo detection
1929 
1930  const std::string Remain = _get_remaining_string(argv[cursor], prefix);
1931 
1932  return Remain != "" ? _convert_to_type(Remain, Default) : Default;
1933 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1569
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
const char * GETPOT_NAMESPACE::GetPot::next ( const char *  Default)
inline

在文件 getpot.h1938 行定义.

参考 _internal_managed_copy() , 以及 next().

1939 {
1940  return _internal_managed_copy(next(std::string(Default)));
1941 }
const char * _internal_managed_copy(const std::string &Arg) const
some functions return a char pointer to a temporarily existing string this function adds them to our ...
Definition: getpot.h:1707
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1916
const char * GETPOT_NAMESPACE::GetPot::next_nominus ( )
inline

在文件 getpot.h2192 行定义.

参考 _internal_managed_copy(), _record_argument_request(), argv, idx_nominus , 以及 nominus_cursor.

2193 {
2194  if (nominus_cursor < int(idx_nominus.size()) - 1)
2195  {
2196  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2197 
2198  // (*) record for later ufo-detection
2200 
2201  return _internal_managed_copy(Tmp);
2202  }
2203 
2204  return 0;
2205 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
const char * _internal_managed_copy(const std::string &Arg) const
some functions return a char pointer to a temporarily existing string this function adds them to our ...
Definition: getpot.h:1707
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::string GETPOT_NAMESPACE::GetPot::next_nominus_string ( )
inline

在文件 getpot.h2209 行定义.

参考 _record_argument_request(), argv, idx_nominus , 以及 nominus_cursor.

2210 {
2211  if (nominus_cursor < int(idx_nominus.size()) - 1)
2212  {
2213  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2214 
2215  // (*) record for later ufo-detection
2217 
2218  return Tmp;
2219  }
2220 
2221  return "";
2222 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
unsigned GETPOT_NAMESPACE::GetPot::nominus_size ( ) const
inline

在文件 getpot.h414 行定义.

参考 idx_nominus.

414 { return getpot_cast_int<unsigned>(idx_nominus.size()); }
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
STRING_VECTOR GETPOT_NAMESPACE::GetPot::nominus_vector ( ) const
inline

在文件 getpot.h2173 行定义.

参考 _record_argument_request(), argv , 以及 idx_nominus.

2174 {
2175  STRING_VECTOR nv;
2176  std::vector<unsigned>::const_iterator it = idx_nominus.begin();
2177  for (; it != idx_nominus.end(); ++it)
2178  {
2179  nv.push_back(argv[*it]);
2180 
2181  // (*) record for later ufo-detection
2182  // when a nominus vector is requested, the entire set of nominus arguments are
2183  // tagged as 'requested'
2185  }
2186  return nv;
2187 }
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const T &  Default 
) const
inline

scalar values

在文件 getpot.h2287 行定义.

参考 _convert_to_type(), _request_variable() , 以及 GETPOT_NAMESPACE::GetPot::variable::original.

参考自 operator()().

2288 {
2289  // (*) recording of requested variables happens in '_request_variable()'
2290  const variable* sv = _request_variable(VarName);
2291 
2292  if (sv == 0)
2293  return Default;
2294 
2295  return _convert_to_type(sv->original, Default);
2296 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1569
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const T &  Default 
) const
inline

在文件 getpot.h2302 行定义.

参考 operator()().

2303 {
2304  return operator()(VarName.c_str(), Default);
2305 }
T operator()(const char *VarName, const T &Default) const
scalar values
Definition: getpot.h:2287
const char * GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const char *  Default 
) const
inline

在文件 getpot.h2310 行定义.

参考 _internal_managed_copy().

2311 {
2312  return _internal_managed_copy(operator()(VarName, std::string(Default)));
2313 }
const char * _internal_managed_copy(const std::string &Arg) const
some functions return a char pointer to a temporarily existing string this function adds them to our ...
Definition: getpot.h:1707
const char * GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const char *  Default 
) const
inline

在文件 getpot.h2318 行定义.

参考 operator()().

2319 {
2320  return operator()(VarName.c_str(), Default);
2321 }
T operator()(const char *VarName, const T &Default) const
scalar values
Definition: getpot.h:2287
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const T &  Default,
unsigned  Idx 
) const
inline

vectors

template<typename T >
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
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const T &  Default,
unsigned int  Idx 
) const
inline

在文件 getpot.h2327 行定义.

参考 _convert_to_type(), _request_variable() , 以及 GETPOT_NAMESPACE::GetPot::variable::get_element().

2328 {
2329  // (*) recording of requested variables happens in '_request_variable()'
2330  const variable* sv = _request_variable(VarName);
2331  if (sv == 0)
2332  return Default;
2333 
2334  const std::string* element = sv->get_element(Idx);
2335  if (element == 0)
2336  return Default;
2337  return _convert_to_type(*element, Default);
2338 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1569
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
template<typename T >
T GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const T &  Default,
unsigned int  Idx 
) const
inline

在文件 getpot.h2344 行定义.

参考 operator()().

2345 {
2346  return operator()(VarName.c_str(), Default, Idx);
2347 }
T operator()(const char *VarName, const T &Default) const
scalar values
Definition: getpot.h:2287
GetPot & GETPOT_NAMESPACE::GetPot::operator= ( const GetPot Other)
inline

在文件 getpot.h1031 行定义.

参考 _comment_end, _comment_start, _field_separator, _internal_string_container, _requested_arguments, _requested_sections, _requested_variables, argv, cursor, idx_nominus, nominus_cursor, overridden_vars, prefix, request_recording_f, search_failed_f, search_loop_f, section, section_list , 以及 variables.

参考自 GETPOT_NAMESPACE::GetPot::variable::variable().

1032 {
1033  if (&Other == this)
1034  return *this;
1035 
1036  prefix = Other.prefix;
1037  section = Other.section;
1038  section_list = Other.section_list;
1039  argv = Other.argv;
1040  cursor = Other.cursor;
1041  search_loop_f = Other.search_loop_f;
1042  search_failed_f = Other.search_failed_f;
1043  nominus_cursor = Other.nominus_cursor;
1044  overridden_vars = Other.overridden_vars;
1045  idx_nominus = Other.idx_nominus;
1046  variables = Other.variables;
1047  _comment_start = Other._comment_start;
1048  _comment_end = Other._comment_end;
1049  _field_separator = Other._field_separator;
1050  // #if !defined(GETPOT_DISABLE_MUTEX)
1051  // _getpot_mtx = Other._getpot_mtx;
1052  // #endif
1053  _requested_arguments = Other._requested_arguments;
1054  _requested_variables = Other._requested_variables;
1055  _requested_sections = Other._requested_sections;
1056  request_recording_f = Other.request_recording_f;
1057 
1058  std::set<const char*, ltstr>::const_iterator my_it =
1060  const std::set<const char*, ltstr>::const_iterator my_end =
1062 
1063  for (; my_it != my_end; ++my_it)
1064  delete [] *my_it;
1065 
1067 
1068  std::set<const char*,ltstr>::const_iterator it =
1069  Other._internal_string_container.begin();
1070  const std::set<const char*,ltstr>::const_iterator end =
1071  Other._internal_string_container.end();
1072 
1073  for (; it != end; ++it)
1074  {
1075  const char* otherstr = *it;
1076  const std::size_t bufsize = strlen(otherstr)+1;
1077  char* newcopy = new char[bufsize];
1078  strncpy(newcopy, otherstr, bufsize);
1079  this->_internal_string_container.insert(newcopy);
1080  }
1081 
1082  return *this;
1083 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
std::string section
Definition: getpot.h:510
std::vector< unsigned > idx_nominus
Definition: getpot.h:526
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::set< std::string > _requested_variables
Definition: getpot.h:581
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
STRING_VECTOR section_list
Definition: getpot.h:511
std::string _comment_start
comment delimiters
Definition: getpot.h:536
std::set< std::string > overridden_vars
Definition: getpot.h:520
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::set< const char *, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:568
const char * GETPOT_NAMESPACE::GetPot::operator[] ( unsigned  Idx) const
inline

direct access to command line arguments

在文件 getpot.h1877 行定义.

参考 argv.

1878 {
1879  return idx<argv.size() ? argv[idx].c_str() : 0;
1880 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
bool GETPOT_NAMESPACE::GetPot::options_contain ( const char *  FlagList) const
inline

flags

在文件 getpot.h2104 行定义.

参考 _check_flags(), _get_remaining_string(), argv , 以及 prefix.

2105 {
2106  // go through all arguments that start with a '-' (but not '--')
2107  std::string str;
2108  STRING_VECTOR::const_iterator it = argv.begin();
2109  for (; it != argv.end(); ++it)
2110  {
2111  str = _get_remaining_string(*it, prefix);
2112 
2113  if (str.length() >= 2 && str[0] == '-' && str[1] != '-')
2114  if (_check_flags(str, FlagList))
2115  return true;
2116  }
2117  return false;
2118 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
bool _check_flags(const std::string &Str, const char *FlagList) const
support search for flags in a specific argument
Definition: getpot.h:2158
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
void GETPOT_NAMESPACE::GetPot::parse_command_line ( const int  argc_,
const char *const *  argv_,
const char *  FieldSeparator = 0x0 
)
inline

Re-initialization methods.

在文件 getpot.h805 行定义.

参考 _basic_initialization(), _field_separator , 以及 _parse_argument_vector().

参考自 GetPot().

807 {
809 
810  // if specified -> overwrite default string
811  if (FieldSeparator)
812  _field_separator = std::string(FieldSeparator);
813 
814  // -- make an internal copy of the argument list:
815  STRING_VECTOR _apriori_argv;
816  // -- for the sake of clarity: we do want to include the first
817  // argument of the first parsing source in the argument vector!
818  // it will not be a nominus argument, though. This gives us a
819  // minimum vector size of one which facilitates error checking
820  // in many functions. Also the user will be able to retrieve
821  // the name of his application or input file by "get[0]"
822  _apriori_argv.push_back(std::string(argv_[0]));
823  for (int i=1; i<argc_; i++)
824  {
825  std::string tmp(argv_[i]); // recall the problem with temporaries,
826  _apriori_argv.push_back(tmp); // reference counting in argument lists ...
827  }
828  _parse_argument_vector(_apriori_argv);
829 }
void _parse_argument_vector(const STRING_VECTOR &ARGV)
produce three basic data vectors:
Definition: getpot.h:1131
void _basic_initialization()
Definition: getpot.h:721
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
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

在文件 getpot.h898 行定义.

参考 parse_input_stream().

参考自 _parse_argument_vector() , 以及 GetPot().

902 {
903  std::ifstream input(FileName.c_str());
904 
905  if (!input)
906  getpot_file_error(FileName);
907 
908  this->parse_input_stream(input,FileName,CommentStart,CommentEnd,FieldSeparator);
909 }
void parse_input_stream(std::istream &FileStream, const std::string &FileName=std::string("ParsedFromStream"), const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\n"), const std::string &FieldSeparator=std::string(" \t\n"))
Definition: getpot.h:946
void GETPOT_NAMESPACE::GetPot::parse_input_stream ( std::istream &  FileStream,
const std::string &  FileName = std::string("ParsedFromStream"),
const std::string &  CommentStart = std::string("#"),
const std::string &  CommentEnd = std::string("\n"),
const std::string &  FieldSeparator = std::string(" \t\n") 
)
inline

在文件 getpot.h946 行定义.

参考 _basic_initialization(), _comment_end, _comment_start, _field_separator, _parse_argument_vector() , 以及 _read_in_stream().

参考自 GetPot() , 以及 parse_input_file().

951 {
953 
954  // overwrite default strings
955  _comment_start = std::string(CommentStart);
956  _comment_end = std::string(CommentEnd);
957  _field_separator = FieldSeparator;
958 
959  STRING_VECTOR _apriori_argv;
960  // -- the first element of the argument vector stores the name of
961  // the first parsing source; however, this element is not
962  // parsed for variable assignments or nominuses.
963  //
964  // Regardless, we don't add more than one name to the argument
965  // vector. In this case, we're parsing from a stream, so we'll
966  // hardcode the "filename" to "ParsedFromStream"
967  _apriori_argv.push_back(FileName);
968 
969  STRING_VECTOR args = _read_in_stream(FileStream);
970  _apriori_argv.insert(_apriori_argv.begin()+1, args.begin(), args.end());
971  _parse_argument_vector(_apriori_argv);
972 }
STRING_VECTOR _read_in_stream(std::istream &istr)
Definition: getpot.h:1234
void _parse_argument_vector(const STRING_VECTOR &ARGV)
produce three basic data vectors:
Definition: getpot.h:1131
void _basic_initialization()
Definition: getpot.h:721
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:542
std::string _comment_end
Definition: getpot.h:537
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
std::string _comment_start
comment delimiters
Definition: getpot.h:536
int GETPOT_NAMESPACE::GetPot::print ( std::ostream &  out_stream = std::cout) const
inline

output

Print everything

在文件 getpot.h2689 行定义.

参考 argv.

2690 {
2691  out_stream << "argc = " << argv.size() << std::endl;
2692  STRING_VECTOR::const_iterator it = argv.begin();
2693  for (; it != argv.end(); ++it)
2694  out_stream << *it << std::endl;
2695  out_stream << std::endl;
2696  return 1;
2697 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
int GETPOT_NAMESPACE::GetPot::print ( const char *  custom_prefix,
std::ostream &  out_stream = std::cout,
unsigned int  skip_count = 1 
) const
inline

Print everything after skipping skip_count arguments, with a custom prefix.

skip_count defaults to 1 to handle the common "executable input_file" command line case.

在文件 getpot.h2707 行定义.

参考 argv.

2708 {
2709  STRING_VECTOR::const_iterator it = argv.begin();
2710  it += skip_count;
2711  for (; it != argv.end(); ++it)
2712  {
2713  out_stream << custom_prefix;
2714  out_stream << *it << std::endl;
2715  }
2716  out_stream << std::endl;
2717  return 1;
2718 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
void GETPOT_NAMESPACE::GetPot::reset_cursor ( )
inline

reset cursor to position '1'

在文件 getpot.h1855 行定义.

参考 cursor , 以及 search_failed_f.

参考自 init_multiple_occurrence().

1856 {
1857  search_failed_f = false;
1858  cursor = 0;
1859 }
void GETPOT_NAMESPACE::GetPot::reset_nominus_cursor ( )
inline

nominus arguments

在文件 getpot.h2227 行定义.

参考 nominus_cursor.

2228 {
2229  nominus_cursor = -1;
2230 }
int nominus_cursor
nominus vector
Definition: getpot.h:525
bool GETPOT_NAMESPACE::GetPot::search ( const char *  option)
inline

search for a certain option and set cursor to position

在文件 getpot.h1766 行定义.

参考 _record_argument_request(), argv, cursor, prefix, search_failed_f , 以及 search_loop_f.

参考自 follow() , 以及 search().

1767 {
1768  unsigned OldCursor = cursor;
1769  const std::string SearchTerm = prefix + Option;
1770 
1771  // (*) record requested arguments for later ufo detection
1772  _record_argument_request(SearchTerm);
1773 
1774  if (OldCursor >= argv.size())
1775  OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
1776  search_failed_f = true;
1777 
1778  // (*) first loop from cursor position until end
1779  for (unsigned c = cursor; c < argv.size(); c++)
1780  {
1781  if (argv[c] == SearchTerm)
1782  {
1783  cursor = c;
1784  search_failed_f = false;
1785  return true;
1786  }
1787  }
1788  if (!search_loop_f)
1789  return false;
1790 
1791  // (*) second loop from 0 to old cursor position
1792  for (unsigned c = 1; c <= OldCursor; c++)
1793  {
1794  if (argv[c] == SearchTerm)
1795  {
1796  cursor = c;
1797  search_failed_f = false;
1798  return true;
1799  }
1800  }
1801 
1802  // in case nothing is found the cursor stays where it was
1803  return false;
1804 }
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
bool GETPOT_NAMESPACE::GetPot::search ( const std::string &  option)
inline

在文件 getpot.h1757 行定义.

参考 search().

1758 {
1759  return search(Option.c_str());
1760 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1766
bool GETPOT_NAMESPACE::GetPot::search ( unsigned  No,
const char *  P,
  ... 
)
inline

在文件 getpot.h1809 行定义.

参考 _record_argument_request() , 以及 search().

1810 {
1811  // (*) recording the requested arguments happens in subroutine 'search'
1812  if (No == 0)
1813  return false;
1814 
1815  // search for the first argument
1816  if (search(P) == true)
1817  return true;
1818 
1819  // start interpreting variable argument list
1820  va_list ap;
1821  va_start(ap, P);
1822  unsigned i = 1;
1823  for (; i < No; i++)
1824  {
1825  char* Opt = va_arg(ap, char *);
1826  // (*) search records itself for later ufo detection
1827  if (search(Opt) == true)
1828  break;
1829  }
1830 
1831  if (i < No)
1832  {
1833  i++;
1834  // loop was left before end of array --> hit but
1835  // make sure that the rest of the search terms is marked
1836  // as requested.
1837  for (; i < No; i++)
1838  {
1839  char* Opt = va_arg(ap, char *);
1840  // (*) record requested arguments for later ufo detection
1842  }
1843  va_end(ap);
1844  return true;
1845  }
1846 
1847  va_end(ap);
1848  // loop was left normally --> no hit
1849  return false;
1850 }
void _record_argument_request(const std::string &Arg) const
if an argument is requested record it and the &#39;tag&#39; the section branch to which it belongs...
Definition: getpot.h:2457
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1766
bool GETPOT_NAMESPACE::GetPot::search_failed ( ) const
inline

在文件 getpot.h356 行定义.

参考 search_failed_f.

356 { return search_failed_f; }
template<typename T >
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

在文件 getpot.h2522 行定义.

参考 _set_variable().

参考自 set().

2523 {
2524  std::ostringstream string_value;
2525  string_value << Value;
2526  _set_variable(VarName, string_value.str().c_str(), Requested);
2527 }
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
helper functions
Definition: getpot.h:2503
template<typename T >
void GETPOT_NAMESPACE::GetPot::set ( const std::string &  VarName,
const T &  Value,
const bool  Requested = true 
)
inline

在文件 getpot.h2533 行定义.

参考 set().

2534 {
2535  set(VarName.c_str(), Value, Requested);
2536 }
void set(const char *VarName, const T &Value, const bool Requested=true)
setting variables i) from outside of GetPot (considering prefix etc.) ii) from inside, use &#39;_set_variable()&#39; below
Definition: getpot.h:2522
void GETPOT_NAMESPACE::GetPot::set ( const char *  VarName,
const char *  Value,
const bool  Requested = true 
)
inline

在文件 getpot.h2541 行定义.

参考 _set_variable().

2542 {
2543  _set_variable(VarName, Value, Requested);
2544 }
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
helper functions
Definition: getpot.h:2503
void GETPOT_NAMESPACE::GetPot::set ( const std::string &  VarName,
const char *  Value,
const bool  Requested = true 
)
inline

在文件 getpot.h2549 行定义.

参考 set().

2550 {
2551  set(VarName.c_str(), Value, Requested);
2552 }
void set(const char *VarName, const T &Value, const bool Requested=true)
setting variables i) from outside of GetPot (considering prefix etc.) ii) from inside, use &#39;_set_variable()&#39; below
Definition: getpot.h:2522
void GETPOT_NAMESPACE::GetPot::set_prefix ( const char *  Prefix)
inline

cursor oriented functions

在文件 getpot.h355 行定义.

参考 prefix.

355 { prefix = std::string(Prefix); }
std::string prefix
member variables
Definition: getpot.h:509
unsigned GETPOT_NAMESPACE::GetPot::size ( ) const
inline

在文件 getpot.h1906 行定义.

参考 argv.

参考自 _DBE_expand().

1907 {
1908  return getpot_cast_int<unsigned>(argv.size());
1909 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( unsigned  Number,
const char *  Known,
  ... 
) const
inline

unidentified flying objects

在文件 getpot.h3447 行定义.

参考 unidentified_arguments().

3449 {
3450  std::set<std::string> known_arguments;
3451 
3452  // (1) create a vector of known arguments
3453  if (Number == 0)
3454  return STRING_VECTOR();
3455 
3456  va_list ap;
3457  va_start(ap, KnownArgument1);
3458  known_arguments.insert(std::string(KnownArgument1));
3459  for (unsigned i=1; i<Number; i++)
3460  known_arguments.insert(std::string(va_arg(ap, char *)));
3461  va_end(ap);
3462 
3463  return unidentified_arguments(known_arguments);
3464 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3469
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( const std::set< std::string > &  Knowns) const
inline

在文件 getpot.h3487 行定义.

参考 _get_remaining_string(), argv , 以及 prefix.

3488 {
3489  STRING_VECTOR ufos;
3490  STRING_VECTOR::const_iterator it = argv.begin();
3491  ++it; // forget about argv[0] (application or filename)
3492  for (; it != argv.end(); ++it)
3493  {
3494  // -- argument belongs to prefixed section ?
3495  const std::string arg = _get_remaining_string(*it, prefix);
3496  if (arg == "")
3497  continue;
3498 
3499  // -- check if in list
3500  if (Knowns.find(arg) == Knowns.end())
3501  ufos.push_back(*it);
3502  }
3503  return ufos;
3504 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( const std::vector< std::string > &  Knowns) const
inline

在文件 getpot.h3477 行定义.

参考 unidentified_arguments().

3478 {
3479  // We use set for efficiency, but want to support vector inputs for
3480  // backwards compatibility.
3481  return unidentified_arguments(std::set<std::string> (Knowns.begin(), Knowns.end()));
3482 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3469
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_arguments ( ) const
inline

在文件 getpot.h3469 行定义.

参考 _requested_arguments.

参考自 unidentified_arguments() , 以及 unidentified_options().

3470 {
3472 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3469
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
std::string GETPOT_NAMESPACE::GetPot::unidentified_flags ( const char *  Known,
int  ArgumentNumber = -1 
) const
inline

在文件 getpot.h3585 行定义.

参考 _get_remaining_string(), argv , 以及 prefix.

3586 {
3587  std::string ufos;
3588  // STRING_VECTOR known_arguments;
3589  std::string KFL(KnownFlagList);
3590 
3591  // (2) iteration over '-' arguments (options)
3592  if (ArgumentNumber == -1)
3593  {
3594  STRING_VECTOR::const_iterator it = argv.begin();
3595  ++it; // forget about argv[0] (application or filename)
3596  for (; it != argv.end(); ++it)
3597  {
3598  // -- argument belongs to prefixed section ?
3599  const std::string arg = _get_remaining_string(*it, prefix);
3600  if (arg == "") continue;
3601 
3602  // -- does arguments start with '-' (but not '--')
3603  if (arg.length() < 2)
3604  continue;
3605 
3606  else if (arg[0] != '-')
3607  continue;
3608 
3609  else if (arg[1] == '-')
3610  continue;
3611 
3612  // -- check out if flags inside option are contained in KnownFlagList
3613  const char* p=arg.c_str();
3614  p++; // skip starting minus
3615  for (; *p != '\0' ; p++)
3616  if (KFL.find(*p) == std::string::npos) ufos += *p;
3617  }
3618  }
3619  // (1) check specific argument
3620  else
3621  {
3622  // -- only check arguments that start with prefix
3623  int no_matches = 0;
3624  for (unsigned i=1; i<argv.size(); i++)
3625  {
3626  const std::string Remain = _get_remaining_string(argv[i], prefix);
3627  if (Remain != "")
3628  {
3629  no_matches++;
3630  if (no_matches == ArgumentNumber)
3631  {
3632  // -- the right argument number inside the section is found
3633  // => check it for flags
3634  const char* p = Remain.c_str();
3635  p++; // skip starting minus
3636  for (; *p != '\0' ; p++)
3637  if (KFL.find(*p) == std::string::npos) ufos += *p;
3638  return ufos;
3639  }
3640  }
3641  }
3642  }
3643  return ufos;
3644 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( unsigned  Number,
const char *  Known,
  ... 
) const
inline

在文件 getpot.h3782 行定义.

参考 unidentified_nominuses().

3783 {
3784  std::set<std::string> known_nominuses;
3785 
3786  // create vector of known arguments
3787  if (Number == 0)
3788  return STRING_VECTOR();
3789 
3790  va_list ap;
3791  va_start(ap, Known);
3792  known_nominuses.insert(std::string(Known));
3793  for (unsigned i=1; i<Number; i++)
3794  {
3795  std::string tmp = std::string(va_arg(ap, char *));
3796  if (tmp.length() == 0)
3797  continue;
3798  known_nominuses.insert(tmp);
3799  }
3800  va_end(ap);
3801 
3802  return unidentified_nominuses(known_nominuses);
3803 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3808
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( const std::set< std::string > &  Knowns) const
inline

在文件 getpot.h3833 行定义.

参考 _get_remaining_string(), argv , 以及 prefix.

3834 {
3835  STRING_VECTOR ufos;
3836 
3837  // (2) iterate over all arguments
3838  STRING_VECTOR::const_iterator it = argv.begin();
3839  ++it; // forget about argv[0] (application or filename)
3840  for (; it != argv.end(); ++it)
3841  {
3842  // -- check if nominus part of prefix
3843  const std::string arg = _get_remaining_string(*it, prefix);
3844  if (arg == "")
3845  continue;
3846 
3847  if (arg.length() < 1)
3848  continue;
3849 
3850  // option ? --> not a nomius
3851  if (arg[0] == '-')
3852  continue;
3853 
3854  // section ? --> not a real nominus
3855  if (arg[0] == '[' && arg[arg.length()-1] == ']')
3856  continue;
3857 
3858  // variable definition ? --> not a real nominus
3859  bool continue_f = false;
3860  for (unsigned i=0; i<arg.length() ; i++)
3861  if (arg[i] == '=')
3862  {
3863  continue_f = true;
3864  break;
3865  }
3866 
3867  if (continue_f)
3868  continue;
3869 
3870  // real nominuses are compared with the given list
3871  if (Knowns.find(arg) == Knowns.end())
3872  ufos.push_back(*it);
3873  }
3874  return ufos;
3875 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( const std::vector< std::string > &  Knowns) const
inline

在文件 getpot.h3823 行定义.

参考 unidentified_nominuses().

3824 {
3825  // We use set for efficiency, but want to support vector inputs for
3826  // backwards compatibility.
3827  return unidentified_nominuses(std::set<std::string> (Knowns.begin(), Knowns.end()));
3828 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3808
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_nominuses ( ) const
inline

在文件 getpot.h3808 行定义.

参考 _requested_arguments.

参考自 unidentified_nominuses().

3809 {
3810  // -- every nominus is an argument.
3811  // -- the set of requested arguments contains the set of requested nominuss.
3812  // -- IF the set of requested arguments contains unrequested nominuss,
3813  // THEN they were requested as 'follow' and 'next' arguments and not as real nominuses.
3814  //
3815  // => it is not necessary to separate requested nominus from the list
3816 
3818 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3808
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( unsigned  Number,
const char *  Known,
  ... 
) const
inline

在文件 getpot.h3509 行定义.

参考 unidentified_options().

3511 {
3512  std::set<std::string> known_options;
3513 
3514  // (1) create a vector of known arguments
3515  if (Number == 0)
3516  return STRING_VECTOR();
3517 
3518  va_list ap;
3519  va_start(ap, KnownOption1);
3520  known_options.insert(std::string(KnownOption1));
3521  for (unsigned i=1; i<Number; i++)
3522  known_options.insert(std::string(va_arg(ap, char *)));
3523  va_end(ap);
3524 
3525  return unidentified_options(known_options);
3526 }
STRING_VECTOR unidentified_options() const
Definition: getpot.h:3531
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( const std::set< std::string > &  Knowns) const
inline

在文件 getpot.h3555 行定义.

参考 _get_remaining_string(), argv , 以及 prefix.

3556 {
3557  STRING_VECTOR ufos;
3558  STRING_VECTOR::const_iterator it = argv.begin();
3559  ++it; // forget about argv[0] (application or filename)
3560  for (; it != argv.end(); ++it)
3561  {
3562  // -- argument belongs to prefixed section ?
3563  const std::string arg = _get_remaining_string(*it, prefix);
3564  if (arg == "")
3565  continue;
3566 
3567  // is argument really an option (starting with '-') ?
3568  if (arg.length() < 1 || arg[0] != '-')
3569  continue;
3570 
3571  if (Knowns.find(arg) == Knowns.end())
3572  ufos.push_back(*it);
3573  }
3574 
3575  return ufos;
3576 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR argv
argument vector
Definition: getpot.h:516
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( const std::vector< std::string > &  Knowns) const
inline

在文件 getpot.h3545 行定义.

参考 unidentified_options().

3546 {
3547  // We use set for efficiency, but want to support vector inputs for
3548  // backwards compatibility.
3549  return unidentified_options(std::set<std::string> (Knowns.begin(), Knowns.end()));
3550 }
STRING_VECTOR unidentified_options() const
Definition: getpot.h:3531
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_options ( ) const
inline

在文件 getpot.h3531 行定义.

参考 _requested_arguments , 以及 unidentified_arguments().

参考自 unidentified_options().

3532 {
3533  // -- every option is an argument.
3534  // -- the set of requested arguments contains the set of requested options.
3535  // -- IF the set of requested arguments contains unrequested options,
3536  // THEN they were requested as 'follow' and 'next' arguments and not as real options.
3537  //
3538  // => it is not necessary to separate requested options from the list
3540 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3469
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:580
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( unsigned  Number,
const char *  Known,
  ... 
) const
inline

在文件 getpot.h3710 行定义.

参考 unidentified_sections().

3712 {
3713  std::set<std::string> known_sections;
3714 
3715  // (1) create a vector of known arguments
3716  if (Number == 0)
3717  return STRING_VECTOR();
3718 
3719  va_list ap;
3720  va_start(ap, KnownSection1);
3721  known_sections.insert(std::string(KnownSection1));
3722  for (unsigned i=1; i<Number; i++)
3723  {
3724  std::string tmp = std::string(va_arg(ap, char *));
3725 
3726  if (tmp.length() == 0)
3727  continue;
3728 
3729  if (tmp[tmp.length()-1] != '/')
3730  tmp += '/';
3731 
3732  known_sections.insert(tmp);
3733  }
3734  va_end(ap);
3735 
3736  return unidentified_sections(known_sections);
3737 }
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3742
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( const std::set< std::string > &  Knowns) const
inline

在文件 getpot.h3760 行定义.

参考 _get_remaining_string(), prefix , 以及 section_list.

3761 {
3762  STRING_VECTOR ufos;
3763 
3764  victorate(std::string, section_list, it)
3765  {
3766  // -- check if section conform to prefix
3767  const std::string sec_name = _get_remaining_string(*it, prefix);
3768  if (sec_name == "")
3769  continue;
3770 
3771  // -- check if section is known
3772  if (Knowns.find(sec_name) == Knowns.end())
3773  ufos.push_back(*it);
3774  }
3775 
3776  return ufos;
3777 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
STRING_VECTOR section_list
Definition: getpot.h:511
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( const std::vector< std::string > &  Knowns) const
inline

在文件 getpot.h3750 行定义.

参考 unidentified_sections().

3751 {
3752  // We use set for efficiency, but want to support vector inputs for
3753  // backwards compatibility.
3754  return unidentified_sections(std::set<std::string> (Knowns.begin(), Knowns.end()));
3755 }
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3742
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_sections ( ) const
inline

在文件 getpot.h3742 行定义.

参考 _requested_sections.

参考自 unidentified_sections().

3743 {
3745 }
std::set< std::string > _requested_sections
Definition: getpot.h:582
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3742
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( unsigned  Number,
const char *  Known,
  ... 
) const
inline

在文件 getpot.h3649 行定义.

参考 unidentified_variables().

3651 {
3652  std::set<std::string> known_variables;
3653 
3654  // create vector of known arguments
3655  if (Number == 0)
3656  return STRING_VECTOR();
3657 
3658  va_list ap;
3659  va_start(ap, KnownVariable1);
3660  known_variables.insert(std::string(KnownVariable1));
3661  for (unsigned i=1; i<Number; i++)
3662  known_variables.insert(std::string(va_arg(ap, char *)));
3663  va_end(ap);
3664 
3665  return unidentified_variables(known_variables);
3666 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3702
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( const std::set< std::string > &  Knowns) const
inline

在文件 getpot.h3681 行定义.

参考 _get_remaining_string(), prefix , 以及 variables.

3682 {
3683  STRING_VECTOR ufos;
3684 
3685  victorate(GetPot::variable, variables, it)
3686  {
3687  // -- check if variable has specific prefix
3688  const std::string var_name = _get_remaining_string((*it).name, prefix);
3689  if (var_name == "")
3690  continue;
3691 
3692  // -- check if variable is known
3693  if (Knowns.find(var_name) == Knowns.end())
3694  ufos.push_back((*it).name);
3695  }
3696  return ufos;
3697 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1739
std::string prefix
member variables
Definition: getpot.h:509
std::vector< variable > variables
variables (arguments of the form &quot;variable=value&quot;)
Definition: getpot.h:531
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:133
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( const std::vector< std::string > &  Knowns) const
inline

在文件 getpot.h3671 行定义.

参考 unidentified_variables().

3672 {
3673  // We use set for efficiency, but want to support vector inputs for
3674  // backwards compatibility.
3675  return unidentified_variables(std::set<std::string> (Knowns.begin(), Knowns.end()));
3676 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3702
STRING_VECTOR GETPOT_NAMESPACE::GetPot::unidentified_variables ( ) const
inline

在文件 getpot.h3702 行定义.

参考 _requested_variables.

参考自 unidentified_variables().

3703 {
3705 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3702
std::set< std::string > _requested_variables
Definition: getpot.h:581
unsigned GETPOT_NAMESPACE::GetPot::vector_variable_size ( const char *  VarName) const
inline

在文件 getpot.h2557 行定义.

参考 _request_variable() , 以及 GETPOT_NAMESPACE::GetPot::variable::value.

参考自 vector_variable_size().

2558 {
2559  const variable* sv = _request_variable(VarName);
2560  if (sv == 0)
2561  return 0;
2562  return (unsigned)(sv->value.size());
2563 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2674
unsigned GETPOT_NAMESPACE::GetPot::vector_variable_size ( const std::string &  VarName) const
inline

在文件 getpot.h2568 行定义.

参考 vector_variable_size().

2569 {
2570  return vector_variable_size(VarName.c_str());
2571 }
unsigned vector_variable_size(const char *VarName) const
Definition: getpot.h:2557

类成员变量说明

std::string GETPOT_NAMESPACE::GetPot::_comment_end
private
std::string GETPOT_NAMESPACE::GetPot::_comment_start
private
std::string GETPOT_NAMESPACE::GetPot::_field_separator
private

field separator (separating elements of a vector)

在文件 getpot.h542 行定义.

参考自 _basic_initialization(), _parse_argument_vector(), _set_variable(), operator=(), parse_command_line() , 以及 parse_input_stream().

std::set<const char*, ltstr> GETPOT_NAMESPACE::GetPot::_internal_string_container
mutableprivate

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

在文件 getpot.h568 行定义.

参考自 _internal_managed_copy(), GetPot(), operator=() , 以及 ~GetPot().

std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_arguments
mutableprivate

keeping track about arguments that are requested, so that the UFO detection can be simplified

在文件 getpot.h580 行定义.

参考自 _parse_argument_vector(), _record_argument_request(), absorb(), clear_requests(), get_requested_arguments(), operator=(), unidentified_arguments(), unidentified_nominuses() , 以及 unidentified_options().

std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_sections
mutableprivate
std::set<std::string> GETPOT_NAMESPACE::GetPot::_requested_variables
mutableprivate
STRING_VECTOR GETPOT_NAMESPACE::GetPot::argv
private
unsigned GETPOT_NAMESPACE::GetPot::cursor
private
GETPOT_NAMESPACE::GetPot::GETPOT_MUTEX_DECLARE
private

we have some mutable non-thread-safe members, but we want to be able to call const member functions from multiple threads at once, so we'll wrap access to mutable objects in a mutex.

在文件 getpot.h558 行定义.

std::vector<unsigned> GETPOT_NAMESPACE::GetPot::idx_nominus
private
int GETPOT_NAMESPACE::GetPot::nominus_cursor
private

nominus vector

在文件 getpot.h525 行定义.

参考自 _basic_initialization(), next_nominus(), next_nominus_string(), operator=() , 以及 reset_nominus_cursor().

std::set<std::string> GETPOT_NAMESPACE::GetPot::overridden_vars
private

在文件 getpot.h520 行定义.

参考自 _set_variable(), get_overridden_variables() , 以及 operator=().

std::string GETPOT_NAMESPACE::GetPot::prefix
private
bool GETPOT_NAMESPACE::GetPot::request_recording_f
private
bool GETPOT_NAMESPACE::GetPot::search_failed_f
private
bool GETPOT_NAMESPACE::GetPot::search_loop_f
private
std::string GETPOT_NAMESPACE::GetPot::section
private
STRING_VECTOR GETPOT_NAMESPACE::GetPot::section_list
private
std::vector<variable> GETPOT_NAMESPACE::GetPot::variables
private

variables (arguments of the form "variable=value")

在文件 getpot.h531 行定义.

参考自 _find_variable(), _set_variable(), absorb(), get_variable_names(), operator=() , 以及 unidentified_variables().


该类的文档由以下文件生成: