GETPOT_NAMESPACE::GetPot Class Reference

#include <getpot.h>

Classes

struct  ltstr
 
struct  variable
 

Public Member Functions

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

Private Member Functions

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

Static Private Member Functions

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

Private Attributes

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

Detailed Description

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

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

Definition at line 153 of file getpot.h.

Constructor & Destructor Documentation

◆ GetPot() [1/6]

GETPOT_NAMESPACE::GetPot::GetPot ( )
inline

constructors, destructor, assignment operator

Definition at line 743 of file getpot.h.

References _basic_initialization().

743  :
744  prefix(),
745  section(),
746  section_list(),
747  argv(),
748  cursor(),
749  search_loop_f(),
750  search_failed_f(),
751  nominus_cursor(),
752  idx_nominus(),
753  variables(),
754  _comment_start(),
755  _comment_end(),
757 #if !defined(GETPOT_DISABLE_MUTEX)
758  _getpot_mtx(),
759 #endif
765 {
767 }
std::string section
Definition: getpot.h:509
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
void _basic_initialization()
Definition: getpot.h:720
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

◆ GetPot() [2/6]

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

Definition at line 976 of file getpot.h.

References _internal_string_container, and end.

976  :
977  prefix(Other.prefix),
978  section(Other.section),
979  section_list(Other.section_list),
980  argv(Other.argv),
981  cursor(Other.cursor),
982  search_loop_f(Other.search_loop_f),
983  search_failed_f(Other.search_failed_f),
984  overridden_vars(),
985  nominus_cursor(Other.nominus_cursor),
986  idx_nominus(Other.idx_nominus),
987  variables(Other.variables),
988  _comment_start(Other._comment_start),
989  _comment_end(Other._comment_end),
990  _field_separator(Other._field_separator),
991  // #if !defined(GETPOT_DISABLE_MUTEX)
992  // _getpot_mtx(Other._getpot_mtx),
993  // #endif
995  _requested_arguments(Other._requested_arguments),
996  _requested_variables(Other._requested_variables),
997  _requested_sections(Other._requested_sections),
998  request_recording_f(Other.request_recording_f)
999 {
1000  std::set<const char*,ltstr>::const_iterator it =
1001  Other._internal_string_container.begin();
1002 
1003  const std::set<const char*,ltstr>::const_iterator end =
1004  Other._internal_string_container.end();
1005 
1006  for (; it != end; ++it)
1007  {
1008  const char* otherstr = *it;
1009  char* newcopy = new char[strlen(otherstr)+1];
1010  strncpy(newcopy, otherstr, strlen(otherstr)+1);
1011  this->_internal_string_container.insert(newcopy);
1012  }
1013 }
std::string section
Definition: getpot.h:509
IterBase * end
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > overridden_vars
Definition: getpot.h:519
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

◆ GetPot() [3/6]

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

Definition at line 772 of file getpot.h.

References parse_command_line().

773  :
774  // leave 'char**' non-const to honor less capable compilers ...
775  prefix(),
776  section(),
777  section_list(),
778  argv(),
779  cursor(),
780  search_loop_f(),
781  search_failed_f(),
782  nominus_cursor(),
783  idx_nominus(),
784  variables(),
785  _comment_start(),
786  _comment_end(),
788 #if !defined(GETPOT_DISABLE_MUTEX)
789  _getpot_mtx(),
790 #endif
796 {
797  this->parse_command_line(argc_, argv_, FieldSeparator);
798 }
std::string section
Definition: getpot.h:509
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
void parse_command_line(const int argc_, const char *const *argv_, const char *FieldSeparator=0x0)
Definition: getpot.h:804
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

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

References parse_input_file().

835  :
836  prefix(),
837  section(),
838  section_list(),
839  argv(),
840  cursor(),
841  search_loop_f(),
842  search_failed_f(),
843  nominus_cursor(),
844  idx_nominus(),
845  variables(),
846  _comment_start(),
847  _comment_end(),
849 #if !defined(GETPOT_DISABLE_MUTEX)
850  _getpot_mtx(),
851 #endif
857 {
858  const std::string& StrCommentStart = CommentStart ? CommentStart : std::string("#");
859  const std::string& StrCommentEnd = CommentEnd ? CommentEnd : std::string("\n");
860  const std::string& StrFieldSeparator = FieldSeparator ? FieldSeparator : std::string(" \t\n");
861  this->parse_input_file(FileName, StrCommentStart, StrCommentEnd, StrFieldSeparator);
862 }
std::string section
Definition: getpot.h:509
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:897
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

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

References parse_input_file().

870  :
871  prefix(),
872  section(),
873  section_list(),
874  argv(),
875  cursor(),
876  search_loop_f(),
877  search_failed_f(),
878  nominus_cursor(),
879  idx_nominus(),
880  variables(),
881  _comment_start(),
882  _comment_end(),
884 #if !defined(GETPOT_DISABLE_MUTEX)
885  _getpot_mtx(),
886 #endif
892 {
893  this->parse_input_file(FileName, CommentStart, CommentEnd, FieldSeparator);
894 }
std::string section
Definition: getpot.h:509
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:897
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

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

References parse_input_stream().

915  :
916  prefix(),
917  section(),
918  section_list(),
919  argv(),
920  cursor(),
921  search_loop_f(),
922  search_failed_f(),
923  nominus_cursor(),
924  idx_nominus(),
925  variables(),
926  _comment_start(),
927  _comment_end(),
929 #if !defined(GETPOT_DISABLE_MUTEX)
930  _getpot_mtx(),
931 #endif
937 {
938  this->parse_input_stream(FileStream,
939  std::string("ParsedFromStream"),// We don't have a filename here
940  CommentStart, CommentEnd, FieldSeparator);
941 }
std::string section
Definition: getpot.h:509
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
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:945
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

◆ ~GetPot()

GETPOT_NAMESPACE::GetPot::~GetPot ( )
inline

Definition at line 1018 of file getpot.h.

