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 2151 of file getpot.h.

Referenced by argument_contains(), and options_contain().

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

◆ _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 2922 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().

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

References _DBE_expand().

Referenced by _parse_argument_vector().

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

◆ _DBE_get_expr_list()

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

Definition at line 2797 of file getpot.h.

References _DBE_expand(), and int.

Referenced by _DBE_expand().

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

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

Referenced by _DBE_expand().

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

◆ _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 2651 of file getpot.h.

References prefix, and variables.

Referenced by _request_variable(), and _set_variable().

2652 {
2653  const std::string Name = prefix + VarName;
2654 
2655  std::vector<variable>::const_iterator it = variables.begin();
2656  for (; it != variables.end(); ++it)
2657  {
2658  if ((*it).name == Name)
2659  return &(*it);
2660  }
2661  return 0;
2662 }
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 1732 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().

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

◆ _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  auto newcopy = std::make_unique<char[]>(strlen(arg)+1);
1716  // Note: strcpy() is safe here because we allocated enough space and
1717  // "arg" is guaranteed to be null-terminated.
1718  strcpy(newcopy.get(), arg);
1719  auto pr = _internal_string_container.insert(std::move(newcopy));
1720  return pr.first->get();
1721 }
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 2053 of file getpot.h.

References argv, cursor, search_failed_f, and search_loop_f.

Referenced by direct_follow().

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

◆ _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 2450 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().

2451 {
2452  if (!request_recording_f)
2453  return;
2454 
2455  // Get a lock before touching anything mutable
2456  SCOPED_MUTEX;
2457 
2458  // (*) record requested variable for later ufo detection
2459  _requested_arguments.insert(Name);
2460 
2461  // (*) record considered section for ufo detection
2462  STRING_VECTOR STree = _get_section_tree(Name);
2463  victorate(std::string, STree, it)
2464  if (_requested_sections.find(*it) == _requested_sections.end())
2465  if (section.length() != 0)
2466  _requested_sections.insert(*it);
2467 }
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 2472 of file getpot.h.

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

Referenced by _request_variable().

2473 {
2474  if (!request_recording_f)
2475  return;
2476 
2477  // Get a lock before touching anything mutable
2478  SCOPED_MUTEX;
2479 
2480  // (*) record requested variable for later ufo detection
2481  _requested_variables.insert(Name);
2482 
2483  // (*) record considered section for ufo detection
2484  STRING_VECTOR STree = _get_section_tree(Name);
2485  victorate(std::string, STree, it)
2486  if (_requested_sections.find(*it) == _requested_sections.end())
2487  if (section.length() != 0)
2488  _requested_sections.insert(*it);
2489 }
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 2667 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().

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

◆ _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 3427 of file getpot.h.

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

◆ _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 2496 of file getpot.h.

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

Referenced by _parse_argument_vector(), and set().

2498 {
2499  const GetPot::variable* Var = Requested ?
2500  _request_variable(VarName.c_str()) :
2501  _find_variable(VarName.c_str());
2502  if (Var == 0)
2503  variables.push_back(variable(VarName.c_str(), Value.c_str(), _field_separator.c_str()));
2504  else
2505  {
2506  overridden_vars.insert(VarName.c_str());
2507  (const_cast<GetPot::variable*>(Var))->take(Value.c_str(), _field_separator.c_str());
2508  }
2509 }
const variable * _find_variable(const char *) const
helpers for argument list processing
Definition: getpot.h:2651
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:2667
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 2116 of file getpot.h.

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

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

◆ 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 2024 of file getpot.h.

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

Referenced by direct_follow().

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

◆ direct_follow() [2/2]

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

Definition at line 2042 of file getpot.h.

References _internal_managed_copy(), and direct_follow().

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

References next(), and search().

Referenced by follow().

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

◆ follow() [2/5]

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

Definition at line 1954 of file getpot.h.

References _internal_managed_copy(), and follow().

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

References next(), and search().

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

◆ follow() [5/5]

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

