libMesh
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
GETPOT_NAMESPACE::GetPot Class Reference

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

#include <getpot.h>

Classes

struct  ltstr
 Transparent comparator object used for making std::sets that contain unique_ptrs. More...
 
struct  variable
 Variable to be specified on the command line or in input files. More...
 

Public Member Functions

 GetPot ()
 constructors, destructor, assignment operator More...
 
 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("\), const std::string &FieldSeparator=std::string(" \\"))
 
 GetPot (std::istream &FileStream, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\), const std::string &FieldSeparator=std::string(" \\"))
 This constructor is mainly for testing. More...
 
 ~GetPot ()
 
GetPotoperator= (const GetPot &)
 
void parse_command_line (const int argc_, const char *const *argv_, const char *FieldSeparator=0x0)
 Re-initialization methods. More...
 
void parse_input_file (const std::string &FileName, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\), const std::string &FieldSeparator=std::string(" \\"))
 
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("\), const std::string &FieldSeparator=std::string(" \\"))
 
void absorb (const GetPot &Other)
 absorbing contents of another GetPot object More...
 
void clear_requests ()
 for ufo detection: recording requested arguments, options etc. More...
 
void disable_request_recording ()
 
void enable_request_recording ()
 
const char * operator[] (unsigned Idx) const
 direct access to command line arguments More...
 
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 More...
 
bool argument_contains (unsigned Idx, const char *FlagList) const
 
bool have_variable (const char *VarName) const
 variables More...
 
bool have_variable (const std::string &VarName) const
 
bool have_section (const char *section_name) const
 Check for a section name. More...
 
bool have_section (const std::string &section_name) const
 Check for a section name. More...
 
template<typename T >
operator() (const char *VarName, const T &Default) const
 scalar values More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
bool search_failed () const
 
void disable_loop ()
 enable/disable search for an option in loop More...
 
void enable_loop ()
 
void reset_cursor ()
 reset cursor to position '1' More...
 
void init_multiple_occurrence ()
 
bool search (const char *option)
 search for a certain option and set cursor to position More...
 
bool search (const std::string &option)
 
bool search (unsigned No, const char *P,...)
 
template<typename T >
next (const T &Default)
 get argument at cursor++ More...
 
const char * next (const char *Default)
 
template<typename T >
follow (const T &Default, const char *Option)
 search for option and get argument at cursor++ More...
 
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 More...
 
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 More...
 
const char * direct_follow (const char *Default, const char *Option)
 
void reset_nominus_cursor ()
 nominus arguments More...
 
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 More...
 
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. More...
 
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 More...
 
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. More...
 
template<>
std::string _convert_to_type (const std::string &String, const std::string &) const
 
template<>
std::string _convert_to_type_no_default (const char *, const std::string &String, const std::string &) const
 
template<typename T >
get (unsigned int Idx, const T &Default) const
 
template<typename T >
follow (const T &Default, unsigned int No, const char *P,...)
 
template<typename T >
operator() (const char *VarName, const T &Default, unsigned int Idx) const
 
template<typename T >
operator() (const std::string &VarName, const T &Default, unsigned int Idx) const
 
template<typename T >
get_value_no_default (const char *VarName, const T &Default, unsigned int Idx) const
 
template<typename T >
get_value_no_default (const std::string &VarName, const T &Default, unsigned int Idx) const
 

Private Member Functions

void _basic_initialization ()
 
const char * _internal_managed_copy (const std::string &Arg) const
 some functions return a char pointer to a temporarily existing string this function adds them to our container More...
 
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. More...
 
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 More...
 
void _parse_argument_vector (const STRING_VECTOR &ARGV)
 produce three basic data vectors: More...
 
const variable_find_variable (const char *) const
 helpers for argument list processing More...
 
const variable_request_variable (const char *) const
 search (and record request) for a variable in 'variables' array More...
 
const char * _match_starting_string (const char *StartString)
 support finding directly followed arguments More...
 
bool _check_flags (const std::string &Str, const char *FlagList) const
 support search for flags in a specific argument More...
 
template<typename T >
_convert_to_type (const std::string &String, const T &Default) const
 type conversion if possible More...
 
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 More...
 
bool _search_string_vector (const STRING_VECTOR &Vec, const std::string &Str) const
 search for a specific string More...
 
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. More...
 
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 More...
 
std::string _DBE_expand (const std::string &str)
 
const GetPot::variable_DBE_get_variable (const std::string &str)
 
STRING_VECTOR _DBE_get_expr_list (const std::string &str, const unsigned ExpectedNumber)
 
template<>
bool _convert_to_type (const std::string &String, const bool &Default) const
 
template<>
bool _convert_to_type_no_default (const char *VarName, const std::string &String, const bool &) const
 

Static Private Member Functions

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

Private Attributes

std::string prefix
 member variables More...
 
std::string section
 
STRING_VECTOR section_list
 
STRING_VECTOR argv
 argument vector More...
 
unsigned cursor
 
bool search_loop_f
 
bool search_failed_f
 
std::set< std::string > overridden_vars
 
int nominus_cursor
 nominus vector More...
 
std::vector< unsigned > idx_nominus
 
std::vector< variablevariables
 variables (arguments of the form "variable=value") More...
 
std::string _comment_start
 comment delimiters More...
 
std::string _comment_end
 
std::string _field_separator
 field separator (separating elements of a vector) More...
 
 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. More...
 
std::set< std::unique_ptr< const char[]>, ltstr_internal_string_container
 some functions return a char pointer to a string created on the fly. More...
 
std::set< std::string > _requested_arguments
 keeping track about arguments that are requested, so that the UFO detection can be simplified More...
 
std::set< std::string > _requested_variables
 
std::set< std::string > _requested_sections
 
bool request_recording_f
 

Detailed Description

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

Author
Frank R. Schaefer
Date
(C) 2001-2002

Definition at line 155 of file getpot.h.

Constructor & Destructor Documentation

◆ GetPot() [1/6]

GETPOT_NAMESPACE::GetPot::GetPot ( )
inline

constructors, destructor, assignment operator

Definition at line 764 of file getpot.h.

References _basic_initialization().

764  :
765  prefix(),
766  section(),
767  section_list(),
768  argv(),
769  cursor(),
770  search_loop_f(),
771  search_failed_f(),
772  nominus_cursor(),
773  idx_nominus(),
774  variables(),
775  _comment_start(),
776  _comment_end(),
778 #if !defined(GETPOT_DISABLE_MUTEX)
779  _getpot_mtx(),
780 #endif
786 {
788 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
void _basic_initialization()
Definition: getpot.h:741
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ GetPot() [2/6]

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

Definition at line 997 of file getpot.h.

References _internal_string_container.

997  :
998  prefix(Other.prefix),
999  section(Other.section),
1000  section_list(Other.section_list),
1001  argv(Other.argv),
1002  cursor(Other.cursor),
1003  search_loop_f(Other.search_loop_f),
1004  search_failed_f(Other.search_failed_f),
1005  overridden_vars(),
1006  nominus_cursor(Other.nominus_cursor),
1007  idx_nominus(Other.idx_nominus),
1008  variables(Other.variables),
1009  _comment_start(Other._comment_start),
1010  _comment_end(Other._comment_end),
1011  _field_separator(Other._field_separator),
1012  // #if !defined(GETPOT_DISABLE_MUTEX)
1013  // _getpot_mtx(Other._getpot_mtx),
1014  // #endif
1016  _requested_arguments(Other._requested_arguments),
1017  _requested_variables(Other._requested_variables),
1018  _requested_sections(Other._requested_sections),
1019  request_recording_f(Other.request_recording_f)
1020 {
1021  for (const auto & otherstr : Other._internal_string_container)
1022  {
1023  auto newlen = strlen(otherstr.get()) + 1;
1024  auto newcopy = std::make_unique<char[]>(newlen);
1025  strncpy(newcopy.get(), otherstr.get(), newlen);
1026  this->_internal_string_container.insert(std::move(newcopy));
1027  }
1028 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > overridden_vars
Definition: getpot.h:521
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ GetPot() [3/6]

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

Definition at line 793 of file getpot.h.

References parse_command_line().

794  :
795  // leave 'char**' non-const to honor less capable compilers ...
796  prefix(),
797  section(),
798  section_list(),
799  argv(),
800  cursor(),
801  search_loop_f(),
802  search_failed_f(),
803  nominus_cursor(),
804  idx_nominus(),
805  variables(),
806  _comment_start(),
807  _comment_end(),
809 #if !defined(GETPOT_DISABLE_MUTEX)
810  _getpot_mtx(),
811 #endif
817 {
818  this->parse_command_line(argc_, argv_, FieldSeparator);
819 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
void parse_command_line(const int argc_, const char *const *argv_, const char *FieldSeparator=0x0)
Re-initialization methods.
Definition: getpot.h:825
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ GetPot() [4/6]

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

Definition at line 854 of file getpot.h.

References parse_input_file().

856  :
857  prefix(),
858  section(),
859  section_list(),
860  argv(),
861  cursor(),
862  search_loop_f(),
863  search_failed_f(),
864  nominus_cursor(),
865  idx_nominus(),
866  variables(),
867  _comment_start(),
868  _comment_end(),
870 #if !defined(GETPOT_DISABLE_MUTEX)
871  _getpot_mtx(),
872 #endif
878 {
879  const std::string& StrCommentStart = CommentStart ? CommentStart : std::string("#");
880  const std::string& StrCommentEnd = CommentEnd ? CommentEnd : std::string("\n");
881  const std::string& StrFieldSeparator = FieldSeparator ? FieldSeparator : std::string(" \t\n");
882  this->parse_input_file(FileName, StrCommentStart, StrCommentEnd, StrFieldSeparator);
883 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
void parse_input_file(const std::string &FileName, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\), const std::string &FieldSeparator=std::string(" \\"))
Definition: getpot.h:918
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ GetPot() [5/6]

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

Definition at line 888 of file getpot.h.

References parse_input_file().

891  :
892  prefix(),
893  section(),
894  section_list(),
895  argv(),
896  cursor(),
897  search_loop_f(),
898  search_failed_f(),
899  nominus_cursor(),
900  idx_nominus(),
901  variables(),
902  _comment_start(),
903  _comment_end(),
905 #if !defined(GETPOT_DISABLE_MUTEX)
906  _getpot_mtx(),
907 #endif
913 {
914  this->parse_input_file(FileName, CommentStart, CommentEnd, FieldSeparator);
915 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
void parse_input_file(const std::string &FileName, const std::string &CommentStart=std::string("#"), const std::string &CommentEnd=std::string("\), const std::string &FieldSeparator=std::string(" \\"))
Definition: getpot.h:918
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ GetPot() [6/6]

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.

Definition at line 933 of file getpot.h.

References parse_input_stream().

936  :
937  prefix(),
938  section(),
939  section_list(),
940  argv(),
941  cursor(),
942  search_loop_f(),
943  search_failed_f(),
944  nominus_cursor(),
945  idx_nominus(),
946  variables(),
947  _comment_start(),
948  _comment_end(),
950 #if !defined(GETPOT_DISABLE_MUTEX)
951  _getpot_mtx(),
952 #endif
958 {
959  this->parse_input_stream(FileStream,
960  std::string("ParsedFromStream"),// We don't have a filename here
961  CommentStart, CommentEnd, FieldSeparator);
962 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
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("\), const std::string &FieldSeparator=std::string(" \\"))
Definition: getpot.h:966
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ ~GetPot()

GETPOT_NAMESPACE::GetPot::~GetPot ( )
inlinedefault

Member Function Documentation

◆ _basic_initialization()

void GETPOT_NAMESPACE::GetPot::_basic_initialization ( )
inlineprivate

Definition at line 741 of file getpot.h.

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

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

742 {
743  cursor = 0;
744  nominus_cursor = -1;
745  search_failed_f = true;
746  search_loop_f = true;
747  prefix = "";
748  section = "";
749 
750  // automatic request recording for later ufo detection
751  request_recording_f = true;
752 
753  // comment start and end strings
754  _comment_start = std::string("#");
755  _comment_end = std::string("\n");
756 
757  // default: separate vector elements by whitespaces
758  _field_separator = " \t\n";
759 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
std::string prefix
member variables
Definition: getpot.h:510
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
std::string _comment_start
comment delimiters
Definition: getpot.h:537

◆ _check_flags()

bool GETPOT_NAMESPACE::GetPot::_check_flags ( const std::string &  Str,
const char *  FlagList 
) const
inlineprivate

support search for flags in a specific argument

Definition at line 2150 of file getpot.h.

Referenced by argument_contains(), and options_contain().

2151 {
2152  for (const char* p=FlagList; *p != '\0' ; p++)
2153  if (Str.find(*p) != std::string::npos)
2154  return true; // found something
2155  return false;
2156 }

◆ _convert_from_type()

template<typename T >
static std::string GETPOT_NAMESPACE::GetPot::_convert_from_type ( const T &  Value)
inlinestaticprivate

Definition at line 711 of file getpot.h.

Referenced by _DBE_expand().

712  {
713  std::ostringstream out_string;
714  out_string << Value;
715  return out_string.str();
716  }

◆ _convert_to_type() [1/4]

template<typename T >
T GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const T &  Default 
) const
inlineprivate

type conversion if possible

Definition at line 1563 of file getpot.h.

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

1564 {
1565  std::istringstream in_string(String);
1566  T retval;
1567  in_string >> retval;
1568  if (in_string.fail())
1569  retval = Default;
1570  return retval;
1571 }

◆ _convert_to_type() [2/4]

std::string GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const char *  Default 
) const
inlineprivate

Definition at line 1587 of file getpot.h.

1588 {
1589  return String;
1590 }

◆ _convert_to_type() [3/4]

template<>
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const std::string &   
) const
inline

Definition at line 1578 of file getpot.h.

1579 {
1580  return String;
1581 }

◆ _convert_to_type() [4/4]

template<>
bool GETPOT_NAMESPACE::GetPot::_convert_to_type ( const std::string &  String,
const bool &  Default 
) const
inlineprivate

Definition at line 1597 of file getpot.h.

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

◆ _convert_to_type_no_default() [1/4]

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

Definition at line 1628 of file getpot.h.

References libMesh::Quality::name().

Referenced by get_value_no_default().

1629 {
1630  std::istringstream in_string(String);
1631  T retval;
1632  in_string >> retval;
1633  if (in_string.fail())
1634  {
1635  getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
1636  getpot_cerr <<" value = "<<String<<" expected type = "<<typeid(T).name()<<std::endl;
1637  getpot_error();
1638  }
1639  return retval;
1640 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42

◆ _convert_to_type_no_default() [2/4]

std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const char *  Default 
) const
inlineprivate

Definition at line 1656 of file getpot.h.

1657 {
1658  return String;
1659 }

◆ _convert_to_type_no_default() [3/4]

template<>
std::string GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  ,
const std::string &  String,
const std::string &   
) const
inline

Definition at line 1647 of file getpot.h.

1648 {
1649  return String;
1650 }

◆ _convert_to_type_no_default() [4/4]

template<>
bool GETPOT_NAMESPACE::GetPot::_convert_to_type_no_default ( const char *  VarName,
const std::string &  String,
const bool &   
) const
inlineprivate

Definition at line 1666 of file getpot.h.

References libMesh::Quality::name().

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

◆ _DBE_expand()

std::string GETPOT_NAMESPACE::GetPot::_DBE_expand ( const std::string &  str)
inlineprivate

Definition at line 2921 of file getpot.h.

References _convert_from_type(), _convert_to_type(), _DBE_get_expr_list(), _DBE_get_variable(), int, GETPOT_NAMESPACE::GetPot::variable::name, GETPOT_NAMESPACE::GetPot::variable::original, libMesh::Utility::pow(), and size().

Referenced by _DBE_expand_string(), and _DBE_get_expr_list().

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

◆ _DBE_expand_string()

std::string GETPOT_NAMESPACE::GetPot::_DBE_expand_string ( const std::string &  str)
inlineprivate

dollar bracket expressions

Definition at line 2763 of file getpot.h.

References _DBE_expand().

Referenced by _parse_argument_vector().

2764 {
2765  // Parses for closing operators '${ }' and expands them letting
2766  // white spaces and other letters as they are.
2767  std::string new_string = "";
2768  unsigned open_brackets = 0;
2769  unsigned first = 0;
2770  for (unsigned i = 0; i<str.size(); i++)
2771  {
2772  if (i + 2 < str.size() && str.substr(i, 2) == "${")
2773  {
2774  if (open_brackets == 0)
2775  first = i+2;
2776  open_brackets++;
2777  }
2778  else if (str[i] == '}' && open_brackets > 0)
2779  {
2780  open_brackets -= 1;
2781  if (open_brackets == 0)
2782  {
2783  const std::string Replacement = _DBE_expand(str.substr(first, i - first));
2784  new_string += Replacement;
2785  }
2786  }
2787  else if (open_brackets == 0)
2788  new_string += str[i];
2789  }
2790  return new_string;
2791 }
std::string _DBE_expand(const std::string &str)
Definition: getpot.h:2921

◆ _DBE_get_expr_list()

STRING_VECTOR GETPOT_NAMESPACE::GetPot::_DBE_get_expr_list ( const std::string &  str,
const unsigned  ExpectedNumber 
)
inlineprivate

Definition at line 2796 of file getpot.h.

References _DBE_expand(), and int.

Referenced by _DBE_expand().

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

◆ _DBE_get_variable()

const GetPot::variable * GETPOT_NAMESPACE::GetPot::_DBE_get_variable ( const std::string &  str)
inlineprivate

Definition at line 2887 of file getpot.h.

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

Referenced by _DBE_expand().

2888 {
2889  static GetPot::variable ev;
2890  std::string secure_Prefix = prefix;
2891 
2892  prefix = section;
2893  // (1) first search in currently active section
2894  const GetPot::variable* var = _request_variable(VarName.c_str());
2895  if (var != 0)
2896  {
2897  prefix = secure_Prefix;
2898  return var;
2899  }
2900 
2901  // (2) search in root name space
2902  prefix = "";
2903  var = _request_variable(VarName.c_str());
2904  if (var != 0)
2905  {
2906  prefix = secure_Prefix;
2907  return var;
2908  }
2909 
2910  prefix = secure_Prefix;
2911 
2912  // error occurred => variable name == ""
2913  ev.original = "<<${ } variable '";
2914  ev.original += VarName + "' undefined>>";
2915  return &ev;
2916 }
std::string section
Definition: getpot.h:511
std::string prefix
member variables
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:2666

◆ _find_variable()

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

Definition at line 2650 of file getpot.h.

References prefix, and variables.

Referenced by _request_variable(), and _set_variable().

2651 {
2652  const std::string Name = prefix + VarName;
2653 
2654  std::vector<variable>::const_iterator it = variables.begin();
2655  for (; it != variables.end(); ++it)
2656  {
2657  if ((*it).name == Name)
2658  return &(*it);
2659  }
2660  return 0;
2661 }
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532

◆ _get_next_token()

const std::string GETPOT_NAMESPACE::GetPot::_get_next_token ( std::istream &  istr)
inlineprivate

Definition at line 1362 of file getpot.h.

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

Referenced by _read_in_stream().

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

◆ _get_remaining_string()

const std::string GETPOT_NAMESPACE::GetPot::_get_remaining_string ( const std::string &  String,
const std::string &  Start 
) const
inlineprivate

prefix extraction

Definition at line 1731 of file getpot.h.

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

1732 {
1733  if (Start == "")
1734  return String;
1735 
1736  // note: java.lang.String: substring(a,b) = from a to b-1
1737  // C++ string: substr(a,b) = from a to a + b
1738  if (String.find(Start) == 0)
1739  return String.substr(Start.length());
1740 
1741  else
1742  return "";
1743 }

◆ _get_section_tree()

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.

Definition at line 722 of file getpot.h.

Referenced by _record_argument_request(), and _record_variable_request().

723  {
724  STRING_VECTOR result;
725  for (std::size_t pos = 0; pos != FullPath.size(); ++pos)
726  {
727  if (FullPath[pos] == '/')
728  result.push_back(FullPath.substr(0,pos));
729  }
730 
731  return result;
732  }
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ _get_string()

const std::string GETPOT_NAMESPACE::GetPot::_get_string ( std::istream &  istr)
inlineprivate

Definition at line 1419 of file getpot.h.

Referenced by _get_next_token().

1420 {
1421  // parse input until next matching '
1422  std::string str;
1423  int tmp = 0;
1424  while (true)
1425  {
1426  int last_letter = tmp;
1427  tmp = istr.get();
1428  if (tmp == EOF)
1429  return str;
1430 
1431  // un-backslashed quotes => it's the end of the string
1432  else if (tmp == '\'' && last_letter != '\\')
1433  return str;
1434 
1435  else if (tmp == '\\' && last_letter != '\\')
1436  continue; // don't append
1437 
1438  str += getpot_cast_int<char>(tmp);
1439  }
1440 }

◆ _get_until_closing_bracket()

const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_bracket ( std::istream &  istr)
inlineprivate

Definition at line 1445 of file getpot.h.

Referenced by _get_next_token().

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

◆ _get_until_closing_square_bracket()

const std::string GETPOT_NAMESPACE::GetPot::_get_until_closing_square_bracket ( std::istream &  istr)
inlineprivate

Definition at line 1478 of file getpot.h.

Referenced by _get_next_token().

1479 {
1480  // parse input until next matching ]
1481  std::string str = "";
1482  int brackets = 1;
1483  while (true)
1484  {
1485  int tmp = istr.get();
1486  if (tmp == EOF)
1487  return str;
1488 
1489  else if (tmp == '[')
1490  brackets += 1;
1491 
1492  else if (tmp == ']')
1493  {
1494  brackets -= 1;
1495  if (brackets == 0)
1496  return str + ']';
1497  }
1498 
1499  str += getpot_cast_int<char>(tmp);
1500  }
1501 }

◆ _internal_managed_copy()

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

Definition at line 1701 of file getpot.h.

References _internal_string_container.

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

1702 {
1703  const char* arg = Arg.c_str();
1704 
1705  // Get a lock before touching anything mutable
1706  SCOPED_MUTEX;
1707 
1708  // See if there's already an identical string saved
1709  // If so, return it
1710  if (auto it = _internal_string_container.find(arg);
1711  it != _internal_string_container.end())
1712  return it->get();
1713 
1714  // Otherwise, create a new one
1715  const std::size_t bufsize = strlen(arg)+1;
1716  auto newcopy = std::make_unique<char[]>(bufsize);
1717  strncpy(newcopy.get(), arg, bufsize);
1718  auto pr = _internal_string_container.insert(std::move(newcopy));
1719  return pr.first->get();
1720 }
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588

◆ _match_starting_string()

const char * GETPOT_NAMESPACE::GetPot::_match_starting_string ( const char *  StartString)
inlineprivate

support finding directly followed arguments

Definition at line 2052 of file getpot.h.

References argv, cursor, search_failed_f, and search_loop_f.

Referenced by direct_follow().

2053 {
2054  const unsigned N =
2055  getpot_cast_int<unsigned>(strlen(StartString));
2056  unsigned OldCursor = cursor;
2057 
2058  if (OldCursor >= argv.size())
2059  OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
2060  search_failed_f = true;
2061 
2062  // (*) first loop from cursor position until end
2063  for (unsigned c = cursor; c < argv.size(); c++)
2064  {
2065  if (strncmp(StartString, argv[c].c_str(), N) == 0)
2066  {
2067  cursor = c;
2068  search_failed_f = false;
2069  return &(argv[c].c_str()[N]);
2070  }
2071  }
2072 
2073  if (!search_loop_f)
2074  return NULL;
2075 
2076  // (*) second loop from 0 to old cursor position
2077  for (unsigned c = 1; c < OldCursor; c++)
2078  {
2079  if (strncmp(StartString, argv[c].c_str(), N) == 0)
2080  {
2081  cursor = c;
2082  search_failed_f = false;
2083  return &(argv[c].c_str()[N]);
2084  }
2085  }
2086  return 0;
2087 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:517

◆ _parse_argument_vector()

void GETPOT_NAMESPACE::GetPot::_parse_argument_vector ( const STRING_VECTOR ARGV)
inlineprivate

produce three basic data vectors:

  • argument vector
  • nominus vector
  • variable dictionary

Definition at line 1125 of file getpot.h.

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

Referenced by parse_command_line(), and parse_input_stream().

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

◆ _process_section_label()

std::string GETPOT_NAMESPACE::GetPot::_process_section_label ( const std::string &  Section,
STRING_VECTOR section_stack 
)
inlineprivate

Definition at line 1506 of file getpot.h.

Referenced by _parse_argument_vector().

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

◆ _read_in_stream()

STRING_VECTOR GETPOT_NAMESPACE::GetPot::_read_in_stream ( std::istream &  istr)
inlineprivate

Definition at line 1228 of file getpot.h.

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

Referenced by parse_input_stream().

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

◆ _record_argument_request()

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

Definition at line 2449 of file getpot.h.

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

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

2450 {
2451  if (!request_recording_f)
2452  return;
2453 
2454  // Get a lock before touching anything mutable
2455  SCOPED_MUTEX;
2456 
2457  // (*) record requested variable for later ufo detection
2458  _requested_arguments.insert(Name);
2459 
2460  // (*) record considered section for ufo detection
2461  STRING_VECTOR STree = _get_section_tree(Name);
2462  victorate(std::string, STree, it)
2463  if (_requested_sections.find(*it) == _requested_sections.end())
2464  if (section.length() != 0)
2465  _requested_sections.insert(*it);
2466 }
static STRING_VECTOR _get_section_tree(const std::string &FullPath)
cuts a variable name into a tree of sub-sections.
Definition: getpot.h:722
std::string section
Definition: getpot.h:511
std::set< std::string > _requested_sections
Definition: getpot.h:602
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ _record_variable_request()

void GETPOT_NAMESPACE::GetPot::_record_variable_request ( const std::string &  Arg) const
inlineprivate

Definition at line 2471 of file getpot.h.

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

Referenced by _request_variable().

2472 {
2473  if (!request_recording_f)
2474  return;
2475 
2476  // Get a lock before touching anything mutable
2477  SCOPED_MUTEX;
2478 
2479  // (*) record requested variable for later ufo detection
2480  _requested_variables.insert(Name);
2481 
2482  // (*) record considered section for ufo detection
2483  STRING_VECTOR STree = _get_section_tree(Name);
2484  victorate(std::string, STree, it)
2485  if (_requested_sections.find(*it) == _requested_sections.end())
2486  if (section.length() != 0)
2487  _requested_sections.insert(*it);
2488 }
static STRING_VECTOR _get_section_tree(const std::string &FullPath)
cuts a variable name into a tree of sub-sections.
Definition: getpot.h:722
std::string section
Definition: getpot.h:511
std::set< std::string > _requested_sections
Definition: getpot.h:602
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ _request_variable()

const GetPot::variable * GETPOT_NAMESPACE::GetPot::_request_variable ( const char *  VarName) const
inlineprivate

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

Definition at line 2666 of file getpot.h.

References _find_variable(), and _record_variable_request().

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

2667 {
2668  // (*) record requested variable for later ufo detection
2669  this->_record_variable_request(VarName);
2670 
2671  return this->_find_variable(VarName);
2672 }
const variable * _find_variable(const char *) const
helpers for argument list processing
Definition: getpot.h:2650
void _record_variable_request(const std::string &Arg) const
Definition: getpot.h:2471

◆ _search_string_vector()

bool GETPOT_NAMESPACE::GetPot::_search_string_vector ( const STRING_VECTOR Vec,
const std::string &  Str 
) const
inlineprivate

search for a specific string

Definition at line 3426 of file getpot.h.

3427 {
3428  victorate(std::string, VecStr, itk)
3429  {
3430  if (*itk == Str)
3431  return true;
3432  }
3433  return false;
3434 }

◆ _set_variable()

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)

Definition at line 2495 of file getpot.h.

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

Referenced by _parse_argument_vector(), and set().

2497 {
2498  const GetPot::variable* Var = Requested ?
2499  _request_variable(VarName.c_str()) :
2500  _find_variable(VarName.c_str());
2501  if (Var == 0)
2502  variables.push_back(variable(VarName.c_str(), Value.c_str(), _field_separator.c_str()));
2503  else
2504  {
2505  overridden_vars.insert(VarName.c_str());
2506  (const_cast<GetPot::variable*>(Var))->take(Value.c_str(), _field_separator.c_str());
2507  }
2508 }
const variable * _find_variable(const char *) const
helpers for argument list processing
Definition: getpot.h:2650
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::set< std::string > overridden_vars
Definition: getpot.h:521

◆ _skip_whitespace()

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.

Definition at line 1300 of file getpot.h.

References _comment_end, and _comment_start.

Referenced by _read_in_stream().

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

◆ absorb()

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

absorbing contents of another GetPot object

Definition at line 1082 of file getpot.h.

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

1083 {
1084  if (&Other == this)
1085  return;
1086 
1087  // variables that are not influenced by absorption:
1088  // _comment_start
1089  // _comment_end
1090  // cursor
1091  // nominus_cursor
1092  // search_failed
1093  // idx_nominus
1094  // search_loop_f
1095  argv = Other.argv;
1096  variables = Other.variables;
1097 
1098  if (request_recording_f)
1099  {
1100  // Get a lock before touching anything mutable
1101  SCOPED_MUTEX;
1102 
1103  _requested_arguments.insert(Other._requested_arguments.begin(), Other._requested_arguments.end());
1104  _requested_variables.insert(Other._requested_variables.begin(), Other._requested_variables.end());
1105  _requested_sections.insert(Other._requested_sections.begin(), Other._requested_sections.end());
1106  }
1107 }
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ argument_contains()

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

Definition at line 2115 of file getpot.h.

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

2116 {
2117  if (Idx >= argv.size())
2118  return false;
2119 
2120  // (*) record requested of argument for later ufo-detection
2121  // an argument that is checked for flags is considered to be 'requested'
2123 
2124  if (prefix == "")
2125  // search argument for any flag in flag list
2126  return _check_flags(argv[Idx], FlagList);
2127 
2128  // if a prefix is set, then the argument index is the index
2129  // inside the 'namespace'
2130  // => only check list of arguments that start with prefix
2131  unsigned no_matches = 0;
2132  for (unsigned i=0; i<argv.size(); i++)
2133  {
2134  const std::string Remain = _get_remaining_string(argv[i], prefix);
2135  if (Remain != "")
2136  {
2137  no_matches += 1;
2138  if (no_matches == Idx)
2139  return _check_flags(Remain, FlagList);
2140  }
2141  }
2142 
2143  // no argument in this namespace
2144  return false;
2145 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
bool _check_flags(const std::string &Str, const char *FlagList) const
support search for flags in a specific argument
Definition: getpot.h:2150
std::string prefix
member variables
Definition: getpot.h:510
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
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:2449

◆ clear_requests()

void GETPOT_NAMESPACE::GetPot::clear_requests ( )
inline

for ufo detection: recording requested arguments, options etc.

Definition at line 1112 of file getpot.h.

References _requested_arguments, _requested_sections, and _requested_variables.

1113 {
1114  // Get a lock before touching anything mutable
1115  SCOPED_MUTEX;
1116 
1117  _requested_arguments.clear();
1118  _requested_variables.clear();
1119  _requested_sections.clear();
1120 }
std::set< std::string > _requested_sections
Definition: getpot.h:602
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ direct_follow() [1/2]

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

directly followed arguments

Definition at line 2023 of file getpot.h.

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

Referenced by direct_follow().

2024 {
2025  const char* FollowStr = _match_starting_string(Option);
2026 
2027  // (*) record requested of argument for later ufo-detection
2028  _record_argument_request(std::string(Option) + FollowStr);
2029 
2030  if (FollowStr == 0)
2031  return Default;
2032 
2033  if (++cursor >= argv.size())
2034  cursor = getpot_cast_int<unsigned>(argv.size());
2035  return _convert_to_type(FollowStr, Default);
2036 }
const char * _match_starting_string(const char *StartString)
support finding directly followed arguments
Definition: getpot.h:2052
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1563
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
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:2449

◆ direct_follow() [2/2]

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

Definition at line 2041 of file getpot.h.

References _internal_managed_copy(), and direct_follow().

2042 {
2043  return _internal_managed_copy(direct_follow(std::string(Default), Option));
2044 }
T direct_follow(const T &Default, const char *Option)
directly followed arguments
Definition: getpot.h:2023
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:1701

◆ disable_loop()

void GETPOT_NAMESPACE::GetPot::disable_loop ( )
inline

enable/disable search for an option in loop

Definition at line 362 of file getpot.h.

References search_loop_f.

Referenced by init_multiple_occurrence().

362 { search_loop_f = false; }

◆ disable_request_recording()

void GETPOT_NAMESPACE::GetPot::disable_request_recording ( )
inline

Definition at line 211 of file getpot.h.

References request_recording_f.

211 { request_recording_f = false; }

◆ enable_loop()

void GETPOT_NAMESPACE::GetPot::enable_loop ( )
inline

Definition at line 363 of file getpot.h.

References search_loop_f.

363 { search_loop_f = true; }

◆ enable_request_recording()

void GETPOT_NAMESPACE::GetPot::enable_request_recording ( )
inline

Definition at line 212 of file getpot.h.

References request_recording_f.

212 { request_recording_f = true; }

◆ follow() [1/5]

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

search for option and get argument at cursor++

Definition at line 1941 of file getpot.h.

References next(), and search().

Referenced by follow().

1942 {
1943  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1944  if (search(Option) == false)
1945  return Default;
1946 
1947  return next(Default);
1948 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1758
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1908

◆ follow() [2/5]

const char * GETPOT_NAMESPACE::GetPot::follow ( const char *  Default,
const char *  Option 
)
inline

Definition at line 1953 of file getpot.h.

References _internal_managed_copy(), and follow().

1954 {
1955  return _internal_managed_copy(follow(std::string(Default), Option));
1956 }
T follow(const T &Default, const char *Option)
search for option and get argument at cursor++
Definition: getpot.h: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:1701

◆ follow() [3/5]

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

◆ follow() [4/5]

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

Definition at line 1991 of file getpot.h.

References next(), and search().

1992 {
1993  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1994  if (No == 0)
1995  return Default;
1996 
1997  if (search(P) == true)
1998  return next(Default);
1999 
2000  va_list ap;
2001  va_start(ap, P);
2002  for (unsigned i=1; i<No; i++)
2003  {
2004  char* Opt = va_arg(ap, char *);
2005  if (search(Opt) == true)
2006  {
2007  va_end(ap);
2008  return next(Default);
2009  }
2010  }
2011  va_end(ap);
2012  return Default;
2013 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1758
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1908

◆ follow() [5/5]

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

Definition at line 1964 of file getpot.h.

References next(), and search().

1965 {
1966  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1967  if (No == 0)
1968  return Default;
1969 
1970  if (search(P) == true)
1971  return next(Default);
1972 
1973  va_list ap;
1974  va_start(ap, P);
1975  for (unsigned i=1; i<No; i++)
1976  {
1977  char* Opt = va_arg(ap, char *);
1978  if (search(Opt) == true)
1979  {
1980  va_end(ap);
1981  return next(Default);
1982  }
1983  }
1984  va_end(ap);
1985  return Default;
1986 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1758
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1908

◆ get() [1/3]

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

◆ get() [2/3]

const char* GETPOT_NAMESPACE::GetPot::get ( unsigned  Idx,
const char *  Default 
) const
inline

◆ get() [3/3]

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

Definition at line 1878 of file getpot.h.

References _convert_to_type(), and argv.

1879 {
1880  if (Idx >= argv.size())
1881  return Default;
1882  return _convert_to_type(argv[Idx], Default);
1883 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1563
STRING_VECTOR argv
argument vector
Definition: getpot.h:517

◆ get_overridden_variables()

std::set< std::string > GETPOT_NAMESPACE::GetPot::get_overridden_variables ( ) const
inline

Definition at line 2642 of file getpot.h.

References overridden_vars.

2643 {
2644  return overridden_vars;
2645 }
std::set< std::string > overridden_vars
Definition: getpot.h:521

◆ get_requested_arguments()

std::set< std::string > GETPOT_NAMESPACE::GetPot::get_requested_arguments ( ) const
inline

Accessors for requested variables.

Definition at line 3876 of file getpot.h.

References _requested_arguments.

3877 {
3878  return _requested_arguments;
3879 }
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ get_requested_sections()

std::set< std::string > GETPOT_NAMESPACE::GetPot::get_requested_sections ( ) const
inline

Definition at line 3894 of file getpot.h.

References _requested_sections.

3895 {
3896  return _requested_sections;
3897 }
std::set< std::string > _requested_sections
Definition: getpot.h:602

◆ get_requested_variables()

std::set< std::string > GETPOT_NAMESPACE::GetPot::get_requested_variables ( ) const
inline

Definition at line 3885 of file getpot.h.

References _requested_variables.

3886 {
3887  return _requested_variables;
3888 }
std::set< std::string > _requested_variables
Definition: getpot.h:601

◆ get_section_names()

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

Definition at line 2584 of file getpot.h.

References section_list.

2585 {
2586  return section_list;
2587 }
STRING_VECTOR section_list
Definition: getpot.h:512

◆ get_subsection_names()

STRING_VECTOR GETPOT_NAMESPACE::GetPot::get_subsection_names ( const std::string &  section_name) const
inline

Definition at line 2592 of file getpot.h.

References section_list.

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

◆ get_value_no_default() [1/10]

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

Definition at line 2361 of file getpot.h.

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

Referenced by get_value_no_default().

2362 {
2363  // (*) recording of requested variables happens in '_request_variable()'
2364  const variable* sv = _request_variable(VarName);
2365  if (sv == 0)
2366  {
2367  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2368  getpot_error();
2369  }
2370  return _convert_to_type_no_default(VarName, sv->original, Default);
2371 }
T _convert_to_type_no_default(const char *VarName, const std::string &String, const T &Default) const
Definition: getpot.h:1628
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666

◆ get_value_no_default() [2/10]

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

Definition at line 2377 of file getpot.h.

References get_value_no_default().

2378 {
2379  return get_value_no_default(VarName.c_str(),Default);
2380 }
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:2361

◆ get_value_no_default() [3/10]

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

Definition at line 2385 of file getpot.h.

References _internal_managed_copy(), and get_value_no_default().

2386 {
2387  return _internal_managed_copy(get_value_no_default(VarName, std::string(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:2361
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:1701

◆ get_value_no_default() [4/10]

const char * GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const char *  Default 
) const
inline

Definition at line 2393 of file getpot.h.

References get_value_no_default().

2394 {
2395  return get_value_no_default(VarName.c_str(),Default);
2396 }
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:2361

◆ get_value_no_default() [5/10]

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

vectors

◆ get_value_no_default() [6/10]

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

◆ get_value_no_default() [7/10]

const char* GETPOT_NAMESPACE::GetPot::get_value_no_default ( const char *  VarName,
const char *  Default,
unsigned  Idx 
) const
inline

◆ get_value_no_default() [8/10]

const char* GETPOT_NAMESPACE::GetPot::get_value_no_default ( const std::string &  VarName,
const char *  Default,
unsigned  Idx 
) const
inline

◆ get_value_no_default() [9/10]

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

Definition at line 2402 of file getpot.h.

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

2403 {
2404  // (*) recording of requested variables happens in '_request_variable()'
2405  const variable* sv = _request_variable(VarName);
2406  if (sv == 0)
2407  {
2408  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2409  getpot_error();
2410  }
2411 
2412  const std::string* element = sv->get_element(Idx);
2413  if (element == 0)
2414  {
2415  getpot_cerr << "ERROR: cannot find index "<<Idx<<" of variable "<<VarName<<std::endl;
2416  getpot_error();
2417  }
2418  return _convert_to_type_no_default(VarName, *element, Default);
2419 }
T _convert_to_type_no_default(const char *VarName, const std::string &String, const T &Default) const
Definition: getpot.h:1628
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666

◆ get_value_no_default() [10/10]

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

Definition at line 2425 of file getpot.h.

References get_value_no_default().

2426 {
2427  return get_value_no_default(VarName.c_str(), Default, Idx);
2428 }
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:2361

◆ get_variable_names()

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

Definition at line 2568 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

2569 {
2570  STRING_VECTOR result;
2571  std::vector<GetPot::variable>::const_iterator it = variables.begin();
2572  for (; it != variables.end(); ++it)
2573  {
2574  const std::string Tmp = _get_remaining_string((*it).name, prefix);
2575  if (Tmp != "")
2576  result.push_back(Tmp);
2577  }
2578  return result;
2579 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ have_section() [1/2]

bool GETPOT_NAMESPACE::GetPot::have_section ( const char *  section_name) const
inline

Check for a section name.

When querying, the section_name can be of the form Section1 or Section1/

Section1/Section2 or Section1/Section2/

etc.

Definition at line 2250 of file getpot.h.

2251 {
2252  std::string s = std::string(section_name);
2253  return this->have_section(s);
2254 }
bool have_section(const char *section_name) const
Check for a section name.
Definition: getpot.h:2250

◆ have_section() [2/2]

bool GETPOT_NAMESPACE::GetPot::have_section ( const std::string &  section_name) const
inline

Check for a section name.

When querying, the section_name can be of the form Section1 or Section1/

Section1/Section2 or Section1/Section2/

etc.

Definition at line 2257 of file getpot.h.

References section_list.

2258 {
2259  const char slash('/');
2260 
2261  std::string::const_reverse_iterator it = section_name.rbegin();
2262 
2263  bool found_section = false;
2264 
2265  // Check if section_name ends with a "/". If not, append it for the search since
2266  // the section names are stored with a "/" at the end.
2267  if( (*it) != slash )
2268  // We need to use a linear search because we can't sort section_list
2269  // without violating some assumptions. See libMesh #481 for more discussion.
2270  found_section = ( std::find(section_list.begin(), section_list.end(), section_name+slash) != section_list.end() );
2271  else
2272  found_section = ( std::find(section_list.begin(), section_list.end(), section_name) != section_list.end() );
2273 
2274  return found_section;
2275 }
STRING_VECTOR section_list
Definition: getpot.h:512

◆ have_variable() [1/2]

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

variables

check for a variable

Definition at line 2231 of file getpot.h.

References _request_variable().

Referenced by have_variable().

2232 {
2233  const variable* sv = _request_variable(VarName);
2234 
2235  if (sv == 0)
2236  return false;
2237 
2238  return true;
2239 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666

◆ have_variable() [2/2]

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

Definition at line 2244 of file getpot.h.

References have_variable().

2245 {
2246  return have_variable(VarName.c_str());
2247 }
bool have_variable(const char *VarName) const
variables
Definition: getpot.h:2231

◆ init_multiple_occurrence()

void GETPOT_NAMESPACE::GetPot::init_multiple_occurrence ( )
inline

Definition at line 1856 of file getpot.h.

References disable_loop(), and reset_cursor().

1857 {
1858  disable_loop();
1859  reset_cursor();
1860 }
void disable_loop()
enable/disable search for an option in loop
Definition: getpot.h:362
void reset_cursor()
reset cursor to position &#39;1&#39;
Definition: getpot.h:1847

◆ next() [1/2]

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

get argument at cursor++

Definition at line 1908 of file getpot.h.

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

Referenced by follow(), and next().

1909 {
1910  if (search_failed_f)
1911  return Default;
1912  cursor++;
1913  if (cursor >= argv.size())
1914  {
1915  cursor = getpot_cast_int<unsigned>(argv.size());
1916  return Default;
1917  }
1918 
1919  // (*) record requested argument for later ufo detection
1921 
1922  const std::string Remain = _get_remaining_string(argv[cursor], prefix);
1923 
1924  return Remain != "" ? _convert_to_type(Remain, Default) : Default;
1925 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
std::string prefix
member variables
Definition: getpot.h:510
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1563
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
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:2449

◆ next() [2/2]

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

Definition at line 1930 of file getpot.h.

References _internal_managed_copy(), and next().

1931 {
1932  return _internal_managed_copy(next(std::string(Default)));
1933 }
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:1701
T next(const T &Default)
get argument at cursor++
Definition: getpot.h:1908

◆ next_nominus()

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

Definition at line 2184 of file getpot.h.

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

2185 {
2186  if (nominus_cursor < int(idx_nominus.size()) - 1)
2187  {
2188  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2189 
2190  // (*) record for later ufo-detection
2192 
2193  return _internal_managed_copy(Tmp);
2194  }
2195 
2196  return 0;
2197 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
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:1701
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
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:2449

◆ next_nominus_string()

std::string GETPOT_NAMESPACE::GetPot::next_nominus_string ( )
inline

Definition at line 2201 of file getpot.h.

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

2202 {
2203  if (nominus_cursor < int(idx_nominus.size()) - 1)
2204  {
2205  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2206 
2207  // (*) record for later ufo-detection
2209 
2210  return Tmp;
2211  }
2212 
2213  return "";
2214 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
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:2449

◆ nominus_size()

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

Definition at line 415 of file getpot.h.

References idx_nominus.

415 { return getpot_cast_int<unsigned>(idx_nominus.size()); }
std::vector< unsigned > idx_nominus
Definition: getpot.h:527

◆ nominus_vector()

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

Definition at line 2165 of file getpot.h.

References _record_argument_request(), argv, and idx_nominus.

2166 {
2167  STRING_VECTOR nv;
2168  std::vector<unsigned>::const_iterator it = idx_nominus.begin();
2169  for (; it != idx_nominus.end(); ++it)
2170  {
2171  nv.push_back(argv[*it]);
2172 
2173  // (*) record for later ufo-detection
2174  // when a nominus vector is requested, the entire set of nominus arguments are
2175  // tagged as 'requested'
2177  }
2178  return nv;
2179 }
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134
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:2449

◆ operator()() [1/10]

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

scalar values

Definition at line 2279 of file getpot.h.

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

Referenced by operator()().

2280 {
2281  // (*) recording of requested variables happens in '_request_variable()'
2282  const variable* sv = _request_variable(VarName);
2283 
2284  if (sv == 0)
2285  return Default;
2286 
2287  return _convert_to_type(sv->original, Default);
2288 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1563
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666

◆ operator()() [2/10]

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

Definition at line 2294 of file getpot.h.

References operator()().

2295 {
2296  return operator()(VarName.c_str(), Default);
2297 }
T operator()(const char *VarName, const T &Default) const
scalar values
Definition: getpot.h:2279

◆ operator()() [3/10]

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

Definition at line 2302 of file getpot.h.

References _internal_managed_copy().

2303 {
2304  return _internal_managed_copy(operator()(VarName, std::string(Default)));
2305 }
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:1701

◆ operator()() [4/10]

const char * GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const char *  Default 
) const
inline

Definition at line 2310 of file getpot.h.

References operator()().

2311 {
2312  return operator()(VarName.c_str(), Default);
2313 }
T operator()(const char *VarName, const T &Default) const
scalar values
Definition: getpot.h:2279

◆ operator()() [5/10]

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

vectors

◆ operator()() [6/10]

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

◆ operator()() [7/10]

const char* GETPOT_NAMESPACE::GetPot::operator() ( const char *  VarName,
const char *  Default,
unsigned  Idx 
) const
inline

◆ operator()() [8/10]

const char* GETPOT_NAMESPACE::GetPot::operator() ( const std::string &  VarName,
const char *  Default,
unsigned  Idx 
) const
inline

◆ operator()() [9/10]

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

Definition at line 2319 of file getpot.h.

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

2320 {
2321  // (*) recording of requested variables happens in '_request_variable()'
2322  const variable* sv = _request_variable(VarName);
2323  if (sv == 0)
2324  return Default;
2325 
2326  const std::string* element = sv->get_element(Idx);
2327  if (element == 0)
2328  return Default;
2329  return _convert_to_type(*element, Default);
2330 }
T _convert_to_type(const std::string &String, const T &Default) const
type conversion if possible
Definition: getpot.h:1563
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666

◆ operator()() [10/10]

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

Definition at line 2336 of file getpot.h.

References operator()().

2337 {
2338  return operator()(VarName.c_str(), Default, Idx);
2339 }
T operator()(const char *VarName, const T &Default) const
scalar values
Definition: getpot.h:2279

◆ operator=()

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

Definition at line 1038 of file getpot.h.

References _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, and variables.

Referenced by GETPOT_NAMESPACE::GetPot::variable::variable().

1039 {
1040  if (&Other == this)
1041  return *this;
1042 
1043  prefix = Other.prefix;
1044  section = Other.section;
1045  section_list = Other.section_list;
1046  argv = Other.argv;
1047  cursor = Other.cursor;
1048  search_loop_f = Other.search_loop_f;
1049  search_failed_f = Other.search_failed_f;
1050  nominus_cursor = Other.nominus_cursor;
1051  overridden_vars = Other.overridden_vars;
1052  idx_nominus = Other.idx_nominus;
1053  variables = Other.variables;
1054  _comment_start = Other._comment_start;
1055  _comment_end = Other._comment_end;
1056  _field_separator = Other._field_separator;
1057  // #if !defined(GETPOT_DISABLE_MUTEX)
1058  // _getpot_mtx = Other._getpot_mtx;
1059  // #endif
1060  _requested_arguments = Other._requested_arguments;
1061  _requested_variables = Other._requested_variables;
1062  _requested_sections = Other._requested_sections;
1063  request_recording_f = Other.request_recording_f;
1064 
1065  // Clear existing strings
1067 
1068  for (const auto & otherstr : Other._internal_string_container)
1069  {
1070  auto newlen = strlen(otherstr.get()) + 1;
1071  auto newcopy = std::make_unique<char[]>(newlen);
1072  strncpy(newcopy.get(), otherstr.get(), newlen);
1073  this->_internal_string_container.insert(std::move(newcopy));
1074  }
1075 
1076  return *this;
1077 }
int nominus_cursor
nominus vector
Definition: getpot.h:526
std::string section
Definition: getpot.h:511
std::vector< unsigned > idx_nominus
Definition: getpot.h:527
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::set< std::unique_ptr< const char[]>, ltstr > _internal_string_container
some functions return a char pointer to a string created on the fly.
Definition: getpot.h:588
std::set< std::string > _requested_sections
Definition: getpot.h:602
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::set< std::string > _requested_variables
Definition: getpot.h:601
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
STRING_VECTOR section_list
Definition: getpot.h:512
std::string _comment_start
comment delimiters
Definition: getpot.h:537
std::set< std::string > overridden_vars
Definition: getpot.h:521
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ operator[]()

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

direct access to command line arguments

Definition at line 1869 of file getpot.h.

References argv, and libMesh::MeshTools::Generation::Private::idx().

1870 {
1871  return idx<argv.size() ? argv[idx].c_str() : 0;
1872 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.

◆ options_contain()

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

flags

Definition at line 2096 of file getpot.h.

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

2097 {
2098  // go through all arguments that start with a '-' (but not '--')
2099  std::string str;
2100  STRING_VECTOR::const_iterator it = argv.begin();
2101  for (; it != argv.end(); ++it)
2102  {
2103  str = _get_remaining_string(*it, prefix);
2104 
2105  if (str.length() >= 2 && str[0] == '-' && str[1] != '-')
2106  if (_check_flags(str, FlagList))
2107  return true;
2108  }
2109  return false;
2110 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
bool _check_flags(const std::string &Str, const char *FlagList) const
support search for flags in a specific argument
Definition: getpot.h:2150
std::string prefix
member variables
Definition: getpot.h:510
STRING_VECTOR argv
argument vector
Definition: getpot.h:517

◆ parse_command_line()

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

Re-initialization methods.

Definition at line 825 of file getpot.h.

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

Referenced by GetPot().

827 {
829 
830  // if specified -> overwrite default string
831  if (FieldSeparator)
832  _field_separator = std::string(FieldSeparator);
833 
834  // -- make an internal copy of the argument list:
835  STRING_VECTOR _apriori_argv;
836  // -- for the sake of clarity: we do want to include the first
837  // argument of the first parsing source in the argument vector!
838  // it will not be a nominus argument, though. This gives us a
839  // minimum vector size of one which facilitates error checking
840  // in many functions. Also the user will be able to retrieve
841  // the name of his application or input file by "get[0]"
842  _apriori_argv.push_back(std::string(argv_[0]));
843  for (int i=1; i<argc_; i++)
844  {
845  std::string tmp(argv_[i]); // recall the problem with temporaries,
846  _apriori_argv.push_back(tmp); // reference counting in argument lists ...
847  }
848  _parse_argument_vector(_apriori_argv);
849 }
void _parse_argument_vector(const STRING_VECTOR &ARGV)
produce three basic data vectors:
Definition: getpot.h:1125
void _basic_initialization()
Definition: getpot.h:741
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ parse_input_file()

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

Definition at line 918 of file getpot.h.

References parse_input_stream().

Referenced by _parse_argument_vector(), and GetPot().

922 {
923  std::ifstream input(FileName.c_str());
924 
925  if (!input)
926  getpot_file_error(FileName);
927 
928  this->parse_input_stream(input,FileName,CommentStart,CommentEnd,FieldSeparator);
929 }
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("\), const std::string &FieldSeparator=std::string(" \\"))
Definition: getpot.h:966

◆ parse_input_stream()

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

Definition at line 966 of file getpot.h.

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

Referenced by GetPot(), and parse_input_file().

971 {
973 
974  // overwrite default strings
975  _comment_start = std::string(CommentStart);
976  _comment_end = std::string(CommentEnd);
977  _field_separator = FieldSeparator;
978 
979  STRING_VECTOR _apriori_argv;
980  // -- the first element of the argument vector stores the name of
981  // the first parsing source; however, this element is not
982  // parsed for variable assignments or nominuses.
983  //
984  // Regardless, we don't add more than one name to the argument
985  // vector. In this case, we're parsing from a stream, so we'll
986  // hardcode the "filename" to "ParsedFromStream"
987  _apriori_argv.push_back(FileName);
988 
989  STRING_VECTOR args = _read_in_stream(FileStream);
990  _apriori_argv.insert(_apriori_argv.begin()+1, args.begin(), args.end());
991  _parse_argument_vector(_apriori_argv);
992 }
STRING_VECTOR _read_in_stream(std::istream &istr)
Definition: getpot.h:1228
void _parse_argument_vector(const STRING_VECTOR &ARGV)
produce three basic data vectors:
Definition: getpot.h:1125
void _basic_initialization()
Definition: getpot.h:741
std::string _field_separator
field separator (separating elements of a vector)
Definition: getpot.h:543
std::string _comment_end
Definition: getpot.h:538
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134
std::string _comment_start
comment delimiters
Definition: getpot.h:537

◆ print() [1/2]

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

output

Print everything

Definition at line 2681 of file getpot.h.

References argv.

2682 {
2683  out_stream << "argc = " << argv.size() << std::endl;
2684  STRING_VECTOR::const_iterator it = argv.begin();
2685  for (; it != argv.end(); ++it)
2686  out_stream << *it << std::endl;
2687  out_stream << std::endl;
2688  return 1;
2689 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:517

◆ print() [2/2]

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.

Definition at line 2699 of file getpot.h.

References argv.

2700 {
2701  STRING_VECTOR::const_iterator it = argv.begin();
2702  it += skip_count;
2703  for (; it != argv.end(); ++it)
2704  {
2705  out_stream << custom_prefix;
2706  out_stream << *it << std::endl;
2707  }
2708  out_stream << std::endl;
2709  return 1;
2710 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:517

◆ reset_cursor()

void GETPOT_NAMESPACE::GetPot::reset_cursor ( )
inline

reset cursor to position '1'

Definition at line 1847 of file getpot.h.

References cursor, and search_failed_f.

Referenced by init_multiple_occurrence().

1848 {
1849  search_failed_f = false;
1850  cursor = 0;
1851 }

◆ reset_nominus_cursor()

void GETPOT_NAMESPACE::GetPot::reset_nominus_cursor ( )
inline

nominus arguments

Definition at line 2219 of file getpot.h.

References nominus_cursor.

2220 {
2221  nominus_cursor = -1;
2222 }
int nominus_cursor
nominus vector
Definition: getpot.h:526

◆ search() [1/3]

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

search for a certain option and set cursor to position

Definition at line 1758 of file getpot.h.

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

Referenced by follow(), and search().

1759 {
1760  unsigned OldCursor = cursor;
1761  const std::string SearchTerm = prefix + Option;
1762 
1763  // (*) record requested arguments for later ufo detection
1764  _record_argument_request(SearchTerm);
1765 
1766  if (OldCursor >= argv.size())
1767  OldCursor = getpot_cast_int<unsigned>(argv.size() - 1);
1768  search_failed_f = true;
1769 
1770  // (*) first loop from cursor position until end
1771  for (unsigned c = cursor; c < argv.size(); c++)
1772  {
1773  if (argv[c] == SearchTerm)
1774  {
1775  cursor = c;
1776  search_failed_f = false;
1777  return true;
1778  }
1779  }
1780  if (!search_loop_f)
1781  return false;
1782 
1783  // (*) second loop from 0 to old cursor position
1784  for (unsigned c = 1; c <= OldCursor; c++)
1785  {
1786  if (argv[c] == SearchTerm)
1787  {
1788  cursor = c;
1789  search_failed_f = false;
1790  return true;
1791  }
1792  }
1793 
1794  // in case nothing is found the cursor stays where it was
1795  return false;
1796 }
std::string prefix
member variables
Definition: getpot.h:510
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
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:2449

◆ search() [2/3]

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

Definition at line 1749 of file getpot.h.

References search().

1750 {
1751  return search(Option.c_str());
1752 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1758

◆ search() [3/3]

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

Definition at line 1801 of file getpot.h.

References _record_argument_request(), and search().

1802 {
1803  // (*) recording the requested arguments happens in subroutine 'search'
1804  if (No == 0)
1805  return false;
1806 
1807  // search for the first argument
1808  if (search(P) == true)
1809  return true;
1810 
1811  // start interpreting variable argument list
1812  va_list ap;
1813  va_start(ap, P);
1814  unsigned i = 1;
1815  for (; i < No; i++)
1816  {
1817  char* Opt = va_arg(ap, char *);
1818  // (*) search records itself for later ufo detection
1819  if (search(Opt) == true)
1820  break;
1821  }
1822 
1823  if (i < No)
1824  {
1825  i++;
1826  // loop was left before end of array --> hit but
1827  // make sure that the rest of the search terms is marked
1828  // as requested.
1829  for (; i < No; i++)
1830  {
1831  char* Opt = va_arg(ap, char *);
1832  // (*) record requested arguments for later ufo detection
1834  }
1835  va_end(ap);
1836  return true;
1837  }
1838 
1839  va_end(ap);
1840  // loop was left normally --> no hit
1841  return false;
1842 }
bool search(const char *option)
search for a certain option and set cursor to position
Definition: getpot.h:1758
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:2449

◆ search_failed()

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

Definition at line 357 of file getpot.h.

References search_failed_f.

357 { return search_failed_f; }

◆ set() [1/4]

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

Definition at line 2514 of file getpot.h.

References _set_variable().

2515 {
2516  std::ostringstream string_value;
2517  string_value << Value;
2518  _set_variable(VarName, string_value.str().c_str(), Requested);
2519 }
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
helper functions
Definition: getpot.h:2495

◆ set() [2/4]

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

Definition at line 2525 of file getpot.h.

2526 {
2527  set(VarName.c_str(), Value, Requested);
2528 }

◆ set() [3/4]

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

Definition at line 2533 of file getpot.h.

References _set_variable().

2534 {
2535  _set_variable(VarName, Value, Requested);
2536 }
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
helper functions
Definition: getpot.h:2495

◆ set() [4/4]

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

Definition at line 2541 of file getpot.h.

2542 {
2543  set(VarName.c_str(), Value, Requested);
2544 }

◆ set_prefix()

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

cursor oriented functions

Definition at line 356 of file getpot.h.

References prefix.

356 { prefix = std::string(Prefix); }
std::string prefix
member variables
Definition: getpot.h:510

◆ size()

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

Definition at line 1898 of file getpot.h.

References argv.

Referenced by _DBE_expand().

1899 {
1900  return getpot_cast_int<unsigned>(argv.size());
1901 }
STRING_VECTOR argv
argument vector
Definition: getpot.h:517

◆ unidentified_arguments() [1/4]

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

unidentified flying objects

Definition at line 3439 of file getpot.h.

References unidentified_arguments().

3441 {
3442  std::set<std::string> known_arguments;
3443 
3444  // (1) create a vector of known arguments
3445  if (Number == 0)
3446  return STRING_VECTOR();
3447 
3448  va_list ap;
3449  va_start(ap, KnownArgument1);
3450  known_arguments.insert(std::string(KnownArgument1));
3451  for (unsigned i=1; i<Number; i++)
3452  known_arguments.insert(std::string(va_arg(ap, char *)));
3453  va_end(ap);
3454 
3455  return unidentified_arguments(known_arguments);
3456 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3461
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_arguments() [2/4]

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

Definition at line 3479 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

3480 {
3481  STRING_VECTOR ufos;
3482  STRING_VECTOR::const_iterator it = argv.begin();
3483  ++it; // forget about argv[0] (application or filename)
3484  for (; it != argv.end(); ++it)
3485  {
3486  // -- argument belongs to prefixed section ?
3487  const std::string arg = _get_remaining_string(*it, prefix);
3488  if (arg == "")
3489  continue;
3490 
3491  // -- check if in list
3492  if (Knowns.find(arg) == Knowns.end())
3493  ufos.push_back(*it);
3494  }
3495  return ufos;
3496 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
std::string prefix
member variables
Definition: getpot.h:510
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_arguments() [3/4]

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

Definition at line 3469 of file getpot.h.

References unidentified_arguments().

3470 {
3471  // We use set for efficiency, but want to support vector inputs for
3472  // backwards compatibility.
3473  return unidentified_arguments(std::set<std::string> (Knowns.begin(), Knowns.end()));
3474 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3461

◆ unidentified_arguments() [4/4]

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

Definition at line 3461 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_arguments(), and unidentified_options().

3462 {
3464 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3461
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ unidentified_flags()

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

Definition at line 3577 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

◆ unidentified_nominuses() [1/4]

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

Definition at line 3774 of file getpot.h.

References unidentified_nominuses().

3775 {
3776  std::set<std::string> known_nominuses;
3777 
3778  // create vector of known arguments
3779  if (Number == 0)
3780  return STRING_VECTOR();
3781 
3782  va_list ap;
3783  va_start(ap, Known);
3784  known_nominuses.insert(std::string(Known));
3785  for (unsigned i=1; i<Number; i++)
3786  {
3787  std::string tmp = std::string(va_arg(ap, char *));
3788  if (tmp.length() == 0)
3789  continue;
3790  known_nominuses.insert(tmp);
3791  }
3792  va_end(ap);
3793 
3794  return unidentified_nominuses(known_nominuses);
3795 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3800
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_nominuses() [2/4]

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

Definition at line 3825 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

◆ unidentified_nominuses() [3/4]

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

Definition at line 3815 of file getpot.h.

References unidentified_nominuses().

3816 {
3817  // We use set for efficiency, but want to support vector inputs for
3818  // backwards compatibility.
3819  return unidentified_nominuses(std::set<std::string> (Knowns.begin(), Knowns.end()));
3820 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3800

◆ unidentified_nominuses() [4/4]

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

Definition at line 3800 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_nominuses().

3801 {
3802  // -- every nominus is an argument.
3803  // -- the set of requested arguments contains the set of requested nominuss.
3804  // -- IF the set of requested arguments contains unrequested nominuss,
3805  // THEN they were requested as 'follow' and 'next' arguments and not as real nominuses.
3806  //
3807  // => it is not necessary to separate requested nominus from the list
3808 
3810 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3800
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ unidentified_options() [1/4]

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

Definition at line 3501 of file getpot.h.

References unidentified_options().

3503 {
3504  std::set<std::string> known_options;
3505 
3506  // (1) create a vector of known arguments
3507  if (Number == 0)
3508  return STRING_VECTOR();
3509 
3510  va_list ap;
3511  va_start(ap, KnownOption1);
3512  known_options.insert(std::string(KnownOption1));
3513  for (unsigned i=1; i<Number; i++)
3514  known_options.insert(std::string(va_arg(ap, char *)));
3515  va_end(ap);
3516 
3517  return unidentified_options(known_options);
3518 }
STRING_VECTOR unidentified_options() const
Definition: getpot.h:3523
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_options() [2/4]

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

Definition at line 3547 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

3548 {
3549  STRING_VECTOR ufos;
3550  STRING_VECTOR::const_iterator it = argv.begin();
3551  ++it; // forget about argv[0] (application or filename)
3552  for (; it != argv.end(); ++it)
3553  {
3554  // -- argument belongs to prefixed section ?
3555  const std::string arg = _get_remaining_string(*it, prefix);
3556  if (arg == "")
3557  continue;
3558 
3559  // is argument really an option (starting with '-') ?
3560  if (arg.length() < 1 || arg[0] != '-')
3561  continue;
3562 
3563  if (Knowns.find(arg) == Knowns.end())
3564  ufos.push_back(*it);
3565  }
3566 
3567  return ufos;
3568 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
std::string prefix
member variables
Definition: getpot.h:510
STRING_VECTOR argv
argument vector
Definition: getpot.h:517
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_options() [3/4]

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

Definition at line 3537 of file getpot.h.

References unidentified_options().

3538 {
3539  // We use set for efficiency, but want to support vector inputs for
3540  // backwards compatibility.
3541  return unidentified_options(std::set<std::string> (Knowns.begin(), Knowns.end()));
3542 }
STRING_VECTOR unidentified_options() const
Definition: getpot.h:3523

◆ unidentified_options() [4/4]

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

Definition at line 3523 of file getpot.h.

References _requested_arguments, and unidentified_arguments().

Referenced by unidentified_options().

3524 {
3525  // -- every option is an argument.
3526  // -- the set of requested arguments contains the set of requested options.
3527  // -- IF the set of requested arguments contains unrequested options,
3528  // THEN they were requested as 'follow' and 'next' arguments and not as real options.
3529  //
3530  // => it is not necessary to separate requested options from the list
3532 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3461
std::set< std::string > _requested_arguments
keeping track about arguments that are requested, so that the UFO detection can be simplified ...
Definition: getpot.h:600

◆ unidentified_sections() [1/4]

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

Definition at line 3702 of file getpot.h.

References unidentified_sections().

3704 {
3705  std::set<std::string> known_sections;
3706 
3707  // (1) create a vector of known arguments
3708  if (Number == 0)
3709  return STRING_VECTOR();
3710 
3711  va_list ap;
3712  va_start(ap, KnownSection1);
3713  known_sections.insert(std::string(KnownSection1));
3714  for (unsigned i=1; i<Number; i++)
3715  {
3716  std::string tmp = std::string(va_arg(ap, char *));
3717 
3718  if (tmp.length() == 0)
3719  continue;
3720 
3721  if (tmp[tmp.length()-1] != '/')
3722  tmp += '/';
3723 
3724  known_sections.insert(tmp);
3725  }
3726  va_end(ap);
3727 
3728  return unidentified_sections(known_sections);
3729 }
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3734
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_sections() [2/4]

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

Definition at line 3752 of file getpot.h.

References _get_remaining_string(), prefix, and section_list.

3753 {
3754  STRING_VECTOR ufos;
3755 
3756  victorate(std::string, section_list, it)
3757  {
3758  // -- check if section conform to prefix
3759  const std::string sec_name = _get_remaining_string(*it, prefix);
3760  if (sec_name == "")
3761  continue;
3762 
3763  // -- check if section is known
3764  if (Knowns.find(sec_name) == Knowns.end())
3765  ufos.push_back(*it);
3766  }
3767 
3768  return ufos;
3769 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
std::string prefix
member variables
Definition: getpot.h:510
STRING_VECTOR section_list
Definition: getpot.h:512
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_sections() [3/4]

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

Definition at line 3742 of file getpot.h.

References unidentified_sections().

3743 {
3744  // We use set for efficiency, but want to support vector inputs for
3745  // backwards compatibility.
3746  return unidentified_sections(std::set<std::string> (Knowns.begin(), Knowns.end()));
3747 }
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3734

◆ unidentified_sections() [4/4]

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

Definition at line 3734 of file getpot.h.

References _requested_sections.

Referenced by unidentified_sections().

3735 {
3737 }
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3734
std::set< std::string > _requested_sections
Definition: getpot.h:602

◆ unidentified_variables() [1/4]

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

Definition at line 3641 of file getpot.h.

References unidentified_variables().

3643 {
3644  std::set<std::string> known_variables;
3645 
3646  // create vector of known arguments
3647  if (Number == 0)
3648  return STRING_VECTOR();
3649 
3650  va_list ap;
3651  va_start(ap, KnownVariable1);
3652  known_variables.insert(std::string(KnownVariable1));
3653  for (unsigned i=1; i<Number; i++)
3654  known_variables.insert(std::string(va_arg(ap, char *)));
3655  va_end(ap);
3656 
3657  return unidentified_variables(known_variables);
3658 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3694
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_variables() [2/4]

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

Definition at line 3673 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

3674 {
3675  STRING_VECTOR ufos;
3676 
3677  victorate(GetPot::variable, variables, it)
3678  {
3679  // -- check if variable has specific prefix
3680  const std::string var_name = _get_remaining_string((*it).name, prefix);
3681  if (var_name == "")
3682  continue;
3683 
3684  // -- check if variable is known
3685  if (Knowns.find(var_name) == Knowns.end())
3686  ufos.push_back((*it).name);
3687  }
3688  return ufos;
3689 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1731
std::string prefix
member variables
Definition: getpot.h:510
std::vector< variable > variables
variables (arguments of the form "variable=value")
Definition: getpot.h:532
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:134

◆ unidentified_variables() [3/4]

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

Definition at line 3663 of file getpot.h.

References unidentified_variables().

3664 {
3665  // We use set for efficiency, but want to support vector inputs for
3666  // backwards compatibility.
3667  return unidentified_variables(std::set<std::string> (Knowns.begin(), Knowns.end()));
3668 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3694

◆ unidentified_variables() [4/4]

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

Definition at line 3694 of file getpot.h.

References _requested_variables.

Referenced by unidentified_variables().

3695 {
3697 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3694
std::set< std::string > _requested_variables
Definition: getpot.h:601

◆ vector_variable_size() [1/2]

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

Definition at line 2549 of file getpot.h.

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

Referenced by vector_variable_size().

2550 {
2551  const variable* sv = _request_variable(VarName);
2552  if (sv == 0)
2553  return 0;
2554  return (unsigned)(sv->value.size());
2555 }
const variable * _request_variable(const char *) const
search (and record request) for a variable in &#39;variables&#39; array
Definition: getpot.h:2666

◆ vector_variable_size() [2/2]

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

Definition at line 2560 of file getpot.h.

References vector_variable_size().

2561 {
2562  return vector_variable_size(VarName.c_str());
2563 }
unsigned vector_variable_size(const char *VarName) const
Definition: getpot.h:2549

Member Data Documentation

◆ _comment_end

std::string GETPOT_NAMESPACE::GetPot::_comment_end
private

◆ _comment_start

std::string GETPOT_NAMESPACE::GetPot::_comment_start
private

◆ _field_separator

std::string GETPOT_NAMESPACE::GetPot::_field_separator
private

field separator (separating elements of a vector)

Definition at line 543 of file getpot.h.

Referenced by _basic_initialization(), _parse_argument_vector(), _set_variable(), operator=(), parse_command_line(), and parse_input_stream().

◆ _internal_string_container

std::set<std::unique_ptr<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

Definition at line 588 of file getpot.h.

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

◆ _requested_arguments

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

Definition at line 600 of file getpot.h.

Referenced by _parse_argument_vector(), _record_argument_request(), absorb(), clear_requests(), get_requested_arguments(), operator=(), unidentified_arguments(), unidentified_nominuses(), and unidentified_options().

◆ _requested_sections

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

◆ _requested_variables

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

◆ argv

STRING_VECTOR GETPOT_NAMESPACE::GetPot::argv
private

◆ cursor

unsigned GETPOT_NAMESPACE::GetPot::cursor
private

◆ GETPOT_MUTEX_DECLARE

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.

Definition at line 551 of file getpot.h.

◆ idx_nominus

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

◆ nominus_cursor

int GETPOT_NAMESPACE::GetPot::nominus_cursor
private

nominus vector

Definition at line 526 of file getpot.h.

Referenced by _basic_initialization(), next_nominus(), next_nominus_string(), operator=(), and reset_nominus_cursor().

◆ overridden_vars

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

Definition at line 521 of file getpot.h.

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

◆ prefix

std::string GETPOT_NAMESPACE::GetPot::prefix
private

◆ request_recording_f

bool GETPOT_NAMESPACE::GetPot::request_recording_f
private

◆ search_failed_f

bool GETPOT_NAMESPACE::GetPot::search_failed_f
private

◆ search_loop_f

bool GETPOT_NAMESPACE::GetPot::search_loop_f
private

◆ section

std::string GETPOT_NAMESPACE::GetPot::section
private

◆ section_list

STRING_VECTOR GETPOT_NAMESPACE::GetPot::section_list
private

◆ variables

std::vector<variable> GETPOT_NAMESPACE::GetPot::variables
private

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

Definition at line 532 of file getpot.h.

Referenced by _find_variable(), _set_variable(), absorb(), get_variable_names(), operator=(), and unidentified_variables().


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