References _internal_string_container, and end.

1019 {
1020  // may be some return strings had to be created, delete now !
1021  std::set<const char*, ltstr>::const_iterator it = _internal_string_container.begin();
1022  const std::set<const char*, ltstr>::const_iterator end = _internal_string_container.end();
1023  for (; it != end; ++it)
1024  delete [] *it;
1025 }
IterBase * end
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

Member Function Documentation

◆ _basic_initialization()

void GETPOT_NAMESPACE::GetPot::_basic_initialization ( )
inlineprivate

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

721 {
722  cursor = 0;
723  nominus_cursor = -1;
724  search_failed_f = true;
725  search_loop_f = true;
726  prefix = "";
727  section = "";
728 
729  // automatic request recording for later ufo detection
730  request_recording_f = true;
731 
732  // comment start and end strings
733  _comment_start = std::string("#");
734  _comment_end = std::string("\n");
735 
736  // default: separate vector elements by whitespaces
737  _field_separator = " \t\n";
738 }
std::string section
Definition: getpot.h:509
std::string prefix
Definition: getpot.h:508
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
std::string _comment_start
Definition: getpot.h:535

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

Referenced by argument_contains(), and options_contain().

2158 {
2159  for (const char* p=FlagList; *p != '\0' ; p++)
2160  if (Str.find(*p) != std::string::npos)
2161  return true; // found something
2162  return false;
2163 }

◆ _convert_from_type()

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

Definition at line 690 of file getpot.h.

Referenced by _DBE_expand().

691  {
692  std::ostringstream out_string;
693  out_string << Value;
694  return out_string.str();
695  }

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

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

1569 {
1570  std::istringstream in_string(String);
1571  T retval;
1572  in_string >> retval;
1573  if (in_string.fail())
1574  retval = Default;
1575  return retval;
1576 }

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

1593 {
1594  return String;
1595 }

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

1584 {
1585  return String;
1586 }

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

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

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

References libMesh::Quality::name().

Referenced by get_value_no_default().

