Reference documentation for deal.II version 9.4.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
patterns.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 1998 - 2022 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_patterns_h
17#define dealii_patterns_h
18
19
20#include <deal.II/base/config.h>
21
23#include <deal.II/base/point.h>
27
29
31#include <boost/archive/basic_archive.hpp>
32#include <boost/core/demangle.hpp>
33#include <boost/property_tree/ptree_fwd.hpp>
34#include <boost/property_tree/ptree_serialization.hpp>
35#include <boost/serialization/split_member.hpp>
37
38#include <algorithm>
39#include <array>
40#include <deque>
41#include <list>
42#include <map>
43#include <memory>
44#include <set>
45#include <sstream>
46#include <string>
47#include <type_traits>
48#include <unordered_map>
49#include <unordered_set>
50#include <utility>
51#include <vector>
52
54
55// forward declarations for interfaces and friendship
56#ifndef DOXYGEN
57class LogStream;
59template <int dim>
60class FunctionParser;
61#endif
62
71namespace Patterns
72{
80 {
81 public:
85 virtual ~PatternBase() = default;
86
90 virtual bool
91 match(const std::string &test_string) const = 0;
92
99 {
115 LaTeX
116 };
117
121 virtual std::string
122 description(const OutputStyle style = Machine) const = 0;
123
133 virtual std::unique_ptr<PatternBase>
134 clone() const = 0;
135
151 virtual std::size_t
152 memory_consumption() const;
153 };
154
158 std::unique_ptr<PatternBase>
159 pattern_factory(const std::string &description);
160
161 namespace internal
162 {
168 std::string
169 escape(const std::string &input, const PatternBase::OutputStyle style);
170
171 } // namespace internal
172
189 class Integer : public PatternBase
190 {
191 public:
197 static const int min_int_value;
198
204 static const int max_int_value;
205
219 const int upper_bound = max_int_value);
220
225 virtual bool
226 match(const std::string &test_string) const override;
227
233 virtual std::string
234 description(const OutputStyle style = Machine) const override;
235
241 virtual std::unique_ptr<PatternBase>
242 clone() const override;
243
249 static std::unique_ptr<Integer>
250 create(const std::string &description);
251
252 private:
259 const int lower_bound;
260
267 const int upper_bound;
268
272 static const char *description_init;
273 };
274
292 class Double : public PatternBase
293 {
294 public:
299 static const double min_double_value;
300
305 static const double max_double_value;
306
314 Double(const double lower_bound = min_double_value,
315 const double upper_bound = max_double_value);
316
321 virtual bool
322 match(const std::string &test_string) const override;
323
329 virtual std::string
330 description(const OutputStyle style = Machine) const override;
331
337 virtual std::unique_ptr<PatternBase>
338 clone() const override;
339
347 static std::unique_ptr<Double>
348 create(const std::string &description);
349
350 private:
357 const double lower_bound;
358
365 const double upper_bound;
366
370 static const char *description_init;
371 };
372
382 class Selection : public PatternBase
383 {
384 public:
389 Selection(const std::string &seq);
390
395 virtual bool
396 match(const std::string &test_string) const override;
397
403 virtual std::string
404 description(const OutputStyle style = Machine) const override;
405
411 virtual std::unique_ptr<PatternBase>
412 clone() const override;
413
418 std::size_t
419 memory_consumption() const override;
420
426 static std::unique_ptr<Selection>
427 create(const std::string &description);
428
429 private:
434 std::string sequence;
435
439 static const char *description_init;
440 };
441
442
450 class List : public PatternBase
451 {
452 public:
458 static const unsigned int max_int_value;
459
468 List(const PatternBase &base_pattern,
469 const unsigned int min_elements = 0,
470 const unsigned int max_elements = max_int_value,
471 const std::string &separator = ",");
472
473
477 const std::string &
478 get_separator() const;
479
483 const PatternBase &
484 get_base_pattern() const;
485
489 List(const List &other);
490
495 virtual bool
496 match(const std::string &test_string) const override;
497
502 virtual std::string
503 description(const OutputStyle style = Machine) const override;
504
510 virtual std::unique_ptr<PatternBase>
511 clone() const override;
512
518 static std::unique_ptr<List>
519 create(const std::string &description);
520
525 std::size_t
526 memory_consumption() const override;
527
537 int,
538 int,
539 << "The values " << arg1 << " and " << arg2
540 << " do not form a valid range.");
542 private:
546 std::unique_ptr<PatternBase> pattern;
547
551 const unsigned int min_elements;
552
556 const unsigned int max_elements;
557
561 const std::string separator;
562
566 static const char *description_init;
567 };
568
569
584 class Map : public PatternBase
585 {
586 public:
592 static const unsigned int max_int_value;
593
604 const unsigned int min_elements = 0,
605 const unsigned int max_elements = max_int_value,
606 const std::string &separator = ",",
607 const std::string &key_value_separator = ":");
608
612 Map(const Map &other);
613
618 virtual bool
619 match(const std::string &test_string) const override;
620
625 virtual std::string
626 description(const OutputStyle style = Machine) const override;
627
633 virtual std::unique_ptr<PatternBase>
634 clone() const override;
635
641 static std::unique_ptr<Map>
642 create(const std::string &description);
643
648 std::size_t
649 memory_consumption() const override;
650
654 const PatternBase &
655 get_key_pattern() const;
656
660 const PatternBase &
661 get_value_pattern() const;
662
666 const std::string &
667 get_separator() const;
668
672 const std::string &
674
684 int,
685 int,
686 << "The values " << arg1 << " and " << arg2
687 << " do not form a valid range.");
689 private:
694 std::unique_ptr<PatternBase> key_pattern;
695 std::unique_ptr<PatternBase> value_pattern;
696
700 const unsigned int min_elements;
701
705 const unsigned int max_elements;
706
710 const std::string separator;
711
712
716 const std::string key_value_separator;
717
721 static const char *description_init;
722 };
723
724
725
771 class Tuple : public PatternBase
772 {
773 public:
782 Tuple(const std::vector<std::unique_ptr<PatternBase>> &patterns,
783 const std::string & separator = ":");
784
790 Tuple(const std::vector<std::unique_ptr<PatternBase>> &patterns,
791 const char * separator);
792
793
801 template <class... PatternTypes>
802 Tuple(const std::string &separator, const PatternTypes &...patterns);
803
811 template <class... PatternTypes>
812 Tuple(const char *separator, const PatternTypes &...patterns);
813
819 template <typename... Patterns>
821
825 Tuple(const Tuple &other);
826
831 virtual bool
832 match(const std::string &test_string) const override;
833
838 virtual std::string
839 description(const OutputStyle style = Machine) const override;
840
846 virtual std::unique_ptr<PatternBase>
847 clone() const override;
848
854 static std::unique_ptr<Tuple>
855 create(const std::string &description);
856
861 std::size_t
862 memory_consumption() const override;
863
867 const PatternBase &
868 get_pattern(const unsigned int i) const;
869
873 const std::string &
874 get_separator() const;
875
876 private:
880 std::vector<std::unique_ptr<PatternBase>> patterns;
881
885 const std::string separator;
886
890 static const char *description_init;
891 };
892
893
905 {
906 public:
910 MultipleSelection(const std::string &seq);
911
916 virtual bool
917 match(const std::string &test_string) const override;
918
924 virtual std::string
925 description(const OutputStyle style = Machine) const override;
926
932 virtual std::unique_ptr<PatternBase>
933 clone() const override;
934
940 static std::unique_ptr<MultipleSelection>
941 create(const std::string &description);
942
947 std::size_t
948 memory_consumption() const override;
949
960 int,
961 << "A comma was found at position " << arg1
962 << " of your input string, but commas are not allowed here.");
964 private:
969 std::string sequence;
970
974 static const char *description_init;
975 };
976
981 class Bool : public Selection
982 {
983 public:
987 Bool();
988
993 virtual std::string
994 description(const OutputStyle style = Machine) const override;
995
1001 virtual std::unique_ptr<PatternBase>
1002 clone() const override;
1003
1009 static std::unique_ptr<Bool>
1010 create(const std::string &description);
1011
1012 private:
1016 static const char *description_init;
1017 };
1018
1022 class Anything : public PatternBase
1023 {
1024 public:
1029 Anything() = default;
1030
1035 virtual bool
1036 match(const std::string &test_string) const override;
1037
1042 virtual std::string
1043 description(const OutputStyle style = Machine) const override;
1044
1050 virtual std::unique_ptr<PatternBase>
1051 clone() const override;
1052
1058 static std::unique_ptr<Anything>
1059 create(const std::string &description);
1060
1061 private:
1065 static const char *description_init;
1066 };
1067
1068
1083 class FileName : public PatternBase
1084 {
1085 public:
1091 {
1099 output = 1
1101
1106 FileName(const FileType type = input);
1107
1112 virtual bool
1113 match(const std::string &test_string) const override;
1114
1119 virtual std::string
1120 description(const OutputStyle style = Machine) const override;
1121
1127 virtual std::unique_ptr<PatternBase>
1128 clone() const override;
1129
1134
1140 static std::unique_ptr<FileName>
1141 create(const std::string &description);
1142
1143 private:
1147 static const char *description_init;
1148 };
1149
1150
1164 {
1165 public:
1169 DirectoryName() = default;
1170
1175 virtual bool
1176 match(const std::string &test_string) const override;
1177
1182 virtual std::string
1183 description(const OutputStyle style = Machine) const override;
1184
1190 virtual std::unique_ptr<PatternBase>
1191 clone() const override;
1192
1198 static std::unique_ptr<DirectoryName>
1199 create(const std::string &description);
1200
1201 private:
1205 static const char *description_init;
1206 };
1207
1208
1287 namespace Tools
1288 {
1298 template <class T, class Enable = void>
1299 struct Convert
1300 {
1310 static std::unique_ptr<Patterns::PatternBase>
1311 to_pattern() = delete;
1312
1323 static std::string
1324 to_string(const T & s,
1326 delete;
1327
1337 static T
1338 to_value(const std::string & s,
1340 delete;
1341 };
1342
1361 template <typename T>
1362 std::string
1363 to_string(const T &t);
1364
1390 template <typename T>
1391 void
1392 to_value(const std::string &s, T &t);
1393
1403 std::string,
1404 std::string,
1405 << "The string \"" << arg1
1406 << "\" does not match the pattern \"" << arg2 << "\"");
1408 } // namespace Tools
1409} // namespace Patterns
1410
1411
1412// ---------------------- inline and template functions --------------------
1413namespace Patterns
1414{
1415 template <class... PatternTypes>
1416 Tuple::Tuple(const char *separator, const PatternTypes &...ps)
1417 : // forward to the version with std::string argument
1418 Tuple(std::string(separator), ps...)
1419 {}
1420
1421
1422
1423 template <class... PatternTypes>
1424 Tuple::Tuple(const std::string &separator, const PatternTypes &...ps)
1425 : separator(separator)
1426 {
1427 static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
1428 "Not all of the input arguments of this function "
1429 "are derived from PatternBase");
1430 static_assert(sizeof...(ps) > 0,
1431 "The number of PatternTypes must be greater than zero!");
1432 const auto pattern_pointers = {(static_cast<const PatternBase *>(&ps))...};
1433 for (const auto p : pattern_pointers)
1434 patterns.push_back(p->clone());
1435 }
1436
1437
1438
1439 template <class... PatternTypes>
1440 Tuple::Tuple(const PatternTypes &...ps)
1441 : // forward to the version with the separator argument
1442 Tuple(std::string(":"), ps...)
1443 {}
1444
1445
1446
1447 namespace Tools
1448 {
1449 namespace internal
1450 {
1475 template <class T, class Enable = void>
1477 {
1478 static constexpr int list_rank = 0;
1479 static constexpr int map_rank = 0;
1480 };
1481 } // namespace internal
1482
1483 // Arithmetic types
1484 template <class T>
1485 struct Convert<T,
1486 typename std::enable_if<std::is_arithmetic<T>::value>::type>
1487 {
1488 template <typename Dummy = T>
1489 static
1490 typename std::enable_if<std::is_same<Dummy, T>::value &&
1491 std::is_same<T, bool>::value,
1492 std::unique_ptr<Patterns::PatternBase>>::type
1494 {
1495 return std::make_unique<Patterns::Bool>();
1496 }
1497
1498 template <typename Dummy = T>
1499 static
1500 typename std::enable_if<std::is_same<Dummy, T>::value &&
1501 !std::is_same<T, bool>::value &&
1502 std::is_integral<T>::value,
1503 std::unique_ptr<Patterns::PatternBase>>::type
1505 {
1506 return std::make_unique<Patterns::Integer>(
1507 std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
1508 }
1509
1510 template <typename Dummy = T>
1511 static
1512 typename std::enable_if<std::is_same<Dummy, T>::value &&
1513 !std::is_same<T, bool>::value &&
1514 std::is_floating_point<T>::value,
1515 std::unique_ptr<Patterns::PatternBase>>::type
1517 {
1518 return std::make_unique<Patterns::Double>(
1519 std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
1520 }
1521
1522 static std::string
1523 to_string(const T & value,
1525 {
1526 std::stringstream str;
1527 if (std::is_same<T, unsigned char>::value ||
1528 std::is_same<T, signed char>::value || std::is_same<T, char>::value)
1529 str << static_cast<int>(value);
1530 else if (std::is_same<T, bool>::value)
1531 str << (static_cast<bool>(value) ? "true" : "false");
1532 else
1533 str << value;
1534 AssertThrow(p.match(str.str()), ExcNoMatch(str.str(), p.description()));
1535 return str.str();
1536 }
1537
1538 static T
1539 to_value(const std::string & s,
1541 {
1542 AssertThrow(p.match(s), ExcNoMatch(s, p.description()));
1543 T value;
1544 if (std::is_same<T, bool>::value)
1545 value = (s == "true");
1546 else
1547 {
1548 std::istringstream is(s);
1549 if (std::is_same<T, unsigned char>::value ||
1550 std::is_same<T, signed char>::value ||
1551 std::is_same<T, char>::value)
1552 {
1553 int i;
1554 is >> i;
1555 value = i;
1556 }
1557 else
1558 is >> value;
1559
1560 // If someone passes "123 abc" to the function, the method yields an
1561 // integer 123 alright, but the space terminates the read from the
1562 // string although there is more to come. This case, however, is
1563 // checked for in the call p->match(s) at the beginning of this
1564 // function, and would throw earlier. Here it is safe to assume that
1565 // if we didn't fail the conversion with the operator >>, then we
1566 // are good to go.
1568 !is.fail(),
1569 ExcMessage("Failed to convert from \"" + s + "\" to the type \"" +
1570 boost::core::demangle(typeid(T).name()) + "\""));
1571 }
1572 return value;
1573 }
1574 };
1575
1576 namespace internal
1577 {
1578 constexpr std::array<const char *, 4> default_list_separator{
1579 {",", ";", "|", "%"}};
1580 constexpr std::array<const char *, 4> default_map_separator{
1581 {":", "=", "@", "#"}};
1582
1583 // specialize a type for all of the STL containers and maps
1584 template <typename T>
1585 struct is_list_compatible : std::false_type
1586 {};
1587 template <typename... Args>
1588 struct is_list_compatible<std::vector<Args...>> : std::true_type
1589 {};
1590 template <typename... Args>
1591 struct is_list_compatible<std::deque<Args...>> : std::true_type
1592 {};
1593 template <typename... Args>
1594 struct is_list_compatible<std::list<Args...>> : std::true_type
1595 {};
1596 template <typename... Args>
1597 struct is_list_compatible<std::set<Args...>> : std::true_type
1598 {};
1599 template <typename... Args>
1600 struct is_list_compatible<std::multiset<Args...>> : std::true_type
1601 {};
1602 template <typename... Args>
1603 struct is_list_compatible<std::unordered_set<Args...>> : std::true_type
1604 {};
1605 template <typename... Args>
1606 struct is_list_compatible<std::unordered_multiset<Args...>>
1607 : std::true_type
1608 {};
1609
1610 template <typename T>
1611 struct is_map_compatible : std::false_type
1612 {};
1613 template <class Key, class T, class Compare, class Allocator>
1614 struct is_map_compatible<std::map<Key, T, Compare, Allocator>>
1615 : std::true_type
1616 {};
1617 template <class Key, class T, class Compare, class Allocator>
1618 struct is_map_compatible<std::multimap<Key, T, Compare, Allocator>>
1619 : std::true_type
1620 {};
1621 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
1623 std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type
1624 {};
1625 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
1627 std::unordered_multimap<Key, T, Hash, KeyEqual, Allocator>>
1628 : std::true_type
1629 {};
1630 } // namespace internal
1631
1632 // type trait to use the implementation type traits as well as decay the
1633 // type
1634 template <typename T>
1636 {
1637 static constexpr bool const value =
1639 };
1640
1641 template <typename T>
1643 {
1644 static constexpr bool const value =
1646 };
1647
1648 namespace internal
1649 {
1650 // Helper function for list_rank
1651 template <class T>
1652 constexpr int
1654 {
1656 }
1657
1658 template <class T1, class T2, class... Types>
1659 constexpr int
1661 {
1662 return std::max(RankInfo<T1>::list_rank, max_list_rank<T2, Types...>());
1663 }
1664
1665 // Helper function for map_rank
1666 template <class T>
1667 constexpr int
1669 {
1670 return RankInfo<T>::map_rank;
1671 }
1672
1673 template <class T1, class T2, class... Types>
1674 constexpr int
1676 {
1677 return std::max(RankInfo<T1>::map_rank, max_map_rank<T2, Types...>());
1678 }
1679
1680 // Rank of vector types
1681 template <class T>
1682 struct RankInfo<
1683 T,
1684 typename std::enable_if<is_list_compatible<T>::value>::type>
1685 {
1686 static constexpr int list_rank =
1688 static constexpr int map_rank =
1690 };
1691
1692 // Rank of map types
1693 template <class T>
1694 struct RankInfo<
1695 T,
1696 typename std::enable_if<is_map_compatible<T>::value>::type>
1697 {
1698 static constexpr int list_rank =
1699 max_list_rank<typename T::key_type, typename T::mapped_type>() + 1;
1700 static constexpr int map_rank =
1701 max_map_rank<typename T::key_type, typename T::mapped_type>() + 1;
1702 };
1703
1704 // Rank of Tensor types
1705 template <int rank, int dim, class Number>
1706 struct RankInfo<Tensor<rank, dim, Number>>
1707 {
1708 static constexpr int list_rank = rank + RankInfo<Number>::list_rank;
1709 static constexpr int map_rank = RankInfo<Number>::map_rank;
1710 };
1711
1712 template <int dim, class Number>
1713 struct RankInfo<Point<dim, Number>> : RankInfo<Tensor<1, dim, Number>>
1714 {};
1715
1716 // Rank of complex types
1717 template <class Number>
1718 struct RankInfo<std::complex<Number>>
1719 {
1720 static constexpr int list_rank = RankInfo<Number>::list_rank + 1;
1721 static constexpr int map_rank = RankInfo<Number>::map_rank;
1722 };
1723
1724 // Rank of FunctionParser
1725 template <int dim>
1726 struct RankInfo<std::unique_ptr<FunctionParser<dim>>>
1727 {
1728 static constexpr int list_rank = 1;
1729 static constexpr int map_rank = 0;
1730 };
1731
1732 // Rank of ComponentMask
1733 template <>
1735 {
1736 static constexpr int list_rank = 1;
1737 static constexpr int map_rank = 0;
1738 };
1739
1740 // Rank of std::pair
1741 template <class Key, class Value>
1742 struct RankInfo<std::pair<Key, Value>>
1743 {
1744 static constexpr int list_rank =
1746 static constexpr int map_rank =
1748 };
1749
1750 // Rank of std::tuple types
1751 template <class... Types>
1752 struct RankInfo<std::tuple<Types...>>
1753 {
1754 static constexpr int list_rank = max_list_rank<Types...>();
1755 static constexpr int map_rank = max_map_rank<Types...>() + 1;
1756 };
1757
1758 // Rank of std::array types
1759 template <class T, std::size_t N>
1760 struct RankInfo<std::array<T, N>>
1761 {
1762 static constexpr int list_rank = RankInfo<T>::list_rank + 1;
1763 static constexpr int map_rank = RankInfo<T>::map_rank;
1764 };
1765 } // namespace internal
1766
1767 // stl containers
1768 template <class T>
1769 struct Convert<T,
1770 typename std::enable_if<is_list_compatible<T>::value>::type>
1771 {
1772 static std::unique_ptr<Patterns::PatternBase>
1774 {
1775 static_assert(internal::RankInfo<T>::list_rank > 0,
1776 "Cannot use this class for non List-compatible types.");
1777 return std::make_unique<Patterns::List>(
1779 0,
1782 1]);
1783 }
1784
1785 static std::string
1787 const T & t,
1789 {
1790 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1791 AssertThrow(p,
1792 ExcMessage("I need a List pattern to convert a "
1793 "string to a List type."));
1794 auto base_p = p->get_base_pattern().clone();
1795 std::vector<std::string> vec(t.size());
1796
1798 t.cbegin(), t.cend(), vec.begin(), [&base_p](const auto &entry) {
1799 return Convert<typename T::value_type>::to_string(entry, *base_p);
1800 });
1801
1802 std::string s;
1803 if (vec.size() > 0)
1804 s = vec[0];
1805 for (unsigned int i = 1; i < vec.size(); ++i)
1806 s += p->get_separator() + " " + vec[i];
1807
1808 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
1809 return s;
1810 }
1811
1812 static T
1813 to_value(const std::string & s,
1815 {
1816 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1817
1818 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1819 AssertThrow(p,
1820 ExcMessage("I need a List pattern to convert a string "
1821 "to a List type."));
1822
1823 auto base_p = p->get_base_pattern().clone();
1824 T t;
1825
1826 auto v = Utilities::split_string_list(s, p->get_separator());
1827 for (const auto &str : v)
1828 t.insert(t.end(),
1830
1831 return t;
1832 }
1833 };
1834
1835 // stl maps
1836 template <class T>
1837 struct Convert<T,
1838 typename std::enable_if<is_map_compatible<T>::value>::type>
1839 {
1840 static std::unique_ptr<Patterns::PatternBase>
1842 {
1843 static_assert(internal::RankInfo<T>::list_rank > 0,
1844 "Cannot use this class for non List-compatible types.");
1845 static_assert(internal::RankInfo<T>::map_rank > 0,
1846 "Cannot use this class for non Map-compatible types.");
1847 return std::make_unique<Patterns::Map>(
1850 0,
1853 1],
1855 }
1856
1857 static std::string
1859 const T & t,
1861 {
1862 auto p = dynamic_cast<const Patterns::Map *>(&pattern);
1863 AssertThrow(p,
1864 ExcMessage("I need a Map pattern to convert a string to "
1865 "a Map compatible type."));
1866 auto key_p = p->get_key_pattern().clone();
1867 auto val_p = p->get_value_pattern().clone();
1868 std::vector<std::string> vec(t.size());
1869
1870 unsigned int i = 0;
1871 for (const auto &ti : t)
1872 vec[i++] =
1874 p->get_key_value_separator() +
1876
1877 std::string s;
1878 if (vec.size() > 0)
1879 s = vec[0];
1880 for (unsigned int i = 1; i < vec.size(); ++i)
1881 s += p->get_separator() + " " + vec[i];
1882
1883 AssertThrow(p->match(s), ExcNoMatch(s, p->description()));
1884 return s;
1885 }
1886
1887 static T
1888 to_value(const std::string & s,
1890 {
1891 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1892
1893 auto p = dynamic_cast<const Patterns::Map *>(&pattern);
1894 AssertThrow(p,
1895 ExcMessage("I need a Map pattern to convert a "
1896 "string to a Map compatible type."));
1897
1898 auto key_p = p->get_key_pattern().clone();
1899 auto val_p = p->get_value_pattern().clone();
1900 T t;
1901
1902 auto v = Utilities::split_string_list(s, p->get_separator());
1903 for (const auto &str : v)
1904 {
1905 auto key_val =
1906 Utilities::split_string_list(str, p->get_key_value_separator());
1907 AssertDimension(key_val.size(), 2);
1908 t.insert(std::make_pair(
1909 Convert<typename T::key_type>::to_value(key_val[0], *key_p),
1910 Convert<typename T::mapped_type>::to_value(key_val[1], *val_p)));
1911 }
1912
1913 return t;
1914 }
1915 };
1916
1917 // std::array
1918 template <class ValueType, std::size_t N>
1919 struct Convert<std::array<ValueType, N>>
1920 {
1921 using T = std::array<ValueType, N>;
1922
1923 static std::unique_ptr<Patterns::PatternBase>
1925 {
1926 static_assert(internal::RankInfo<T>::list_rank > 0,
1927 "Cannot use this class for non List-compatible types.");
1928 return std::make_unique<Patterns::List>(
1930 N,
1931 N,
1933 1]);
1934 }
1935
1936 static std::string
1938 const T & t,
1940 {
1941 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1942 AssertThrow(p,
1943 ExcMessage("I need a List pattern to convert a "
1944 "string to a std::array."));
1945 auto base_p = p->get_base_pattern().clone();
1946 std::vector<std::string> vec(t.size());
1947
1949 t.cbegin(), t.cend(), vec.begin(), [&base_p](const auto &entry) {
1950 return Convert<typename T::value_type>::to_string(entry, *base_p);
1951 });
1952
1953 std::string s;
1954 if (vec.size() > 0)
1955 s = vec[0];
1956 for (unsigned int i = 1; i < vec.size(); ++i)
1957 s += p->get_separator() + " " + vec[i];
1958
1959 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
1960 return s;
1961 }
1962
1963 static T
1964 to_value(const std::string & s,
1966 {
1967 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1968
1969 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1970 AssertThrow(p,
1971 ExcMessage("I need a List pattern to convert a string "
1972 "to a std::array."));
1973
1974 auto base_p = p->get_base_pattern().clone();
1975 T t;
1976
1977 auto v = Utilities::split_string_list(s, p->get_separator());
1978 AssertDimension(v.size(), N);
1979 for (unsigned int i = 0; i < N; ++i)
1980 t[i] = Convert<typename T::value_type>::to_value(v[i], *base_p);
1981 return t;
1982 }
1983 };
1984
1985 // Tensors
1986 template <int rank, int dim, class Number>
1987 struct Convert<Tensor<rank, dim, Number>>
1988 {
1990 static std::unique_ptr<Patterns::PatternBase>
1992 {
1993 static_assert(internal::RankInfo<T>::list_rank > 0,
1994 "Cannot use this class for non List-compatible types.");
1995 return std::make_unique<Patterns::List>(
1997 dim,
1998 dim,
2000 1]);
2001 }
2002
2003 static std::string
2005 const T & t,
2007 {
2008 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2009 AssertThrow(p,
2010 ExcMessage("I need a List pattern to convert a string "
2011 "to a List compatible type."));
2012 auto base_p = p->get_base_pattern().clone();
2013 std::vector<std::string> vec(dim);
2014
2015 for (unsigned int i = 0; i < dim; ++i)
2016 vec[i] = Convert<typename T::value_type>::to_string(t[i], *base_p);
2017
2018 std::string s;
2019 if (vec.size() > 0)
2020 s = vec[0];
2021 for (unsigned int i = 1; i < vec.size(); ++i)
2022 s += p->get_separator() + " " + vec[i];
2023
2024 AssertThrow(p->match(s), ExcNoMatch(s, p->description()));
2025 return s;
2026 }
2027
2028 static T
2029 to_value(const std::string & s,
2031 {
2032 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2033
2034 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2035 AssertThrow(p,
2036 ExcMessage("I need a List pattern to convert a string "
2037 "to a List compatible type."));
2038
2039 auto base_p = p->get_base_pattern().clone();
2040 T t;
2041
2042 auto v = Utilities::split_string_list(s, p->get_separator());
2043 unsigned int i = 0;
2044 for (const auto &str : v)
2045 t[i++] = Convert<typename T::value_type>::to_value(str, *base_p);
2046
2047 return t;
2048 }
2049 };
2050
2051 // Points
2052 template <int dim, class Number>
2053 struct Convert<Point<dim, Number>>
2054 {
2056
2057 static std::unique_ptr<Patterns::PatternBase>
2059 {
2061 }
2062
2063 static std::string
2065 const T & t,
2067 {
2069 Tensor<1, dim, Number>(t), pattern);
2070 }
2071
2072 static T
2073 to_value(const std::string & s,
2075 {
2076 return T(Convert<Tensor<1, dim, Number>>::to_value(s, pattern));
2077 }
2078 };
2079
2080 // Functions::FunctionParser
2081 template <int dim>
2082 struct Convert<std::unique_ptr<FunctionParser<dim>>>
2083 {
2084 using T = std::unique_ptr<FunctionParser<dim>>;
2085
2086 static std::unique_ptr<Patterns::PatternBase>
2088 {
2089 static_assert(internal::RankInfo<T>::list_rank > 0,
2090 "Cannot use this class for non List-compatible types.");
2091
2092 return std::make_unique<Patterns::List>(
2094 1,
2097 1]);
2098 }
2099
2100 static std::string
2102 const T & t,
2104 {
2105 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2106 AssertThrow(p,
2107 ExcMessage("I need a List pattern to convert a string "
2108 "to a List compatible type."));
2109
2110 const auto &expressions = t->get_expressions();
2111 if (expressions.size() == 0)
2112 return std::string();
2113
2114 std::string s = expressions[0];
2115 for (unsigned int i = 1; i < expressions.size(); ++i)
2116 s = s + p->get_separator() + expressions[i];
2117
2118 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
2119 return s;
2120 }
2121
2122 static T
2123 to_value(const std::string & s,
2125 {
2126 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2127
2128 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2129 AssertThrow(p,
2130 ExcMessage("I need a List pattern to convert a string "
2131 "to a List compatible type."));
2132
2133 const auto expressions =
2134 Utilities::split_string_list(s, p->get_separator());
2135
2136 T t = std::make_unique<FunctionParser<dim>>(expressions.size());
2137 const std::string var =
2139 const typename FunctionParser<dim>::ConstMap constants;
2140 t->initialize(var, expressions, constants, true);
2141 return t;
2142 }
2143 };
2144
2145 // ComponentMask
2146 template <>
2148 {
2150
2151 static std::unique_ptr<Patterns::PatternBase>
2153 {
2155 }
2156
2157 static std::string
2159 const T & t,
2161 {
2162 std::vector<bool> mask(t.size());
2163 for (unsigned int i = 0; i < t.size(); ++i)
2164 mask[i] = t[i];
2165
2166 return Convert<std::vector<bool>>::to_string(mask, pattern);
2167 }
2168
2169 static T
2170 to_value(const std::string & s,
2172 {
2173 const auto mask = Convert<std::vector<bool>>::to_value(s, pattern);
2174 return ComponentMask(mask);
2175 }
2176 };
2177
2178 // Complex numbers
2179 template <class Number>
2180 struct Convert<std::complex<Number>>
2181 {
2182 using T = std::complex<Number>;
2183
2184 static std::unique_ptr<Patterns::PatternBase>
2186 {
2187 static_assert(internal::RankInfo<T>::list_rank > 0,
2188 "Cannot use this class for non List-compatible types.");
2189 return std::make_unique<Patterns::List>(
2191 2,
2192 2,
2194 1]);
2195 }
2196
2197 static std::string
2199 const T & t,
2201 {
2202 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2203 AssertThrow(p,
2204 ExcMessage("I need a List pattern to convert a string "
2205 "to a List compatible type."));
2206
2207 auto base_p = p->get_base_pattern().clone();
2208 std::string s =
2210 p->get_separator() + " " +
2212
2213 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
2214 return s;
2215 }
2216
2220 static T
2221 to_value(const std::string & s,
2223 {
2224 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2225
2226 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2227 AssertThrow(p,
2228 ExcMessage("I need a List pattern to convert a string "
2229 "to a List compatible type."));
2230
2231 auto base_p = p->get_base_pattern().clone();
2232
2233 auto v = Utilities::split_string_list(s, p->get_separator());
2234 AssertDimension(v.size(), 2);
2237 return t;
2238 }
2239 };
2240
2241 // Strings
2242 template <>
2243 struct Convert<std::string>
2244 {
2245 using T = std::string;
2246
2247 static std::unique_ptr<Patterns::PatternBase>
2249 {
2250 return std::make_unique<Patterns::Anything>();
2251 }
2252
2253 static std::string
2255 const T & t,
2257 {
2258 AssertThrow(pattern.match(t), ExcNoMatch(t, pattern.description()));
2259 return t;
2260 }
2261
2262 static T
2263 to_value(const std::string & s,
2265 {
2266 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2267 return s;
2268 }
2269 };
2270
2271 // Pairs
2272 template <class Key, class Value>
2273 struct Convert<std::pair<Key, Value>>
2274 {
2275 using T = std::pair<Key, Value>;
2276
2277 static std::unique_ptr<Patterns::PatternBase>
2279 {
2280 static_assert(internal::RankInfo<T>::map_rank > 0,
2281 "Cannot use this class for non Map-compatible types.");
2282 return std::make_unique<Patterns::Tuple>(
2286 }
2287
2288 static std::string
2290 const T & t,
2292 {
2293 std::tuple<Key, Value> m(t);
2294 std::string s = Convert<decltype(m)>::to_string(m, pattern);
2295 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2296 return s;
2297 }
2298
2299 static T
2300 to_value(const std::string & s,
2302 {
2303 std::tuple<Key, Value> m;
2304 m = Convert<decltype(m)>::to_value(s, pattern);
2305 return std::make_pair(std::get<0>(m), std::get<1>(m));
2306 }
2307 };
2308
2309 // Tuples
2310 template <class... Args>
2311 struct Convert<std::tuple<Args...>>
2312 {
2313 using T = std::tuple<Args...>;
2314
2315 static std::unique_ptr<Patterns::PatternBase>
2317 {
2318 static_assert(internal::RankInfo<T>::map_rank > 0,
2319 "Cannot use this class for non tuple-compatible types.");
2320 return std::make_unique<Patterns::Tuple>(
2323 }
2324
2325 static std::string
2327 const T & t,
2329 {
2330 auto p = dynamic_cast<const Patterns::Tuple *>(&pattern);
2331 AssertThrow(p,
2332 ExcMessage("I need a Tuple pattern to convert a tuple "
2333 "to a string."));
2334
2335 const auto string_array = Convert<T>::to_string_internal_2(t, *p);
2336 std::string str;
2337 for (unsigned int i = 0; i < string_array.size(); ++i)
2338 str +=
2339 (i != 0u ? " " + p->get_separator() + " " : "") + string_array[i];
2340 AssertThrow(p->match(str), ExcNoMatch(str, p->description()));
2341 return str;
2342 }
2343
2344 static T
2345 to_value(const std::string & s,
2347 {
2348 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2349
2350 auto p = dynamic_cast<const Patterns::Tuple *>(&pattern);
2351 AssertThrow(p,
2352 ExcMessage("I need a Tuple pattern to convert a string "
2353 "to a tuple type."));
2354
2355 auto v = Utilities::split_string_list(s, p->get_separator());
2356
2357 return Convert<T>::to_value_internal_2(v, *p);
2358 }
2359
2360 private:
2361 template <std::size_t... U>
2362 static std::array<std::string, std::tuple_size<T>::value>
2364 const Patterns::Tuple &pattern,
2365 std::index_sequence<U...>)
2366 {
2367 std::array<std::string, std::tuple_size<T>::value> a = {
2369 std::get<U>(t), pattern.get_pattern(U))...}};
2370 return a;
2371 }
2372
2373 static std::array<std::string, std::tuple_size<T>::value>
2374 to_string_internal_2(const T &t, const Patterns::Tuple &pattern)
2375 {
2377 t, pattern, std::make_index_sequence<std::tuple_size<T>::value>{});
2378 }
2379
2380 template <std::size_t... U>
2381 static T
2382 to_value_internal_1(const std::vector<std::string> &s,
2383 const Patterns::Tuple & pattern,
2384 std::index_sequence<U...>)
2385 {
2386 return std::make_tuple(
2387 Convert<typename std::tuple_element<U, T>::type>::to_value(
2388 s[U], pattern.get_pattern(U))...);
2389 }
2390
2391 static T
2392 to_value_internal_2(const std::vector<std::string> &s,
2393 const Patterns::Tuple & pattern)
2394 {
2396 s, pattern, std::make_index_sequence<std::tuple_size<T>::value>{});
2397 }
2398 };
2399
2400 // Utility function with default Pattern
2401 template <typename T>
2402 std::string
2403 to_string(const T &t)
2404 {
2405 return Convert<T>::to_string(t);
2406 }
2407
2408 // Utility function with default Pattern
2409 template <typename T>
2410 void
2411 to_value(const std::string &s, T &t)
2412 {
2413 t = Convert<T>::to_value(s);
2414 }
2415 } // namespace Tools
2416} // namespace Patterns
2417
2418
2420
2421#endif
unsigned int size() const
std::map< std::string, double > ConstMap
static std::string default_variable_names()
static std::unique_ptr< Double > create(const std::string &description)
Definition: patterns.cc:491
static const char * description_init
Definition: patterns.h:370
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:483
Double(const double lower_bound=min_double_value, const double upper_bound=max_double_value)
Definition: patterns.cc:352
const double lower_bound
Definition: patterns.h:357
const double upper_bound
Definition: patterns.h:365
static const double max_double_value
Definition: patterns.h:305
static const double min_double_value
Definition: patterns.h:299
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:383
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:360
static std::unique_ptr< Integer > create(const std::string &description)
Definition: patterns.cc:312
static const char * description_init
Definition: patterns.h:272
const int upper_bound
Definition: patterns.h:267
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:304
Integer(const int lower_bound=min_int_value, const int upper_bound=max_int_value)
Definition: patterns.cc:213
const int lower_bound
Definition: patterns.h:259
static const int min_int_value
Definition: patterns.h:197
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:243
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:221
static const int max_int_value
Definition: patterns.h:204
std::size_t memory_consumption() const override
Definition: patterns.cc:768
static std::unique_ptr< List > create(const std::string &description)
Definition: patterns.cc:777
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:716
const PatternBase & get_base_pattern() const
Definition: patterns.cc:688
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:696
const std::string & get_separator() const
Definition: patterns.cc:680
List(const PatternBase &base_pattern, const unsigned int min_elements=0, const unsigned int max_elements=max_int_value, const std::string &separator=",")
Definition: patterns.cc:654
static const unsigned int max_int_value
Definition: patterns.h:458
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:760
virtual std::size_t memory_consumption() const
Definition: patterns.cc:192
virtual std::unique_ptr< PatternBase > clone() const =0
virtual std::string description(const OutputStyle style=Machine) const =0
virtual bool match(const std::string &test_string) const =0
virtual ~PatternBase()=default
static const char * description_init
Definition: patterns.h:439
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:578
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:613
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:546
static std::unique_ptr< Selection > create(const std::string &description)
Definition: patterns.cc:629
std::size_t memory_consumption() const override
Definition: patterns.cc:620
Selection(const std::string &seq)
Definition: patterns.cc:534
std::string sequence
Definition: patterns.h:434
Definition: point.h:111
Definition: tensor.h:503
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:456
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:495
__global__ void set(Number *val, const Number s, const size_type N)
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:1399
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:1090
FileType file_type
Definition: patterns.h:1133
static T to_value_internal_2(const std::vector< std::string > &s, const Patterns::Tuple &pattern)
Definition: patterns.h:2392
static std::unique_ptr< Patterns::PatternBase > to_pattern()=delete
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2345
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2248
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:1638
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2152
std::size_t memory_consumption() const override
Definition: patterns.cc:1166
static std::unique_ptr< Anything > create(const std::string &description)
Definition: patterns.cc:1496
static std::array< std::string, std::tuple_size< T >::value > to_string_internal_2(const T &t, const Patterns::Tuple &pattern)
Definition: patterns.h:2374
static std::unique_ptr< Tuple > create(const std::string &description)
Definition: patterns.cc:1175
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2278
const unsigned int max_elements
Definition: patterns.h:556
static ::ExceptionBase & ExcInvalidRange(int arg1, int arg2)
static std::unique_ptr< Map > create(const std::string &description)
Definition: patterns.cc:969
static ::ExceptionBase & ExcInvalidRange(int arg1, int arg2)
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:1518
static const char * description_init
Definition: patterns.h:566
const unsigned int min_elements
Definition: patterns.h:551
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:1924
std::unique_ptr< PatternBase > value_pattern
Definition: patterns.h:695
std::vector< std::unique_ptr< PatternBase > > patterns
Definition: patterns.h:880
const unsigned int min_elements
Definition: patterns.h:700
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:1786
static const char * description_init
Definition: patterns.h:1016
const PatternBase & get_key_pattern() const
Definition: patterns.cc:1024
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:865
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2087
std::unique_ptr< PatternBase > pattern
Definition: patterns.h:546
MultipleSelection(const std::string &seq)
Definition: patterns.cc:1241
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:1452
const std::string separator
Definition: patterns.h:561
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=":")
Definition: patterns.cc:825
const unsigned int max_elements
Definition: patterns.h:705
FileName(const FileType type=input)
Definition: patterns.cc:1511
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2185
static ::ExceptionBase & ExcNoMatch(std::string arg1, std::string arg2)
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2263
constexpr std::array< const char *, 4 > default_map_separator
Definition: patterns.h:1580
void to_value(const std::string &s, T &t)
Definition: patterns.h:2411
constexpr int max_map_rank()
Definition: patterns.h:1668
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2316
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:2058
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2170
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:1159
static const char * description_init
Definition: patterns.h:1147
static const char * description_init
Definition: patterns.h:1205
static std::enable_if< std::is_same< Dummy, T >::value &&std::is_same< T, bool >::value, std::unique_ptr< Patterns::PatternBase > >::type to_pattern()
Definition: patterns.h:1493
Tuple(const Patterns &...patterns)
static std::unique_ptr< MultipleSelection > create(const std::string &description)
Definition: patterns.cc:1370
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:1256
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:1964
std::string to_string(const T &t)
Definition: patterns.h:2403
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:1427
const std::string separator
Definition: patterns.h:885
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:1562
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:1354
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:1610
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:945
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2123
static const char * description_init
Definition: patterns.h:890
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:1858
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2158
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:532
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1667
static T to_value(const std::string &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())
Definition: patterns.h:1539
static constexpr int list_rank
Definition: patterns.h:1478
constexpr int max_list_rank()
Definition: patterns.h:1653
static const char * description_init
Definition: patterns.h:974
static std::unique_ptr< FileName > create(const std::string &description)
Definition: patterns.cc:1570
static const char * description_init
Definition: patterns.h:1065
const PatternBase & get_value_pattern() const
Definition: patterns.cc:1032
std::size_t memory_consumption() const override
Definition: patterns.cc:1361
static constexpr bool const value
Definition: patterns.h:1637
static std::unique_ptr< Bool > create(const std::string &description)
Definition: patterns.cc:1435
const std::string & get_separator() const
Definition: patterns.cc:1040
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:1460
Tuple(const std::vector< std::unique_ptr< PatternBase > > &patterns, const std::string &separator=":")
Definition: patterns.cc:1057
const std::string & get_separator() const
Definition: patterns.cc:1231
static T to_value(const std::string &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())=delete
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2221
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:895
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:1937
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:1319
static std::unique_ptr< DirectoryName > create(const std::string &description)
Definition: patterns.cc:1646
static const unsigned int max_int_value
Definition: patterns.h:592
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2101
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:1813
std::unique_ptr< PatternBase > key_pattern
Definition: patterns.h:694
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:1526
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: patterns.h:1991
virtual bool match(const std::string &test_string) const override
Definition: patterns.cc:1602
const std::string separator
Definition: patterns.h:710
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2300
const PatternBase & get_pattern(const unsigned int i) const
Definition: patterns.cc:1223
std::size_t memory_consumption() const override
Definition: patterns.cc:957
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2029
static ::ExceptionBase & ExcCommasNotAllowed(int arg1)
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2289
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2064
static std::array< std::string, std::tuple_size< T >::value > to_string_internal_1(const T &t, const Patterns::Tuple &pattern, std::index_sequence< U... >)
Definition: patterns.h:2363
static const char * description_init
Definition: patterns.h:721
virtual std::unique_ptr< PatternBase > clone() const override
Definition: patterns.cc:1488
static constexpr int map_rank
Definition: patterns.h:1479
static std::string to_string(const T &value, const Patterns::PatternBase &p= *Convert< T >::to_pattern())
Definition: patterns.h:1523
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2004
static constexpr bool const value
Definition: patterns.h:1644
static T to_value_internal_1(const std::vector< std::string > &s, const Patterns::Tuple &pattern, std::index_sequence< U... >)
Definition: patterns.h:2382
virtual std::string description(const OutputStyle style=Machine) const override
Definition: patterns.cc:1109
constexpr std::array< const char *, 4 > default_list_separator
Definition: patterns.h:1578
static std::string to_string(const T &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())=delete
const std::string & get_key_value_separator() const
Definition: patterns.cc:1047
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2326
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:1888
static ::ExceptionBase & ExcMessage(std::string arg1)
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2198
const std::string key_value_separator
Definition: patterns.h:716
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2254
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition: patterns.h:2073
#define AssertThrow(cond, exc)
Definition: exceptions.h:1583
static const char U
static const char T
static const char N
std::string escape(const std::string &input, const PatternBase::OutputStyle style)
Definition: patterns.cc:55
std::unique_ptr< PatternBase > pattern_factory(const std::string &description)
Definition: patterns.cc:140
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:704
void transform(const InputIterator &begin_in, const InputIterator &end_in, OutputIterator out, const Predicate &predicate, const unsigned int grainsize)
Definition: parallel.h:135
STL namespace.
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
static std::enable_if< std::is_same< Dummy, T >::value &&!std::is_same< T, bool >::value &&std::is_integral< T >::value, std::unique_ptr< Patterns::PatternBase > >::type to_pattern()
Definition: patterns.h:1504