Definition at line 1965 of file getpot.h.

References next(), and search().

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

◆ 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 1879 of file getpot.h.

References _convert_to_type(), and argv.

1880 {
1881  if (Idx >= argv.size())
1882  return Default;
1883  return _convert_to_type(argv[Idx], Default);
1884 }
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 2643 of file getpot.h.

References overridden_vars.

2644 {
2645  return overridden_vars;
2646 }
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 3877 of file getpot.h.

References _requested_arguments.

3878 {
3879  return _requested_arguments;
3880 }
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 3895 of file getpot.h.

References _requested_sections.

3896 {
3897  return _requested_sections;
3898 }
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 3886 of file getpot.h.

References _requested_variables.

3887 {
3888  return _requested_variables;
3889 }
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 2585 of file getpot.h.

References section_list.

2586 {
2587  return section_list;
2588 }
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 2593 of file getpot.h.

References section_list.

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

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

Referenced by get_value_no_default().

2363 {
2364  // (*) recording of requested variables happens in '_request_variable()'
2365  const variable* sv = _request_variable(VarName);
2366  if (sv == 0)
2367  {
2368  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2369  getpot_error();
2370  }
2371  return _convert_to_type_no_default(VarName, sv->original, Default);
2372 }
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:2667

◆ 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 2378 of file getpot.h.

References get_value_no_default().

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

◆ 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 2386 of file getpot.h.

References _internal_managed_copy(), and get_value_no_default().

2387 {
2388  return _internal_managed_copy(get_value_no_default(VarName, std::string(Default)));
2389 }
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:2362
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 2394 of file getpot.h.

References get_value_no_default().

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

◆ 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 2403 of file getpot.h.

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

2404 {
2405  // (*) recording of requested variables happens in '_request_variable()'
2406  const variable* sv = _request_variable(VarName);
2407  if (sv == 0)
2408  {
2409  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2410  getpot_error();
2411  }
2412 
2413  const std::string* element = sv->get_element(Idx);
2414  if (element == 0)
2415  {
2416  getpot_cerr << "ERROR: cannot find index "<<Idx<<" of variable "<<VarName<<std::endl;
2417  getpot_error();
2418  }
2419  return _convert_to_type_no_default(VarName, *element, Default);
2420 }
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:2667

◆ 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 2426 of file getpot.h.

References get_value_no_default().

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

◆ get_variable_names()

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

Definition at line 2569 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