1634 {
1635  std::istringstream in_string(String);
1636  T retval;
1637  in_string >> retval;
1638  if (in_string.fail())
1639  {
1640  getpot_cerr <<"ERROR: Input value for variable "<<VarName<<" is of the wrong type."<<std::endl;
1641  getpot_cerr <<" value = "<<String<<" expected type = "<<typeid(T).name()<<std::endl;
1642  getpot_error();
1643  }
1644  return retval;
1645 }
std::string name(const ElemQuality 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 1661 of file getpot.h.

1662 {
1663  return String;
1664 }

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

1653 {
1654  return String;
1655 }

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

References libMesh::Quality::name().

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

◆ _DBE_expand()

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

Definition at line 2928 of file getpot.h.

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

Referenced by _DBE_expand_string(), and _DBE_get_expr_list().

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

◆ _DBE_expand_string()

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

dollar bracket expressions

Definition at line 2770 of file getpot.h.

References _DBE_expand().

Referenced by _parse_argument_vector().

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

◆ _DBE_get_expr_list()

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

Definition at line 2803 of file getpot.h.

References _DBE_expand().

Referenced by _DBE_expand().

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

◆ _DBE_get_variable()

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

Definition at line 2894 of file getpot.h.

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

Referenced by _DBE_expand().

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

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

References prefix, and variables.

Referenced by _request_variable(), and _set_variable().

2658 {
2659  const std::string Name = prefix + VarName;
2660 
2661  std::vector<variable>::const_iterator it = variables.begin();
2662  for (; it != variables.end(); ++it)
2663  {
2664  if ((*it).name == Name)
2665  return &(*it);
2666  }
2667  return 0;
2668 }
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530

◆ _get_next_token()

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

Definition at line 1367 of file getpot.h.

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

Referenced by _read_in_stream().

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

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

1739 {
1740  if (Start == "")
1741  return String;
1742 
1743  // note: java.lang.String: substring(a,b) = from a to b-1
1744  // C++ string: substr(a,b) = from a to a + b
1745  if (String.find(Start) == 0)
1746  return String.substr(Start.length());
1747 
1748  else
1749  return "";
1750 }

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

Referenced by _record_argument_request(), and _record_variable_request().

702  {
703  STRING_VECTOR result;
704  for (std::size_t pos = 0; pos != FullPath.size(); ++pos)
705  {
706  if (FullPath[pos] == '/')
707  result.push_back(FullPath.substr(0,pos));
708  }
709 
710  return result;
711  }
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132

◆ _get_string()

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

Definition at line 1424 of file getpot.h.

Referenced by _get_next_token().

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

◆ _get_until_closing_bracket()

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

Definition at line 1450 of file getpot.h.

Referenced by _get_next_token().

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

◆ _get_until_closing_square_bracket()

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

Definition at line 1483 of file getpot.h.

Referenced by _get_next_token().

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

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

References _internal_string_container.

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

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

◆ _match_starting_string()

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

support finding directly followed arguments

Definition at line 2059 of file getpot.h.

References argv, cursor, search_failed_f, and search_loop_f.

Referenced by direct_follow().

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

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

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

◆ _process_section_label()

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

Definition at line 1511 of file getpot.h.

Referenced by _parse_argument_vector().

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

◆ _read_in_stream()

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

Definition at line 1233 of file getpot.h.

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

Referenced by parse_input_stream().

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

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

2457 {
2458  if (!request_recording_f)
2459  return;
2460 
2461  // Get a lock before touching anything mutable
2462  SCOPED_MUTEX;
2463 
2464  // (*) record requested variable for later ufo detection
2465  _requested_arguments.insert(Name);
2466 
2467  // (*) record considered section for ufo detection
2468  STRING_VECTOR STree = _get_section_tree(Name);
2469  victorate(std::string, STree, it)
2470  if (_requested_sections.find(*it) == _requested_sections.end())
2471  if (section.length() != 0)
2472  _requested_sections.insert(*it);
2473 }
static STRING_VECTOR _get_section_tree(const std::string &FullPath)
Definition: getpot.h:701
std::string section
Definition: getpot.h:509
std::set< std::string > _requested_sections
Definition: getpot.h:581
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132
std::set< std::string > _requested_arguments
Definition: getpot.h:579

◆ _record_variable_request()

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

Definition at line 2478 of file getpot.h.

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

Referenced by _request_variable().

2479 {
2480  if (!request_recording_f)
2481  return;
2482 
2483  // Get a lock before touching anything mutable
2484  SCOPED_MUTEX;
2485 
2486  // (*) record requested variable for later ufo detection
2487  _requested_variables.insert(Name);
2488 
2489  // (*) record considered section for ufo detection
2490  STRING_VECTOR STree = _get_section_tree(Name);
2491  victorate(std::string, STree, it)
2492  if (_requested_sections.find(*it) == _requested_sections.end())
2493  if (section.length() != 0)
2494  _requested_sections.insert(*it);
2495 }
static STRING_VECTOR _get_section_tree(const std::string &FullPath)
Definition: getpot.h:701
std::string section
Definition: getpot.h:509
std::set< std::string > _requested_sections
Definition: getpot.h:581
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132

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

2674 {
2675  // (*) record requested variable for later ufo detection
2676  this->_record_variable_request(VarName);
2677 
2678  return this->_find_variable(VarName);
2679 }
const variable * _find_variable(const char *) const
Definition: getpot.h:2657
void _record_variable_request(const std::string &Arg) const
Definition: getpot.h:2478

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

3434 {
3435  victorate(std::string, VecStr, itk)
3436  {
3437  if (*itk == Str)
3438  return true;
3439  }
3440  return false;
3441 }

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

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

Referenced by _parse_argument_vector(), and set().

2504 {
2505  const GetPot::variable* Var = Requested ?
2506  _request_variable(VarName.c_str()) :
2507  _find_variable(VarName.c_str());
2508  if (Var == 0)
2509  variables.push_back(variable(VarName.c_str(), Value.c_str(), _field_separator.c_str()));
2510  else
2511  {
2512  overridden_vars.insert(VarName.c_str());
2513  (const_cast<GetPot::variable*>(Var))->take(Value.c_str(), _field_separator.c_str());
2514  }
2515 }
const variable * _find_variable(const char *) const
Definition: getpot.h:2657
std::vector< variable > variables
Definition: getpot.h:530
const variable * _request_variable(const char *) const
Definition: getpot.h:2673
std::string _field_separator
Definition: getpot.h:541
std::set< std::string > overridden_vars
Definition: getpot.h:519

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

Definition at line 1305 of file getpot.h.

References _comment_end, and _comment_start.

Referenced by _read_in_stream().

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

◆ absorb()

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

absorbing contents of another GetPot object

Definition at line 1087 of file getpot.h.

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

1088 {
1089  if (&Other == this)
1090  return;
1091 
1092  // variables that are not influenced by absorption:
1093  // _comment_start
1094  // _comment_end
1095  // cursor
1096  // nominus_cursor
1097  // search_failed
1098  // idx_nominus
1099  // search_loop_f
1100  argv = Other.argv;
1101  variables = Other.variables;
1102 
1103  if (request_recording_f)
1104  {
1105  // Get a lock before touching anything mutable
1106  SCOPED_MUTEX;
1107 
1108  _requested_arguments.insert(Other._requested_arguments.begin(), Other._requested_arguments.end());
1109  _requested_variables.insert(Other._requested_variables.begin(), Other._requested_variables.end());
1110  _requested_sections.insert(Other._requested_sections.begin(), Other._requested_sections.end());
1111  }
1112 }
std::vector< variable > variables
Definition: getpot.h:530
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::set< std::string > _requested_arguments
Definition: getpot.h:579

◆ argument_contains()

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

Definition at line 2122 of file getpot.h.

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

2123 {
2124  if (Idx >= argv.size())
2125  return false;
2126 
2127  // (*) record requested of argument for later ufo-detection
2128  // an argument that is checked for flags is considered to be 'requested'
2130 
2131  if (prefix == "")
2132  // search argument for any flag in flag list
2133  return _check_flags(argv[Idx], FlagList);
2134 
2135  // if a prefix is set, then the argument index is the index
2136  // inside the 'namespace'
2137  // => only check list of arguments that start with prefix
2138  unsigned no_matches = 0;
2139  for (unsigned i=0; i<argv.size(); i++)
2140  {
2141  const std::string Remain = _get_remaining_string(argv[i], prefix);
2142  if (Remain != "")
2143  {
2144  no_matches += 1;
2145  if (no_matches == Idx)
2146  return _check_flags(Remain, FlagList);
2147  }
2148  }
2149 
2150  // no argument in this namespace
2151  return false;
2152 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
Definition: getpot.h:1738
bool _check_flags(const std::string &Str, const char *FlagList) const
Definition: getpot.h:2157
std::string prefix
Definition: getpot.h:508
STRING_VECTOR argv
Definition: getpot.h:515
void _record_argument_request(const std::string &Arg) const
Definition: getpot.h:2456

◆ clear_requests()

void GETPOT_NAMESPACE::GetPot::clear_requests ( )
inline

for ufo detection: recording requested arguments, options etc.

Definition at line 1117 of file getpot.h.

References _requested_arguments, _requested_sections, and _requested_variables.

1118 {
1119  // Get a lock before touching anything mutable
1120  SCOPED_MUTEX;
1121 
1122  _requested_arguments.clear();
1123  _requested_variables.clear();
1124  _requested_sections.clear();
1125 }
std::set< std::string > _requested_sections
Definition: getpot.h:581
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::set< std::string > _requested_arguments
Definition: getpot.h:579

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

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

Referenced by direct_follow().

2031 {
2032  const char* FollowStr = _match_starting_string(Option);
2033 
2034  // (*) record requested of argument for later ufo-detection
2035  _record_argument_request(std::string(Option) + FollowStr);
2036 
2037  if (FollowStr == 0)
2038  return Default;
2039 
2040  if (++cursor >= argv.size())
2041  cursor = getpot_cast_int<unsigned>(argv.size());
2042  return _convert_to_type(FollowStr, Default);
2043 }
const char * _match_starting_string(const char *StartString)
Definition: getpot.h:2059
T _convert_to_type(const std::string &String, const T &Default) const
Definition: getpot.h:1568
STRING_VECTOR argv
Definition: getpot.h:515
void _record_argument_request(const std::string &Arg) const
Definition: getpot.h:2456

◆ direct_follow() [2/2]

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

Definition at line 2048 of file getpot.h.

References _internal_managed_copy(), and direct_follow().

2049 {
2050  return _internal_managed_copy(direct_follow(std::string(Default), Option));
2051 }
T direct_follow(const T &Default, const char *Option)
Definition: getpot.h:2030
const char * _internal_managed_copy(const std::string &Arg) const
Definition: getpot.h:1706

◆ disable_loop()

void GETPOT_NAMESPACE::GetPot::disable_loop ( )
inline

enable/disable search for an option in loop

Definition at line 360 of file getpot.h.

References search_loop_f.

Referenced by init_multiple_occurrence().

360 { search_loop_f = false; }

◆ disable_request_recording()

void GETPOT_NAMESPACE::GetPot::disable_request_recording ( )
inline

Definition at line 209 of file getpot.h.

References request_recording_f.

209 { request_recording_f = false; }

◆ enable_loop()

void GETPOT_NAMESPACE::GetPot::enable_loop ( )
inline

Definition at line 361 of file getpot.h.

References search_loop_f.

361 { search_loop_f = true; }

◆ enable_request_recording()

void GETPOT_NAMESPACE::GetPot::enable_request_recording ( )
inline

Definition at line 210 of file getpot.h.

References request_recording_f.

210 { 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 1948 of file getpot.h.

References next(), and search().

Referenced by follow().

1949 {
1950  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1951  if (search(Option) == false)
1952  return Default;
1953 
1954  return next(Default);
1955 }
bool search(const char *option)
Definition: getpot.h:1765
T next(const T &Default)
Definition: getpot.h:1915

◆ follow() [2/5]

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

Definition at line 1960 of file getpot.h.

References _internal_managed_copy(), and follow().

1961 {
1962  return _internal_managed_copy(follow(std::string(Default), Option));
1963 }
T follow(const T &Default, const char *Option)
Definition: getpot.h:1948
const char * _internal_managed_copy(const std::string &Arg) const
Definition: getpot.h:1706

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

References next(), and search().

1999 {
2000  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
2001  if (No == 0)
2002  return Default;
2003 
2004  if (search(P) == true)
2005  return next(Default);
2006 
2007  va_list ap;
2008  va_start(ap, P);
2009  for (unsigned i=1; i<No; i++)
2010  {
2011  char* Opt = va_arg(ap, char *);
2012  if (search(Opt) == true)
2013  {
2014  va_end(ap);
2015  return next(Default);
2016  }
2017  }
2018  va_end(ap);
2019  return Default;
2020 }
bool search(const char *option)
Definition: getpot.h:1765
T next(const T &Default)
Definition: getpot.h:1915

◆ follow() [5/5]

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

Definition at line 1971 of file getpot.h.

References next(), and search().

1972 {
1973  // (*) record requested of argument is entirely handled in 'search()' and 'next()'
1974  if (No == 0)
1975  return Default;
1976 
1977  if (search(P) == true)
1978  return next(Default);
1979 
1980  va_list ap;
1981  va_start(ap, P);
1982  for (unsigned i=1; i<No; i++)
1983  {
1984  char* Opt = va_arg(ap, char *);
1985  if (search(Opt) == true)
1986  {
1987  va_end(ap);
1988  return next(Default);
1989  }
1990  }
1991  va_end(ap);
1992  return Default;
1993 }
bool search(const char *option)
Definition: getpot.h:1765
T next(const T &Default)
Definition: getpot.h:1915

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

References _convert_to_type(), and argv.

1886 {
1887  if (Idx >= argv.size())
1888  return Default;
1889  return _convert_to_type(argv[Idx], Default);
1890 }
T _convert_to_type(const std::string &String, const T &Default) const
Definition: getpot.h:1568
STRING_VECTOR argv
Definition: getpot.h:515

◆ get_overridden_variables()

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

Definition at line 2649 of file getpot.h.

References overridden_vars.

2650 {
2651  return overridden_vars;
2652 }
std::set< std::string > overridden_vars
Definition: getpot.h:519

◆ get_requested_arguments()

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

Accessors for requested variables

Definition at line 3883 of file getpot.h.

References _requested_arguments.

3884 {
3885  return _requested_arguments;
3886 }
std::set< std::string > _requested_arguments
Definition: getpot.h:579

◆ get_requested_sections()

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

Definition at line 3901 of file getpot.h.

References _requested_sections.

3902 {
3903  return _requested_sections;
3904 }
std::set< std::string > _requested_sections
Definition: getpot.h:581

◆ get_requested_variables()

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

Definition at line 3892 of file getpot.h.

References _requested_variables.

3893 {
3894  return _requested_variables;
3895 }
std::set< std::string > _requested_variables
Definition: getpot.h:580

◆ get_section_names()

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

Definition at line 2591 of file getpot.h.

References section_list.

2592 {
2593  return section_list;
2594 }
STRING_VECTOR section_list
Definition: getpot.h:510

◆ get_subsection_names()

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

Definition at line 2599 of file getpot.h.

References section_list.

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

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

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

Referenced by get_value_no_default().

2369 {
2370  // (*) recording of requested variables happens in '_request_variable()'
2371  const variable* sv = _request_variable(VarName);
2372  if (sv == 0)
2373  {
2374  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2375  getpot_error();
2376  }
2377  return _convert_to_type_no_default(VarName, sv->original, Default);
2378 }
T _convert_to_type_no_default(const char *VarName, const std::string &String, const T &Default) const
Definition: getpot.h:1633
const variable * _request_variable(const char *) const
Definition: getpot.h:2673

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

References get_value_no_default().

2385 {
2386  return get_value_no_default(VarName.c_str(),Default);
2387 }
T get_value_no_default(const char *VarName, const T &Default) const
Definition: getpot.h:2368

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

References _internal_managed_copy(), and get_value_no_default().

2393 {
2394  return _internal_managed_copy(get_value_no_default(VarName, std::string(Default)));
2395 }
T get_value_no_default(const char *VarName, const T &Default) const
Definition: getpot.h:2368
const char * _internal_managed_copy(const std::string &Arg) const
Definition: getpot.h:1706

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

References get_value_no_default().

2401 {
2402  return get_value_no_default(VarName.c_str(),Default);
2403 }
T get_value_no_default(const char *VarName, const T &Default) const
Definition: getpot.h:2368

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

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

2410 {
2411  // (*) recording of requested variables happens in '_request_variable()'
2412  const variable* sv = _request_variable(VarName);
2413  if (sv == 0)
2414  {
2415  getpot_cerr << "ERROR: cannot find variable "<<VarName<<std::endl;
2416  getpot_error();
2417  }
2418 
2419  const std::string* element = sv->get_element(Idx);
2420  if (element == 0)
2421  {
2422  getpot_cerr << "ERROR: cannot find index "<<Idx<<" of variable "<<VarName<<std::endl;
2423  getpot_error();
2424  }
2425  return _convert_to_type_no_default(VarName, *element, Default);
2426 }
T _convert_to_type_no_default(const char *VarName, const std::string &String, const T &Default) const
Definition: getpot.h:1633
const variable * _request_variable(const char *) const
Definition: getpot.h:2673

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

References get_value_no_default().

2433 {
2434  return get_value_no_default(VarName.c_str(), Default, Idx);
2435 }
T get_value_no_default(const char *VarName, const T &Default) const
Definition: getpot.h:2368

◆ get_variable_names()

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

Definition at line 2575 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

2576 {
2577  STRING_VECTOR result;
2578  std::vector<GetPot::variable>::const_iterator it = variables.begin();
2579  for (; it != variables.end(); ++it)
2580  {
2581  const std::string Tmp = _get_remaining_string((*it).name, prefix);
2582  if (Tmp != "")
2583  result.push_back(Tmp);
2584  }
2585  return result;
2586 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
Definition: getpot.h:1738
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132

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

2258 {
2259  std::string s = std::string(section_name);
2260  return this->have_section(s);
2261 }
bool have_section(const char *section_name) const
Definition: getpot.h:2257
const char * s

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

References section_list.

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

◆ have_variable() [1/2]

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

variables check for a variable

Definition at line 2238 of file getpot.h.

References _request_variable().

Referenced by have_variable().

2239 {
2240  const variable* sv = _request_variable(VarName);
2241 
2242  if (sv == 0)
2243  return false;
2244 
2245  return true;
2246 }
const variable * _request_variable(const char *) const
Definition: getpot.h:2673

◆ have_variable() [2/2]

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

Definition at line 2251 of file getpot.h.

References have_variable().

2252 {
2253  return have_variable(VarName.c_str());
2254 }
bool have_variable(const char *VarName) const
Definition: getpot.h:2238

◆ init_multiple_occurrence()

void GETPOT_NAMESPACE::GetPot::init_multiple_occurrence ( )
inline

Definition at line 1863 of file getpot.h.

References disable_loop(), and reset_cursor().

1864 {
1865  disable_loop();
1866  reset_cursor();
1867 }

◆ next() [1/2]

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

get argument at cursor++

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

1916 {
1917  if (search_failed_f)
1918  return Default;
1919  cursor++;
1920  if (cursor >= argv.size())
1921  {
1922  cursor = getpot_cast_int<unsigned>(argv.size());
1923  return Default;
1924  }
1925 
1926  // (*) record requested argument for later ufo detection
1928 
1929  const std::string Remain = _get_remaining_string(argv[cursor], prefix);
1930 
1931  return Remain != "" ? _convert_to_type(Remain, Default) : Default;
1932 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
Definition: getpot.h:1738
std::string prefix
Definition: getpot.h:508
T _convert_to_type(const std::string &String, const T &Default) const
Definition: getpot.h:1568
STRING_VECTOR argv
Definition: getpot.h:515
void _record_argument_request(const std::string &Arg) const
Definition: getpot.h:2456

◆ next() [2/2]

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

Definition at line 1937 of file getpot.h.

References _internal_managed_copy(), and next().

1938 {
1939  return _internal_managed_copy(next(std::string(Default)));
1940 }
const char * _internal_managed_copy(const std::string &Arg) const
Definition: getpot.h:1706
T next(const T &Default)
Definition: getpot.h:1915

◆ next_nominus()

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

Definition at line 2191 of file getpot.h.

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

2192 {
2193  if (nominus_cursor < int(idx_nominus.size()) - 1)
2194  {
2195  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2196 
2197  // (*) record for later ufo-detection
2199 
2200  return _internal_managed_copy(Tmp);
2201  }
2202 
2203  return 0;
2204 }
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
const char * _internal_managed_copy(const std::string &Arg) const
Definition: getpot.h:1706
STRING_VECTOR argv
Definition: getpot.h:515
void _record_argument_request(const std::string &Arg) const
Definition: getpot.h:2456

◆ next_nominus_string()

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

Definition at line 2208 of file getpot.h.

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

2209 {
2210  if (nominus_cursor < int(idx_nominus.size()) - 1)
2211  {
2212  const std::string Tmp = argv[idx_nominus[++nominus_cursor]];
2213 
2214  // (*) record for later ufo-detection
2216 
2217  return Tmp;
2218  }
2219 
2220  return "";
2221 }
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
STRING_VECTOR argv
Definition: getpot.h:515
void _record_argument_request(const std::string &Arg) const
Definition: getpot.h:2456

◆ nominus_size()

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

Definition at line 413 of file getpot.h.

References idx_nominus.

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

◆ nominus_vector()

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

Definition at line 2172 of file getpot.h.

References _record_argument_request(), argv, and idx_nominus.

2173 {
2174  STRING_VECTOR nv;
2175  std::vector<unsigned>::const_iterator it = idx_nominus.begin();
2176  for (; it != idx_nominus.end(); ++it)
2177  {
2178  nv.push_back(argv[*it]);
2179 
2180  // (*) record for later ufo-detection
2181  // when a nominus vector is requested, the entire set of nominus arguments are
2182  // tagged as 'requested'
2184  }
2185  return nv;
2186 }
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
STRING_VECTOR argv
Definition: getpot.h:515
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132
void _record_argument_request(const std::string &Arg) const
Definition: getpot.h:2456

◆ operator()() [1/10]

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

scalar values

Definition at line 2286 of file getpot.h.

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

Referenced by operator()().

2287 {
2288  // (*) recording of requested variables happens in '_request_variable()'
2289  const variable* sv = _request_variable(VarName);
2290 
2291  if (sv == 0)
2292  return Default;
2293 
2294  return _convert_to_type(sv->original, Default);
2295 }
T _convert_to_type(const std::string &String, const T &Default) const
Definition: getpot.h:1568
const variable * _request_variable(const char *) const
Definition: getpot.h:2673

◆ operator()() [2/10]

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

Definition at line 2301 of file getpot.h.

References operator()().

2302 {
2303  return operator()(VarName.c_str(), Default);
2304 }
T operator()(const char *VarName, const T &Default) const
Definition: getpot.h:2286

◆ operator()() [3/10]

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

Definition at line 2309 of file getpot.h.

References _internal_managed_copy().

2310 {
2311  return _internal_managed_copy(operator()(VarName, std::string(Default)));
2312 }
const char * _internal_managed_copy(const std::string &Arg) const
Definition: getpot.h:1706

◆ operator()() [4/10]

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

Definition at line 2317 of file getpot.h.

References operator()().

2318 {
2319  return operator()(VarName.c_str(), Default);
2320 }
T operator()(const char *VarName, const T &Default) const
Definition: getpot.h:2286

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

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

2327 {
2328  // (*) recording of requested variables happens in '_request_variable()'
2329  const variable* sv = _request_variable(VarName);
2330  if (sv == 0)
2331  return Default;
2332 
2333  const std::string* element = sv->get_element(Idx);
2334  if (element == 0)
2335  return Default;
2336  return _convert_to_type(*element, Default);
2337 }
T _convert_to_type(const std::string &String, const T &Default) const
Definition: getpot.h:1568
const variable * _request_variable(const char *) const
Definition: getpot.h:2673

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

References operator()().

2344 {
2345  return operator()(VarName.c_str(), Default, Idx);
2346 }
T operator()(const char *VarName, const T &Default) const
Definition: getpot.h:2286

◆ operator=()

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

Definition at line 1030 of file getpot.h.

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

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

1031 {
1032  if (&Other == this)
1033  return *this;
1034 
1035  prefix = Other.prefix;
1036  section = Other.section;
1037  section_list = Other.section_list;
1038  argv = Other.argv;
1039  cursor = Other.cursor;
1040  search_loop_f = Other.search_loop_f;
1041  search_failed_f = Other.search_failed_f;
1042  nominus_cursor = Other.nominus_cursor;
1043  overridden_vars = Other.overridden_vars;
1044  idx_nominus = Other.idx_nominus;
1045  variables = Other.variables;
1046  _comment_start = Other._comment_start;
1047  _comment_end = Other._comment_end;
1048  _field_separator = Other._field_separator;
1049  // #if !defined(GETPOT_DISABLE_MUTEX)
1050  // _getpot_mtx = Other._getpot_mtx;
1051  // #endif
1052  _requested_arguments = Other._requested_arguments;
1053  _requested_variables = Other._requested_variables;
1054  _requested_sections = Other._requested_sections;
1055  request_recording_f = Other.request_recording_f;
1056 
1057  std::set<const char*, ltstr>::const_iterator my_it =
1059  const std::set<const char*, ltstr>::const_iterator my_end =
1061 
1062  for (; my_it != my_end; ++my_it)
1063  delete [] *my_it;
1064 
1066 
1067  std::set<const char*,ltstr>::const_iterator it =
1068  Other._internal_string_container.begin();
1069  const std::set<const char*,ltstr>::const_iterator end =
1070  Other._internal_string_container.end();
1071 
1072  for (; it != end; ++it)
1073  {
1074  const char* otherstr = *it;
1075  const std::size_t bufsize = strlen(otherstr)+1;
1076  char* newcopy = new char[bufsize];
1077  strncpy(newcopy, otherstr, bufsize);
1078  this->_internal_string_container.insert(newcopy);
1079  }
1080 
1081  return *this;
1082 }
std::string section
Definition: getpot.h:509
IterBase * end
std::vector< unsigned > idx_nominus
Definition: getpot.h:525
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::set< std::string > _requested_sections
Definition: getpot.h:581
STRING_VECTOR argv
Definition: getpot.h:515
std::set< std::string > _requested_variables
Definition: getpot.h:580
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
STRING_VECTOR section_list
Definition: getpot.h:510
std::string _comment_start
Definition: getpot.h:535
std::set< std::string > overridden_vars
Definition: getpot.h:519
std::set< std::string > _requested_arguments
Definition: getpot.h:579
std::set< const char *, ltstr > _internal_string_container
Definition: getpot.h:567

◆ operator[]()

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

direct access to command line arguments

Definition at line 1876 of file getpot.h.

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

1877 {
1878  return idx<argv.size() ? argv[idx].c_str() : 0;
1879 }
STRING_VECTOR argv
Definition: getpot.h:515
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)

◆ options_contain()

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

flags

Definition at line 2103 of file getpot.h.

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

2104 {
2105  // go through all arguments that start with a '-' (but not '--')
2106  std::string str;
2107  STRING_VECTOR::const_iterator it = argv.begin();
2108  for (; it != argv.end(); ++it)
2109  {
2110  str = _get_remaining_string(*it, prefix);
2111 
2112  if (str.length() >= 2 && str[0] == '-' && str[1] != '-')
2113  if (_check_flags(str, FlagList))
2114  return true;
2115  }
2116  return false;
2117 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
Definition: getpot.h:1738
bool _check_flags(const std::string &Str, const char *FlagList) const
Definition: getpot.h:2157
std::string prefix
Definition: getpot.h:508
STRING_VECTOR argv
Definition: getpot.h:515

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

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

Referenced by GetPot().

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

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

References parse_input_stream().

Referenced by _parse_argument_vector(), and GetPot().

901 {
902  std::ifstream input(FileName.c_str());
903 
904  if (!input)
905  getpot_file_error(FileName);
906 
907  this->parse_input_stream(input,FileName,CommentStart,CommentEnd,FieldSeparator);
908 }
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:945

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

950 {
952 
953  // overwrite default strings
954  _comment_start = std::string(CommentStart);
955  _comment_end = std::string(CommentEnd);
956  _field_separator = FieldSeparator;
957 
958  STRING_VECTOR _apriori_argv;
959  // -- the first element of the argument vector stores the name of
960  // the first parsing source; however, this element is not
961  // parsed for variable assignments or nominuses.
962  //
963  // Regardless, we don't add more than one name to the argument
964  // vector. In this case, we're parsing from a stream, so we'll
965  // hardcode the "filename" to "ParsedFromStream"
966  _apriori_argv.push_back(FileName);
967 
968  STRING_VECTOR args = _read_in_stream(FileStream);
969  _apriori_argv.insert(_apriori_argv.begin()+1, args.begin(), args.end());
970  _parse_argument_vector(_apriori_argv);
971 }
STRING_VECTOR _read_in_stream(std::istream &istr)
Definition: getpot.h:1233
void _parse_argument_vector(const STRING_VECTOR &ARGV)
Definition: getpot.h:1130
void _basic_initialization()
Definition: getpot.h:720
std::string _field_separator
Definition: getpot.h:541
std::string _comment_end
Definition: getpot.h:536
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132
std::string _comment_start
Definition: getpot.h:535

◆ print() [1/2]

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

output Print everything

Definition at line 2688 of file getpot.h.

References argv.

2689 {
2690  out_stream << "argc = " << argv.size() << std::endl;
2691  STRING_VECTOR::const_iterator it = argv.begin();
2692  for (; it != argv.end(); ++it)
2693  out_stream << *it << std::endl;
2694  out_stream << std::endl;
2695  return 1;
2696 }
STRING_VECTOR argv
Definition: getpot.h:515

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

References argv.

2707 {
2708  STRING_VECTOR::const_iterator it = argv.begin();
2709  it += skip_count;
2710  for (; it != argv.end(); ++it)
2711  {
2712  out_stream << custom_prefix;
2713  out_stream << *it << std::endl;
2714  }
2715  out_stream << std::endl;
2716  return 1;
2717 }
STRING_VECTOR argv
Definition: getpot.h:515

◆ reset_cursor()

void GETPOT_NAMESPACE::GetPot::reset_cursor ( )
inline

reset cursor to position '1'

Definition at line 1854 of file getpot.h.

References cursor, and search_failed_f.

Referenced by init_multiple_occurrence().

1855 {
1856  search_failed_f = false;
1857  cursor = 0;
1858 }

◆ reset_nominus_cursor()

void GETPOT_NAMESPACE::GetPot::reset_nominus_cursor ( )
inline

nominus arguments

Definition at line 2226 of file getpot.h.

References nominus_cursor.

2227 {
2228  nominus_cursor = -1;
2229 }

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

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

Referenced by follow(), and search().

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

◆ search() [2/3]

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

Definition at line 1756 of file getpot.h.

References search().

1757 {
1758  return search(Option.c_str());
1759 }
bool search(const char *option)
Definition: getpot.h:1765

◆ search() [3/3]

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

Definition at line 1808 of file getpot.h.

References _record_argument_request(), and search().

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

◆ search_failed()

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

Definition at line 355 of file getpot.h.

References search_failed_f.

355 { 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 2521 of file getpot.h.

References _set_variable().

2522 {
2523  std::ostringstream string_value;
2524  string_value << Value;
2525  _set_variable(VarName, string_value.str().c_str(), Requested);
2526 }
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
Definition: getpot.h:2502

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

2533 {
2534  set(VarName.c_str(), Value, Requested);
2535 }

◆ set() [3/4]

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

Definition at line 2540 of file getpot.h.

References _set_variable().

2541 {
2542  _set_variable(VarName, Value, Requested);
2543 }
void _set_variable(const std::string &VarName, const std::string &Value, const bool Requested)
Definition: getpot.h:2502

◆ set() [4/4]

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

Definition at line 2548 of file getpot.h.

2549 {
2550  set(VarName.c_str(), Value, Requested);
2551 }

◆ set_prefix()

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

cursor oriented functions

Definition at line 354 of file getpot.h.

References prefix.

354 { prefix = std::string(Prefix); }
std::string prefix
Definition: getpot.h:508

◆ size()

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

Definition at line 1905 of file getpot.h.

References argv.

Referenced by _DBE_expand().

1906 {
1907  return getpot_cast_int<unsigned>(argv.size());
1908 }
STRING_VECTOR argv
Definition: getpot.h:515

◆ unidentified_arguments() [1/4]

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

unidentified flying objects

Definition at line 3446 of file getpot.h.

References unidentified_arguments().

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

◆ unidentified_arguments() [2/4]

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

Definition at line 3486 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

◆ unidentified_arguments() [3/4]

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

Definition at line 3476 of file getpot.h.

References unidentified_arguments().

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

◆ unidentified_arguments() [4/4]

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

Definition at line 3468 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_arguments(), and unidentified_options().

3469 {
3471 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3468
std::set< std::string > _requested_arguments
Definition: getpot.h:579

◆ unidentified_flags()

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

Definition at line 3584 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

◆ unidentified_nominuses() [1/4]

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

Definition at line 3781 of file getpot.h.

References unidentified_nominuses().

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

◆ unidentified_nominuses() [2/4]

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

Definition at line 3832 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

◆ unidentified_nominuses() [3/4]

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

Definition at line 3822 of file getpot.h.

References unidentified_nominuses().

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

◆ unidentified_nominuses() [4/4]

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

Definition at line 3807 of file getpot.h.

References _requested_arguments.

Referenced by unidentified_nominuses().

3808 {
3809  // -- every nominus is an argument.
3810  // -- the set of requested arguments contains the set of requested nominuss.
3811  // -- IF the set of requested arguments contains unrequested nominuss,
3812  // THEN they were requested as 'follow' and 'next' arguments and not as real nominuses.
3813  //
3814  // => it is not necessary to separate requested nominus from the list
3815 
3817 }
STRING_VECTOR unidentified_nominuses() const
Definition: getpot.h:3807
std::set< std::string > _requested_arguments
Definition: getpot.h:579

◆ unidentified_options() [1/4]

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

Definition at line 3508 of file getpot.h.

References unidentified_options().

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

◆ unidentified_options() [2/4]

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

Definition at line 3554 of file getpot.h.

References _get_remaining_string(), argv, and prefix.

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

◆ unidentified_options() [3/4]

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

Definition at line 3544 of file getpot.h.

References unidentified_options().

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

◆ unidentified_options() [4/4]

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

Definition at line 3530 of file getpot.h.

References _requested_arguments, and unidentified_arguments().

Referenced by unidentified_options().

3531 {
3532  // -- every option is an argument.
3533  // -- the set of requested arguments contains the set of requested options.
3534  // -- IF the set of requested arguments contains unrequested options,
3535  // THEN they were requested as 'follow' and 'next' arguments and not as real options.
3536  //
3537  // => it is not necessary to separate requested options from the list
3539 }
STRING_VECTOR unidentified_arguments() const
Definition: getpot.h:3468
std::set< std::string > _requested_arguments
Definition: getpot.h:579

◆ unidentified_sections() [1/4]

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

Definition at line 3709 of file getpot.h.

References unidentified_sections().

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

◆ unidentified_sections() [2/4]

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

Definition at line 3759 of file getpot.h.

References _get_remaining_string(), prefix, and section_list.

3760 {
3761  STRING_VECTOR ufos;
3762 
3763  victorate(std::string, section_list, it)
3764  {
3765  // -- check if section conform to prefix
3766  const std::string sec_name = _get_remaining_string(*it, prefix);
3767  if (sec_name == "")
3768  continue;
3769 
3770  // -- check if section is known
3771  if (Knowns.find(sec_name) == Knowns.end())
3772  ufos.push_back(*it);
3773  }
3774 
3775  return ufos;
3776 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
Definition: getpot.h:1738
std::string prefix
Definition: getpot.h:508
STRING_VECTOR section_list
Definition: getpot.h:510
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132

◆ unidentified_sections() [3/4]

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

Definition at line 3749 of file getpot.h.

References unidentified_sections().

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

◆ unidentified_sections() [4/4]

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

Definition at line 3741 of file getpot.h.

References _requested_sections.

Referenced by unidentified_sections().

3742 {
3744 }
STRING_VECTOR unidentified_sections() const
Definition: getpot.h:3741
std::set< std::string > _requested_sections
Definition: getpot.h:581

◆ unidentified_variables() [1/4]

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

Definition at line 3648 of file getpot.h.

References unidentified_variables().

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

◆ unidentified_variables() [2/4]

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

Definition at line 3680 of file getpot.h.

References _get_remaining_string(), prefix, and variables.

3681 {
3682  STRING_VECTOR ufos;
3683 
3684  victorate(GetPot::variable, variables, it)
3685  {
3686  // -- check if variable has specific prefix
3687  const std::string var_name = _get_remaining_string((*it).name, prefix);
3688  if (var_name == "")
3689  continue;
3690 
3691  // -- check if variable is known
3692  if (Knowns.find(var_name) == Knowns.end())
3693  ufos.push_back((*it).name);
3694  }
3695  return ufos;
3696 }
const std::string _get_remaining_string(const std::string &String, const std::string &Start) const
Definition: getpot.h:1738
std::string prefix
Definition: getpot.h:508
std::vector< variable > variables
Definition: getpot.h:530
std::vector< std::string > STRING_VECTOR
Definition: getpot.h:132

◆ unidentified_variables() [3/4]

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

Definition at line 3670 of file getpot.h.

References unidentified_variables().

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

◆ unidentified_variables() [4/4]

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

Definition at line 3701 of file getpot.h.

References _requested_variables.

Referenced by unidentified_variables().

3702 {
3704 }
STRING_VECTOR unidentified_variables() const
Definition: getpot.h:3701
std::set< std::string > _requested_variables
Definition: getpot.h:580

◆ vector_variable_size() [1/2]

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

Definition at line 2556 of file getpot.h.

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

Referenced by vector_variable_size().

2557 {
2558  const variable* sv = _request_variable(VarName);
2559  if (sv == 0)
2560  return 0;
2561  return (unsigned)(sv->value.size());
2562 }
const variable * _request_variable(const char *) const
Definition: getpot.h:2673

◆ vector_variable_size() [2/2]

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

Definition at line 2567 of file getpot.h.

References vector_variable_size().

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

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

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

◆ _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 579 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

◆ 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 557 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 524 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 519 of file getpot.h.

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

◆ prefix

◆ 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 530 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: