28 #ifndef __INCLUDE_GUARD_GETPOT_HPP__ 29 #define __INCLUDE_GUARD_GETPOT_HPP__ 31 #ifndef GETPOT_SETTING_THROW_EXCEPTION_ON_DEFAULT 32 # define GETPOT_SETTING_THROW_EXCEPTION_ON_DEFAULT false 34 #ifndef GETPOT_SETTING_DEFAULT_TRUE_STRING_LIST 35 # define GETPOT_SETTING_DEFAULT_TRUE_STRING_LIST "true True TRUE yes Yes YES" 37 #ifndef GETPOT_SETTING_DEFAULT_FALSE_STRING_LIST 38 # define GETPOT_SETTING_DEFAULT_FALSE_STRING_LIST "false False FALSE no No NO" 41 #ifndef GETPOT_SETTING_NAMESPACE 50 #define GETPOT_STR_FILE "File" 51 #define GETPOT_STR_FILE_NOT_FOUND(FILE) std::string("File \"") + FILE + "\" not found." 52 #define GETPOT_STR_REACHED_END_OF_CONSTRAINT std::string("Unexpected end of constraint string reached") 53 #define GETPOT_STR_MISSING_VARIABLE "missing variable" 54 #define GETPOT_STR_VARIABLE "variable" 55 #define GETPOT_STR_VALUE "for the value (read in configuration file)" 56 #define GETPOT_STR_WITH_TYPE "of type" 57 #define GETPOT_STR_IN_SECTION "in section" 58 #define GETPOT_STR_CANNOT_CONVERT_TO(X, TYPE) std::string("Cannot convert '") + X + "' to type " + (TYPE) + "." 59 #define GETPOT_STR_DOES_NOT_SATISFY_CONSTRAINT "does not fulfill the constraint" 60 #define GETPOT_STR_DOES_NOT_CONTAIN_ELEMENT "does not contain element" 61 #define GETPOT_STR_TRUE_FALSE_UNDEFINED "GetPot: no strings defined for meaning of 'true' and 'false'." 87 #ifdef GETPOT_SETTING_NAMESPACE 88 namespace GETPOT_SETTING_NAMESPACE {
100 {
if( Value == 0 ) content = std::string(
"");
else content = std::string(Value); }
102 { content = std::string(Value); }
108 void __basic_initialization();
113 GetPot(
const int argc_,
char** argv_,
const StringOrCharP FieldSeparator=(
const char*)0x0);
126 void set_true_string_list(
unsigned N,
const char* StringForTrue, ...);
127 void set_false_string_list(
unsigned N,
const char* StringForFalse, ...);
130 void absorb(
const GetPot& That);
133 void clear_requests();
140 const std::string operator[](
unsigned Idx)
const;
142 unsigned size()
const;
145 bool options_contain(
const char* FlagList)
const;
146 bool argument_contains(
unsigned Idx,
const char* FlagList)
const;
149 template <
class T> T next(T Default);
153 template <
class T> T follow(T Default,
const char* Option);
154 template <
class T> T follow(T Default,
unsigned No,
const char* Option, ...);
157 template <
class T> T direct_follow(T Default,
const char* Option);
159 std::vector<std::string> string_tails(
const char* StartString);
160 std::vector<int> int_tails(
const char* StartString,
const int Default = 1);
161 std::vector<double> double_tails(
const char* StartString,
const double Default = 1.0);
165 STRING_VECTOR nominus_followers(
const char* Option);
166 STRING_VECTOR nominus_followers(
unsigned No, ...);
169 STRING_VECTOR nominus_vector()
const;
170 unsigned nominus_size()
const {
return static_cast<unsigned int>(idx_nominus.size()); }
171 std::string next_nominus();
174 template <
class T> T
get(
unsigned Idx, T Default)
const;
179 STRING_VECTOR get_section_names()
const;
181 STRING_VECTOR get_variable_names()
const;
183 template <
class T> T operator()(
const StringOrCharP VarName, T Default)
const;
185 template <
class T> T
get(
const StringOrCharP VarName,
const char* Constraint);
186 template <
class T> T
get(
const StringOrCharP VarName,
const char* Constraint,
190 template <
class T> T operator()(
const StringOrCharP VarName,
unsigned Idx, T Default)
const;
191 template <
class T> T get_element(
const StringOrCharP VarName,
unsigned Idx,
192 const char* Constraint);
193 template <
class T> T get_element(
const StringOrCharP VarName,
unsigned Idx,
const char* Constraint,
199 template <
class T>
void set_variable(
StringOrCharP VarName, T Value,
const bool Requested =
true);
200 template <
class T>
void set(
StringOrCharP VarName, T& Value);
201 template <
class T>
void set(
StringOrCharP VarName, T& Value,
const char* Constraint);
202 template <
class T,
class U>
void set(
StringOrCharP VarName, T& Value,
const char* Constraint, U Default);
208 bool search(
const char* option);
209 bool search(
unsigned No,
const char* P, ...);
217 void init_multiple_occurrence();
220 STRING_VECTOR unidentified_arguments(
unsigned Number,
const char* Known, ...)
const;
221 STRING_VECTOR unidentified_arguments(
const STRING_VECTOR& Knowns)
const;
222 STRING_VECTOR unidentified_arguments()
const;
224 STRING_VECTOR unidentified_options(
unsigned Number,
const char* Known, ...)
const;
225 STRING_VECTOR unidentified_options(
const STRING_VECTOR& Knowns)
const;
226 STRING_VECTOR unidentified_options()
const;
228 std::string unidentified_flags(
const char* Known,
229 int ArgumentNumber )
const;
231 STRING_VECTOR unidentified_variables(
unsigned Number,
const char* Known, ...)
const;
232 STRING_VECTOR unidentified_variables(
const STRING_VECTOR& Knowns)
const;
233 STRING_VECTOR unidentified_variables()
const;
235 STRING_VECTOR unidentified_sections(
unsigned Number,
const char* Known, ...)
const;
236 STRING_VECTOR unidentified_sections(
const STRING_VECTOR& Knowns)
const;
237 STRING_VECTOR unidentified_sections()
const;
239 STRING_VECTOR unidentified_nominuses(
unsigned Number,
const char* Known, ...)
const;
240 STRING_VECTOR unidentified_nominuses(
const STRING_VECTOR& Knowns)
const;
241 STRING_VECTOR unidentified_nominuses()
const;
258 variable(
const std::string& Name,
const std::string& Value,
const std::string& FieldSeparator);
262 void take(
const std::string& Value,
const std::string& FieldSeparator);
319 void __record_argument_request(
const std::string& Arg);
320 void __record_variable_request(
const std::string& Arg);
324 void __build(
const std::string& FileName,
325 const std::string& CommentStart,
const std::string& CommentEnd,
326 const std::string& FieldSeparator);
328 void __split(std::string str, std::vector<std::string>& vect, std::string delimiters =
" \n\t");
330 void __set_variable(
const std::string& VarName,
const std::string& Value);
336 void __parse_argument_vector(
const STRING_VECTOR& ARGV);
340 const variable* __find_variable(
const std::string&,
const std::string& TypeName,
342 template <
class T> T __get(
const StringOrCharP VarName,
const char* Constraint,
343 bool ThrowExceptionF)
const;
344 template <
class T> T __get(
const StringOrCharP VarName,
const char* Constraint, T Default,
345 bool ThrowExceptionF)
const;
346 template <
class T> T __get_element(
const StringOrCharP VarName,
unsigned Idx,
const char* Constraint,
347 bool ThrowExceptionF)
const;
348 template <
class T> T __get_element(
const StringOrCharP VarName,
unsigned Idx,
const char* Constraint,
349 T Default,
bool ThrowExceptionF)
const;
352 const char* __match_starting_string(
const char* StartString);
354 bool __check_flags(
const std::string& Str,
const char* FlagList)
const;
356 template <
class T> T __convert_to_type(
const std::string& String, T Default,
360 const char* __get_const_char(
const std::string& String)
const;
363 bool __constraint_check(
const std::string& Value,
364 const char* ConstraintStr,
365 bool ThrowExceptionF)
const;
366 bool __constraint_check_OR(
const std::string& Value,
const char** iterator)
const;
367 bool __constraint_check_AND(
const std::string& Value,
const char** iterator)
const;
368 bool __constraint_check_PRIMARY(
const std::string& Value,
const char** iterator)
const;
369 bool __constrain_check_EQUAL_STRING(
const char* viterator,
const char** iterator)
const;
371 const std::string __get_remaining_string(
const std::string& String,
372 const std::string& Start)
const;
374 bool __search_string_vector(
const STRING_VECTOR& Vec,
375 const std::string& Str)
const;
385 void __skip_whitespace(std::istream& istr);
386 const std::string __get_next_token(std::istream& istr);
387 const std::string __get_string(std::istream& istr);
388 const std::string __get_until_closing_bracket(std::istream& istr);
390 STRING_VECTOR __read_in_stream(std::istream& istr);
391 STRING_VECTOR __read_in_file(
const std::string& FileName);
392 std::string __process_section_label(
const std::string& Section,
393 STRING_VECTOR& section_stack);
396 std::string __DBE_expand_string(
const std::string str);
397 std::string __DBE_expand(
const std::string str);
399 STRING_VECTOR __DBE_get_expr_list(
const std::string str,
const unsigned ExpectedNumber);
401 std::string __double2string(
const double& Value)
const;
402 std::string __int2string(
const int& Value)
const;
403 STRING_VECTOR __get_section_tree(
const std::string& FullPath);
406 #ifdef GETPOT_SETTING_NAMESPACE 411 #endif // __INCLUDE_GUARD_GETPOT_HPP__ bool __request_recording_f
std::vector< unsigned > idx_nominus
std::vector< std::vector< char > *> __internal_string_container
STRING_VECTOR _requested_arguments
std::vector< std::string > STRING_VECTOR
StringOrCharP(const char *Value)
STRING_VECTOR section_list
void set_prefix(StringOrCharP Prefix)
void disable_request_recording()
STRING_VECTOR false_string_list
unsigned nominus_size() const
void enable_request_recording()
STRING_VECTOR _requested_sections
StringOrCharP(const std::string &Value)
#define GETPOT_SETTING_THROW_EXCEPTION_ON_DEFAULT
STRING_VECTOR true_string_list
bool search_failed() const
std::string _field_separator
std::vector< variable > variables
std::string _comment_start
STRING_VECTOR _requested_variables