2570 {
2571  STRING_VECTOR result;
2572  std::vector<GetPot::variable>::const_iterator it = variables.begin();
2573  for (; it != variables.end(); ++it)
2574  {
2575  const std::string Tmp = _get_remaining_string((*it).name, prefix);
2576  if (Tmp != "")
2577  result.push_back(Tmp);
2578  }
2579  return result;
2580 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1732
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 2251 of file getpot.h.

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

◆ 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 2258 of file getpot.h.

References section_list.

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

References _request_variable().

Referenced by have_variable().

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

◆ have_variable() [2/2]

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

Definition at line 2245 of file getpot.h.

References have_variable().

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

◆ init_multiple_occurrence()

void GETPOT_NAMESPACE::GetPot::init_multiple_occurrence ( )
inline

Definition at line 1857 of file getpot.h.

References disable_loop(), and reset_cursor().

1858 {
1859  disable_loop();
1860  reset_cursor();
1861 }
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:1848

◆ next() [1/2]

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

get argument at cursor++

Definition at line 1909 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().

1910 {
1911  if (search_failed_f)
1912  return Default;
1913  cursor++;
1914  if (cursor >= argv.size())
1915  {
1916  cursor = getpot_cast_int<unsigned>(argv.size());
1917  return Default;
1918  }
1919 
1920  // (*) record requested argument for later ufo detection
1922 
1923  const std::string Remain = _get_remaining_string(argv[cursor], prefix);
1924 
1925  return Remain != "" ? _convert_to_type(Remain, Default) : Default;
1926 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1732
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:2450

◆ next() [2/2]

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

Definition at line 1931 of file getpot.h.

References _internal_managed_copy(), and next().

1932 {
1933  return _internal_managed_copy(next(std::string(Default)));
1934 }
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:1909

◆ next_nominus()

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

Definition at line 2185 of file getpot.h.

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

2186 {
2187  if (nominus_cursor < int(idx_nominus.size()) - 1)
2188  {
2189  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2190 
2191  // (*) record for later ufo-detection
2193 
2194  return _internal_managed_copy(Tmp);
2195  }
2196 
2197  return 0;
2198 }
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:2450

◆ next_nominus_string()

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

Definition at line 2202 of file getpot.h.

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

2203 {
2204  if (nominus_cursor < int(idx_nominus.size()) - 1)
2205  {
2206  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2207 
2208  // (*) record for later ufo-detection
2210 
2211  return Tmp;
2212  }
2213 
2214  return "";
2215 }
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:2450

◆ 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 2166 of file getpot.h.

References _record_argument_request(), argv, and idx_nominus.

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

◆ operator()() [1/10]

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

scalar values

Definition at line 2280 of file getpot.h.

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

Referenced by operator()().

2281 {
2282  // (*) recording of requested variables happens in '_request_variable()'
2283  const variable* sv = _request_variable(VarName);
2284 
2285  if (sv == 0)
2286  return Default;
2287 
2288  return _convert_to_type(sv->original, Default);
2289 }
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:2667

◆ operator()() [2/10]

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

Definition at line 2295 of file getpot.h.

References operator()().

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

◆ operator()() [3/10]

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

Definition at line 2303 of file getpot.h.

References _internal_managed_copy().

2304 {
2305  return _internal_managed_copy(operator()(VarName, std::string(Default)));
2306 }
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 2311 of file getpot.h.

References operator()().

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

◆ 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 2320 of file getpot.h.

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

2321 {
2322  // (*) recording of requested variables happens in '_request_variable()'
2323  const variable* sv = _request_variable(VarName);
2324  if (sv == 0)
2325  return Default;
2326 
2327  const std::string* element = sv->get_element(Idx);
2328  if (element == 0)
2329  return Default;
2330  return _convert_to_type(*element, Default);
2331 }
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:2667

◆ 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 2337 of file getpot.h.

References operator()().

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

◆ 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 1870 of file getpot.h.

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

1871 {
1872  return idx<argv.size() ? argv[idx].c_str() : 0;
1873 }
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 2097 of file getpot.h.

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

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

References argv.

2683 {
2684  out_stream << "argc = " << argv.size() << std::endl;
2685  STRING_VECTOR::const_iterator it = argv.begin();
2686  for (; it != argv.end(); ++it)
2687  out_stream << *it << std::endl;
2688  out_stream << std::endl;
2689  return 1;
2690 }
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 2700 of file getpot.h.

References argv.

2701 {
2702  STRING_VECTOR::const_iterator it = argv.begin();
2703  it += skip_count;
2704  for (; it != argv.end(); ++it)
2705  {
2706  out_stream << custom_prefix;
2707  out_stream << *it << std::endl;
2708  }
2709  out_stream << std::endl;
2710  return 1;
2711 }
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 1848 of file getpot.h.

References cursor, and search_failed_f.

Referenced by init_multiple_occurrence().

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

◆ reset_nominus_cursor()

void GETPOT_NAMESPACE::GetPot::reset_nominus_cursor ( )
inline

nominus arguments

Definition at line 2220 of file getpot.h.

References nominus_cursor.

2221 {
2222  nominus_cursor = -1;
2223 }
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 1759 of file getpot.h.

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

Referenced by follow(), and search().

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

◆ search() [2/3]

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

Definition at line 1750 of file getpot.h.

References search().

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

◆ search() [3/3]

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

Definition at line 1802 of file getpot.h.

References _record_argument_request(), and search().

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

◆ 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 2515 of file getpot.h.

References _set_variable().

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

◆ 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 2526 of file getpot.h.

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

◆ set() [3/4]

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

Definition at line 2534 of file getpot.h.

References _set_variable().

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

◆ set() [4/4]

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

Definition at line 2542 of file getpot.h.

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

◆ 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 1899 of file getpot.h.

References argv.

Referenced by _DBE_expand().

1900 {
1901  return getpot_cast_int<unsigned>(argv.size());
1902 }
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 3440 of file getpot.h.

References unidentified_arguments().

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

References _get_remaining_string(), argv, and prefix.

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

References unidentified_arguments().

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

◆ unidentified_arguments() [4/4]

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

Definition at line 3462 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_arguments(), and unidentified_options().

3463 {
3465 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3462
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 3578 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

References unidentified_nominuses().

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

References _get_remaining_string(), argv, and prefix.

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

References unidentified_nominuses().

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

◆ unidentified_nominuses() [4/4]

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

Definition at line 3801 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_nominuses().

3802 {
3803  // -- every nominus is an argument.
3804  // -- the set of requested arguments contains the set of requested nominuss.
3805  // -- IF the set of requested arguments contains unrequested nominuss,
3806  // THEN they were requested as 'follow' and 'next' arguments and not as real nominuses.
3807  //
3808  // => it is not necessary to separate requested nominus from the list
3809 
3811 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3801
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 3502 of file getpot.h.

References unidentified_options().

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

References _get_remaining_string(), argv, and prefix.

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

References unidentified_options().

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

◆ unidentified_options() [4/4]

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

Definition at line 3524 of file getpot.h.

References _requested_arguments, and unidentified_arguments().

Referenced by unidentified_options().

3525 {
3526  // -- every option is an argument.
3527  // -- the set of requested arguments contains the set of requested options.
3528  // -- IF the set of requested arguments contains unrequested options,
3529  // THEN they were requested as 'follow' and 'next' arguments and not as real options.
3530  //
3531  // => it is not necessary to separate requested options from the list
3533 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3462
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 3703 of file getpot.h.

References unidentified_sections().

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

References _get_remaining_string(), prefix, and section_list.

3754 {
3755  STRING_VECTOR ufos;
3756 
3757  victorate(std::string, section_list, it)
3758  {
3759  // -- check if section conform to prefix
3760  const std::string sec_name = _get_remaining_string(*it, prefix);
3761  if (sec_name == "")
3762  continue;
3763 
3764  // -- check if section is known
3765  if (Knowns.find(sec_name) == Knowns.end())
3766  ufos.push_back(*it);
3767  }
3768 
3769  return ufos;
3770 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1732
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 3743 of file getpot.h.

References unidentified_sections().

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

◆ unidentified_sections() [4/4]

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

Definition at line 3735 of file getpot.h.

References _requested_sections.

Referenced by unidentified_sections().

3736 {
3738 }
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3735
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 3642 of file getpot.h.

References unidentified_variables().

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

References _get_remaining_string(), prefix, and variables.

3675 {
3676  STRING_VECTOR ufos;
3677 
3678  victorate(GetPot::variable, variables, it)
3679  {
3680  // -- check if variable has specific prefix
3681  const std::string var_name = _get_remaining_string((*it).name, prefix);
3682  if (var_name == "")
3683  continue;
3684 
3685  // -- check if variable is known
3686  if (Knowns.find(var_name) == Knowns.end())
3687  ufos.push_back((*it).name);
3688  }
3689  return ufos;
3690 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
prefix extraction
Definition: getpot.h:1732
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 3664 of file getpot.h.

References unidentified_variables().

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

◆ unidentified_variables() [4/4]

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

Definition at line 3695 of file getpot.h.

References _requested_variables.

Referenced by unidentified_variables().

3696 {
3698 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3695
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 2550 of file getpot.h.

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

Referenced by vector_variable_size().

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

◆ vector_variable_size() [2/2]

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

Definition at line 2561 of file getpot.h.

References vector_variable_size().

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

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: