24#define BOOST_BIND_GLOBAL_PLACEHOLDERS
25#include <boost/io/ios_state.hpp>
26#include <boost/property_tree/json_parser.hpp>
27#include <boost/property_tree/ptree.hpp>
28#include <boost/property_tree/xml_parser.hpp>
29#undef BOOST_BIND_GLOBAL_PLACEHOLDERS
65 u.reserve(input.size());
66 for (
const auto c : input)
83 u.append(
"\\textbackslash{}");
119 has_only_whitespace(std::istream &in)
130 if ((c !=
' ') && (c !=
'\t'))
139 std::unique_ptr<PatternBase>
142 std::unique_ptr<PatternBase> p;
194 if (
dynamic_cast<const Integer *
>(
this) !=
nullptr)
196 else if (
dynamic_cast<const Double *
>(
this) !=
nullptr)
198 else if (
dynamic_cast<const Bool *
>(
this) !=
nullptr)
200 else if (
dynamic_cast<const Anything *
>(
this) !=
nullptr)
203 return sizeof(*this) + 32;
214 : lower_bound(lower_bound)
215 , upper_bound(upper_bound)
223 std::istringstream str(test_string);
229 if (!has_only_whitespace(str))
303 std::unique_ptr<PatternBase>
311 std::unique_ptr<Integer>
329 return std::make_unique<Integer>();
331 is.ignore(strlen(
"..."));
334 return std::make_unique<Integer>();
339 return std::make_unique<Integer>();
342 return std::unique_ptr<Integer>();
353 : lower_bound(lower_bound)
354 , upper_bound(upper_bound)
362 std::istringstream str(test_string);
369 if (!has_only_whitespace(str))
426 description <<
"A floating point number v such that ";
444 return "A floating point number";
452 description <<
"A floating point number @f$v@f$ such that @f$";
471 return "A floating point number";
482 std::unique_ptr<PatternBase>
490 std::unique_ptr<Double>
495 description_init_str.size(),
496 description_init_str) != 0)
497 return std::unique_ptr<Double>();
499 return std::unique_ptr<Double>();
501 std::string temp =
description.substr(description_init_str.size());
503 return std::make_unique<Double>(1.0,
506 if (temp.find(
"...") != std::string::npos)
507 temp.replace(temp.find(
"..."), 3,
" ");
511 std::istringstream is(temp);
512 if (0 == temp.compare(0, std::strlen(
" -MAX_DOUBLE"),
" -MAX_DOUBLE"))
513 is.ignore(std::strlen(
" -MAX_DOUBLE"));
518 return std::unique_ptr<Double>();
537 while (
sequence.find(
" |") != std::string::npos)
539 while (
sequence.find(
"| ") != std::string::npos)
551 while ((tmp.size() != 0) && (std::isspace(tmp.front()) != 0))
555 while (tmp.find(
'|') != std::string::npos)
557 if (test_string == std::string(tmp, 0, tmp.find(
'|')))
560 tmp.erase(0, tmp.find(
'|') + 1);
564 while ((tmp.size() != 0) && (std::isspace(tmp.back()) != 0))
565 tmp.erase(tmp.end() - 1);
568 if (test_string == tmp)
612 std::unique_ptr<PatternBase>
628 std::unique_ptr<Selection>
640 return std::make_unique<Selection>(
sequence);
643 return std::unique_ptr<Selection>();
649 std::numeric_limits<unsigned int>::max();
655 const unsigned int min_elements,
656 const unsigned int max_elements,
657 const std::string &separator)
659 , min_elements(min_elements)
660 , max_elements(max_elements)
661 , separator(separator)
666 ExcMessage(
"The separator must have a non-zero length."));
672 : pattern(other.pattern->clone())
673 , min_elements(other.min_elements)
674 , max_elements(other.max_elements)
675 , separator(other.separator)
698 const std::vector<std::string> split_list =
706 for (
const std::string &
string : split_list)
707 if (
pattern->match(
string) ==
false)
725 <<
pattern->description(style) <<
">"
745 <<
pattern->description(style) <<
"]";
759 std::unique_ptr<PatternBase>
762 return std::unique_ptr<PatternBase>(
776 std::unique_ptr<List>
789 std::getline(is, str,
'>');
793 is.ignore(strlen(
" of length "));
795 return std::make_unique<List>(*base_pattern);
797 is.ignore(strlen(
"..."));
799 return std::make_unique<List>(*base_pattern,
min_elements);
801 is.ignore(strlen(
" (inclusive) separated by <"));
808 return std::make_unique<List>(*base_pattern,
814 return std::unique_ptr<List>();
820 std::numeric_limits<unsigned int>::max();
827 const unsigned int min_elements,
828 const unsigned int max_elements,
829 const std::string &separator,
830 const std::string &key_value_separator)
831 : key_pattern(p_key.clone())
832 , value_pattern(p_value.clone())
833 , min_elements(min_elements)
834 , max_elements(max_elements)
835 , separator(separator)
836 , key_value_separator(key_value_separator)
841 ExcMessage(
"The separator must have a non-zero length."));
843 ExcMessage(
"The key_value_separator must have a non-zero length."));
846 "The separator can not be the same of the key_value_separator "
847 "since that is used as the separator between the two elements "
848 "of <key:value> pairs"));
854 : key_pattern(other.key_pattern->clone())
855 , value_pattern(other.value_pattern->clone())
856 , min_elements(other.min_elements)
857 , max_elements(other.max_elements)
858 , separator(other.separator)
859 , key_value_separator(other.key_value_separator)
867 std::vector<std::string> split_list =
873 for (
const auto &key_value_pair : split_list)
875 std::vector<std::string> pair =
879 if (pair.size() != 2)
929 <<
" and each value is ["
944 std::unique_ptr<PatternBase>
959 return (
sizeof(*
this) +
981 std::getline(is, key,
'>');
988 std::getline(is, value,
'>');
993 is.ignore(strlen(
" of length "));
997 is.ignore(strlen(
"..."));
1003 is.ignore(strlen(
" (inclusive) separated by <"));
1018 return std::unique_ptr<Map>();
1058 const std::string & separator)
1059 : separator(separator)
1062 ExcMessage(
"The Patterns list must have a non-zero length."));
1064 ExcMessage(
"The separator must have a non-zero length."));
1066 for (
unsigned int i = 0; i < ps.size(); ++i)
1073 const char * separator)
1074 :
Tuple(ps,
std::string(separator))
1080 : separator(other.separator)
1083 for (
unsigned int i = 0; i < other.
patterns.size(); ++i)
1092 std::vector<std::string> split_list =
1094 if (split_list.size() !=
patterns.size())
1097 for (
unsigned int i = 0; i <
patterns.size(); ++i)
1118 <<
"> elements <" <<
patterns[0]->description(style)
1120 for (
unsigned int i = 1; i <
patterns.size(); ++i)
1139 <<
patterns[0]->description(style) <<
"]";
1140 for (
unsigned int i = 1; i <
patterns.size(); ++i)
1143 <<
patterns[i]->description(style) <<
"]";
1158 std::unique_ptr<PatternBase>
1174 std::unique_ptr<Tuple>
1181 std::vector<std::unique_ptr<PatternBase>>
patterns;
1187 std::getline(is, len,
'>');
1190 ExcMessage(
"Provide at least 1 element in the tuple."));
1193 is.ignore(strlen(
" elements <"));
1195 std::string element;
1196 std::getline(is, element,
'>');
1199 for (
unsigned int i = 1; i < n_elements; ++i)
1201 is.ignore(strlen(
", <"));
1202 std::getline(is, element,
'>');
1206 is.ignore(strlen(
" separated by <"));
1217 return std::unique_ptr<Tuple>();
1243 Assert(seq.find(
',') == std::string::npos,
1247 while (
sequence.find(
" |") != std::string::npos)
1249 while (
sequence.find(
"| ") != std::string::npos)
1258 std::string tmp = test_string_list;
1259 std::vector<std::string> split_names;
1262 while (tmp.size() != 0)
1267 if (name.find(
',') != std::string::npos)
1269 name.erase(name.find(
','), std::string::npos);
1270 tmp.erase(0, tmp.find(
',') + 1);
1275 while ((name.size() != 0) && (std::isspace(name.front()) != 0))
1277 while ((name.size() != 0) && (std::isspace(name.back()) != 0))
1278 name.erase(name.size() - 1, 1);
1280 split_names.push_back(name);
1285 for (
const auto &test_string : split_names)
1287 bool string_found =
false;
1290 while (tmp.find(
'|') != std::string::npos)
1292 if (test_string == std::string(tmp, 0, tmp.find(
'|')))
1298 string_found =
true;
1302 tmp.erase(0, tmp.find(
'|') + 1);
1306 if (test_string == tmp)
1307 string_found =
true;
1336 description <<
"A comma-separated list of any of "
1353 std::unique_ptr<PatternBase>
1369 std::unique_ptr<MultipleSelection>
1381 return std::make_unique<MultipleSelection>(
sequence);
1384 return std::unique_ptr<MultipleSelection>();
1414 return "A boolean value (true or false)";
1426 std::unique_ptr<PatternBase>
1429 return std::unique_ptr<PatternBase>(
new Bool());
1434 std::unique_ptr<Bool>
1440 return std::make_unique<Bool>();
1442 return std::unique_ptr<Bool>();
1475 return "Any string";
1487 std::unique_ptr<PatternBase>
1490 return std::unique_ptr<PatternBase>(
new Anything());
1495 std::unique_ptr<Anything>
1501 return std::make_unique<Anything>();
1503 return std::unique_ptr<Anything>();
1547 return "an input filename";
1549 return "an output filename";
1561 std::unique_ptr<PatternBase>
1569 std::unique_ptr<FileName>
1589 return std::make_unique<FileName>(type);
1592 return std::unique_ptr<FileName>();
1625 return "A directory name";
1637 std::unique_ptr<PatternBase>
1645 std::unique_ptr<DirectoryName>
1651 return std::make_unique<DirectoryName>();
1653 return std::unique_ptr<DirectoryName>();
static std::unique_ptr< Double > create(const std::string &description)
static const char * description_init
virtual std::unique_ptr< PatternBase > clone() const override
Double(const double lower_bound=min_double_value, const double upper_bound=max_double_value)
static const double max_double_value
static const double min_double_value
virtual std::string description(const OutputStyle style=Machine) const override
virtual bool match(const std::string &test_string) const override
static std::unique_ptr< Integer > create(const std::string &description)
static const char * description_init
virtual std::unique_ptr< PatternBase > clone() const override
Integer(const int lower_bound=min_int_value, const int upper_bound=max_int_value)
static const int min_int_value
virtual std::string description(const OutputStyle style=Machine) const override
virtual bool match(const std::string &test_string) const override
static const int max_int_value
std::size_t memory_consumption() const override
static std::unique_ptr< List > create(const std::string &description)
virtual std::string description(const OutputStyle style=Machine) const override
const PatternBase & get_base_pattern() const
virtual bool match(const std::string &test_string) const override
const std::string & get_separator() const
List(const PatternBase &base_pattern, const unsigned int min_elements=0, const unsigned int max_elements=max_int_value, const std::string &separator=",")
static const unsigned int max_int_value
virtual std::unique_ptr< PatternBase > clone() const override
virtual std::size_t memory_consumption() const
static const char * description_init
virtual std::string description(const OutputStyle style=Machine) const override
virtual std::unique_ptr< PatternBase > clone() const override
virtual bool match(const std::string &test_string) const override
static std::unique_ptr< Selection > create(const std::string &description)
std::size_t memory_consumption() const override
Selection(const std::string &seq)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
virtual std::string description(const OutputStyle style=Machine) const override
virtual bool match(const std::string &test_string) const override
virtual std::unique_ptr< PatternBase > clone() const override
std::size_t memory_consumption() const override
static std::unique_ptr< Anything > create(const std::string &description)
static std::unique_ptr< Tuple > create(const std::string &description)
const unsigned int max_elements
static ::ExceptionBase & ExcInvalidRange(int arg1, int arg2)
static std::unique_ptr< Map > create(const std::string &description)
static ::ExceptionBase & ExcInvalidRange(int arg1, int arg2)
virtual bool match(const std::string &test_string) const override
static const char * description_init
const unsigned int min_elements
std::unique_ptr< PatternBase > value_pattern
std::vector< std::unique_ptr< PatternBase > > patterns
const unsigned int min_elements
static const char * description_init
const PatternBase & get_key_pattern() const
virtual bool match(const std::string &test_string) const override
std::unique_ptr< PatternBase > pattern
MultipleSelection(const std::string &seq)
virtual bool match(const std::string &test_string) const override
const std::string separator
Map(const PatternBase &key_pattern, const PatternBase &value_pattern, const unsigned int min_elements=0, const unsigned int max_elements=max_int_value, const std::string &separator=",", const std::string &key_value_separator=":")
const unsigned int max_elements
FileName(const FileType type=input)
static ::ExceptionBase & ExcNotImplemented()
virtual std::unique_ptr< PatternBase > clone() const override
static const char * description_init
static const char * description_init
static std::unique_ptr< MultipleSelection > create(const std::string &description)
virtual bool match(const std::string &test_string) const override
#define Assert(cond, exc)
virtual std::unique_ptr< PatternBase > clone() const override
const std::string separator
virtual std::unique_ptr< PatternBase > clone() const override
virtual std::unique_ptr< PatternBase > clone() const override
virtual std::string description(const OutputStyle style=Machine) const override
virtual std::unique_ptr< PatternBase > clone() const override
static const char * description_init
static const char * description_init
static std::unique_ptr< FileName > create(const std::string &description)
static const char * description_init
const PatternBase & get_value_pattern() const
std::size_t memory_consumption() const override
static std::unique_ptr< Bool > create(const std::string &description)
const std::string & get_separator() const
virtual std::string description(const OutputStyle style=Machine) const override
Tuple(const std::vector< std::unique_ptr< PatternBase > > &patterns, const std::string &separator=":")
const std::string & get_separator() const
virtual std::string description(const OutputStyle style=Machine) const override
virtual std::string description(const OutputStyle style=Machine) const override
static std::unique_ptr< DirectoryName > create(const std::string &description)
static const unsigned int max_int_value
std::unique_ptr< PatternBase > key_pattern
virtual std::string description(const OutputStyle style=Machine) const override
virtual bool match(const std::string &test_string) const override
const std::string separator
const PatternBase & get_pattern(const unsigned int i) const
std::size_t memory_consumption() const override
static ::ExceptionBase & ExcCommasNotAllowed(int arg1)
static const char * description_init
virtual std::unique_ptr< PatternBase > clone() const override
virtual std::string description(const OutputStyle style=Machine) const override
const std::string & get_key_value_separator() const
static ::ExceptionBase & ExcMessage(std::string arg1)
const std::string key_value_separator
#define AssertThrow(cond, exc)
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::string escape(const std::string &input, const PatternBase::OutputStyle style)
std::unique_ptr< PatternBase > pattern_factory(const std::string &description)
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
int string_to_int(const std::string &s)