Reference documentation for deal.II version 9.5.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\}}\)
Loading...
Searching...
No Matches
patterns.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 1998 - 2023 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
30#include <boost/archive/basic_archive.hpp>
31#include <boost/core/demangle.hpp>
32#include <boost/property_tree/ptree_fwd.hpp>
33#include <boost/property_tree/ptree_serialization.hpp>
34#include <boost/serialization/split_member.hpp>
35
36#include <algorithm>
37#include <array>
38#include <deque>
39#include <limits>
40#include <list>
41#include <map>
42#include <memory>
43#include <set>
44#include <sstream>
45#include <string>
46#include <type_traits>
47#include <unordered_map>
48#include <unordered_set>
49#include <utility>
50#include <vector>
51
53
54// forward declarations for interfaces and friendship
55#ifndef DOXYGEN
56class LogStream;
58template <int dim>
59class FunctionParser;
60#endif
61
70namespace Patterns
71{
79 {
80 public:
84 virtual ~PatternBase() = default;
85
89 virtual bool
90 match(const std::string &test_string) const = 0;
91
98 {
114 LaTeX
115 };
116
120 virtual std::string
121 description(const OutputStyle style = Machine) const = 0;
122
132 virtual std::unique_ptr<PatternBase>
133 clone() const = 0;
134
150 virtual std::size_t
151 memory_consumption() const;
152 };
153
157 std::unique_ptr<PatternBase>
158 pattern_factory(const std::string &description);
159
160 namespace internal
161 {
167 std::string
168 escape(const std::string &input, const PatternBase::OutputStyle style);
169
170 } // namespace internal
171
188 class Integer : public PatternBase
189 {
190 public:
196 static const int min_int_value;
197
203 static const int max_int_value;
204
218 const int upper_bound = max_int_value);
219
224 virtual bool
225 match(const std::string &test_string) const override;
226
232 virtual std::string
233 description(const OutputStyle style = Machine) const override;
234
240 virtual std::unique_ptr<PatternBase>
241 clone() const override;
242
248 static std::unique_ptr<Integer>
249 create(const std::string &description);
250
251 private:
258 const int lower_bound;
259
266 const int upper_bound;
267
271 static const char *description_init;
272 };
273
291 class Double : public PatternBase
292 {
293 public:
298 static const double min_double_value;
299
304 static const double max_double_value;
305
313 Double(const double lower_bound = min_double_value,
314 const double upper_bound = max_double_value);
315
320 virtual bool
321 match(const std::string &test_string) const override;
322
328 virtual std::string
329 description(const OutputStyle style = Machine) const override;
330
336 virtual std::unique_ptr<PatternBase>
337 clone() const override;
338
346 static std::unique_ptr<Double>
347 create(const std::string &description);
348
349 private:
356 const double lower_bound;
357
364 const double upper_bound;
365
369 static const char *description_init;
370 };
371
381 class Selection : public PatternBase
382 {
383 public:
388 Selection(const std::string &seq);
389
394 virtual bool
395 match(const std::string &test_string) const override;
396
402 virtual std::string
403 description(const OutputStyle style = Machine) const override;
404
410 virtual std::unique_ptr<PatternBase>
411 clone() const override;
412
417 std::size_t
418 memory_consumption() const override;
419
425 static std::unique_ptr<Selection>
426 create(const std::string &description);
427
428 private:
433 std::string sequence;
434
438 static const char *description_init;
439 };
440
441
449 class List : public PatternBase
450 {
451 public:
457 static const unsigned int max_int_value;
458
467 List(const PatternBase &base_pattern,
468 const unsigned int min_elements = 0,
469 const unsigned int max_elements = max_int_value,
470 const std::string &separator = ",");
471
472
476 const std::string &
477 get_separator() const;
478
482 const PatternBase &
483 get_base_pattern() const;
484
488 List(const List &other);
489
494 virtual bool
495 match(const std::string &test_string) const override;
496
501 virtual std::string
502 description(const OutputStyle style = Machine) const override;
503
509 virtual std::unique_ptr<PatternBase>
510 clone() const override;
511
517 static std::unique_ptr<List>
518 create(const std::string &description);
519
524 std::size_t
525 memory_consumption() const override;
526
536 int,
537 int,
538 << "The values " << arg1 << " and " << arg2
539 << " do not form a valid range.");
541 private:
545 std::unique_ptr<PatternBase> pattern;
546
550 const unsigned int min_elements;
551
555 const unsigned int max_elements;
556
560 const std::string separator;
561
565 static const char *description_init;
566 };
567
568
583 class Map : public PatternBase
584 {
585 public:
591 static const unsigned int max_int_value;
592
603 const unsigned int min_elements = 0,
604 const unsigned int max_elements = max_int_value,
605 const std::string &separator = ",",
606 const std::string &key_value_separator = ":");
607
611 Map(const Map &other);
612
617 virtual bool
618 match(const std::string &test_string) const override;
619
624 virtual std::string
625 description(const OutputStyle style = Machine) const override;
626
632 virtual std::unique_ptr<PatternBase>
633 clone() const override;
634
640 static std::unique_ptr<Map>
641 create(const std::string &description);
642
647 std::size_t
648 memory_consumption() const override;
649
653 const PatternBase &
654 get_key_pattern() const;
655
659 const PatternBase &
660 get_value_pattern() const;
661
665 const std::string &
666 get_separator() const;
667
671 const std::string &
673
683 int,
684 int,
685 << "The values " << arg1 << " and " << arg2
686 << " do not form a valid range.");
688 private:
693 std::unique_ptr<PatternBase> key_pattern;
694 std::unique_ptr<PatternBase> value_pattern;
695
699 const unsigned int min_elements;
700
704 const unsigned int max_elements;
705
709 const std::string separator;
710
711
715 const std::string key_value_separator;
716
720 static const char *description_init;
721 };
722
723
724
770 class Tuple : public PatternBase
771 {
772 public:
781 Tuple(const std::vector<std::unique_ptr<PatternBase>> &patterns,
782 const std::string & separator = ":");
783
789 Tuple(const std::vector<std::unique_ptr<PatternBase>> &patterns,
790 const char * separator);
791
792
800 template <class... PatternTypes>
801 Tuple(const std::string &separator, const PatternTypes &...patterns);
802
810 template <class... PatternTypes>
811 Tuple(const char *separator, const PatternTypes &...patterns);
812
818 template <typename... Patterns>
820
824 Tuple(const Tuple &other);
825
830 virtual bool
831 match(const std::string &test_string) const override;
832
837 virtual std::string
838 description(const OutputStyle style = Machine) const override;
839
845 virtual std::unique_ptr<PatternBase>
846 clone() const override;
847
853 static std::unique_ptr<Tuple>
854 create(const std::string &description);
855
860 std::size_t
861 memory_consumption() const override;
862
866 const PatternBase &
867 get_pattern(const unsigned int i) const;
868
872 const std::string &
873 get_separator() const;
874
875 private:
879 std::vector<std::unique_ptr<PatternBase>> patterns;
880
884 const std::string separator;
885
889 static const char *description_init;
890 };
891
892
904 {
905 public:
909 MultipleSelection(const std::string &seq);
910
915 virtual bool
916 match(const std::string &test_string) const override;
917
923 virtual std::string
924 description(const OutputStyle style = Machine) const override;
925
931 virtual std::unique_ptr<PatternBase>
932 clone() const override;
933
939 static std::unique_ptr<MultipleSelection>
940 create(const std::string &description);
941
946 std::size_t
947 memory_consumption() const override;
948
959 int,
960 << "A comma was found at position " << arg1
961 << " of your input string, but commas are not allowed here.");
963 private:
968 std::string sequence;
969
973 static const char *description_init;
974 };
975
980 class Bool : public Selection
981 {
982 public:
986 Bool();
987
992 virtual std::string
993 description(const OutputStyle style = Machine) const override;
994
1000 virtual std::unique_ptr<PatternBase>
1001 clone() const override;
1002
1008 static std::unique_ptr<Bool>
1009 create(const std::string &description);
1010
1011 private:
1015 static const char *description_init;
1016 };
1017
1021 class Anything : public PatternBase
1022 {
1023 public:
1028 Anything() = default;
1029
1034 virtual bool
1035 match(const std::string &test_string) const override;
1036
1041 virtual std::string
1042 description(const OutputStyle style = Machine) const override;
1043
1049 virtual std::unique_ptr<PatternBase>
1050 clone() const override;
1051
1057 static std::unique_ptr<Anything>
1058 create(const std::string &description);
1059
1060 private:
1064 static const char *description_init;
1065 };
1066
1067
1082 class FileName : public PatternBase
1083 {
1084 public:
1090 {
1098 output = 1
1100
1105 FileName(const FileType type = input);
1106
1111 virtual bool
1112 match(const std::string &test_string) const override;
1113
1118 virtual std::string
1119 description(const OutputStyle style = Machine) const override;
1120
1126 virtual std::unique_ptr<PatternBase>
1127 clone() const override;
1128
1133
1139 static std::unique_ptr<FileName>
1140 create(const std::string &description);
1141
1142 private:
1146 static const char *description_init;
1147 };
1148
1149
1163 {
1164 public:
1168 DirectoryName() = default;
1169
1174 virtual bool
1175 match(const std::string &test_string) const override;
1176
1181 virtual std::string
1182 description(const OutputStyle style = Machine) const override;
1183
1189 virtual std::unique_ptr<PatternBase>
1190 clone() const override;
1191
1197 static std::unique_ptr<DirectoryName>
1198 create(const std::string &description);
1199
1200 private:
1204 static const char *description_init;
1205 };
1206
1207
1286 namespace Tools
1287 {
1297 template <class T, class Enable = void>
1298 struct Convert
1299 {
1309 static std::unique_ptr<Patterns::PatternBase>
1310 to_pattern() = delete;
1311
1322 static std::string
1323 to_string(const T & s,
1325 delete;
1326
1336 static T
1337 to_value(const std::string & s,
1339 delete;
1340 };
1341
1360 template <typename T>
1361 std::string
1362 to_string(const T &t);
1363
1389 template <typename T>
1390 void
1391 to_value(const std::string &s, T &t);
1392
1402 std::string,
1403 std::string,
1404 << "The string \"" << arg1
1405 << "\" does not match the pattern \"" << arg2 << "\"");
1407 } // namespace Tools
1408} // namespace Patterns
1409
1410
1411// ---------------------- inline and template functions --------------------
1412namespace Patterns
1413{
1414 template <class... PatternTypes>
1415 Tuple::Tuple(const char *separator, const PatternTypes &...ps)
1416 : // forward to the version with std::string argument
1417 Tuple(std::string(separator), ps...)
1418 {}
1419
1420
1421
1422 template <class... PatternTypes>
1423 Tuple::Tuple(const std::string &separator, const PatternTypes &...ps)
1424 : separator(separator)
1425 {
1426 static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
1427 "Not all of the input arguments of this function "
1428 "are derived from PatternBase");
1429 static_assert(sizeof...(ps) > 0,
1430 "The number of PatternTypes must be greater than zero!");
1431 const auto pattern_pointers = {(static_cast<const PatternBase *>(&ps))...};
1432 for (const auto p : pattern_pointers)
1433 patterns.push_back(p->clone());
1434 }
1435
1436
1437
1438 template <class... PatternTypes>
1439 Tuple::Tuple(const PatternTypes &...ps)
1440 : // forward to the version with the separator argument
1441 Tuple(std::string(":"), ps...)
1442 {}
1443
1444
1445
1446 namespace Tools
1447 {
1448 namespace internal
1449 {
1474 template <class T, class Enable = void>
1476 {
1477 static constexpr int list_rank = 0;
1478 static constexpr int map_rank = 0;
1479 };
1480 } // namespace internal
1481
1482 // Arithmetic types
1483 template <class T>
1484 struct Convert<T, std::enable_if_t<std::is_arithmetic<T>::value>>
1485 {
1486 template <typename Dummy = T>
1487 static std::enable_if_t<std::is_same<Dummy, T>::value &&
1488 std::is_same<T, bool>::value,
1489 std::unique_ptr<Patterns::PatternBase>>
1491 {
1492 return std::make_unique<Patterns::Bool>();
1493 }
1494
1495 template <typename Dummy = T>
1496 static std::enable_if_t<std::is_same<Dummy, T>::value &&
1497 !std::is_same<T, bool>::value &&
1498 std::is_integral<T>::value,
1499 std::unique_ptr<Patterns::PatternBase>>
1501 {
1502 return std::make_unique<Patterns::Integer>(
1503 std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
1504 }
1505
1506 template <typename Dummy = T>
1507 static std::enable_if_t<std::is_same<Dummy, T>::value &&
1508 !std::is_same<T, bool>::value &&
1509 std::is_floating_point<T>::value,
1510 std::unique_ptr<Patterns::PatternBase>>
1512 {
1513 return std::make_unique<Patterns::Double>(
1514 std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
1515 }
1516
1517 static std::string
1518 to_string(const T & value,
1520 {
1521 std::stringstream str;
1522 if (std::is_same<T, unsigned char>::value ||
1523 std::is_same<T, signed char>::value || std::is_same<T, char>::value)
1524 str << static_cast<int>(value);
1525 else if (std::is_same<T, bool>::value)
1526 str << (static_cast<bool>(value) ? "true" : "false");
1527 else
1528 str << value;
1529 AssertThrow(p.match(str.str()), ExcNoMatch(str.str(), p.description()));
1530 return str.str();
1531 }
1532
1533 static T
1534 to_value(const std::string & s,
1536 {
1537 AssertThrow(p.match(s), ExcNoMatch(s, p.description()));
1538 T value;
1539 if (std::is_same<T, bool>::value)
1540 value = (s == "true");
1541 else
1542 {
1543 std::istringstream is(s);
1544 if (std::is_same<T, unsigned char>::value ||
1545 std::is_same<T, signed char>::value ||
1546 std::is_same<T, char>::value)
1547 {
1548 int i;
1549 is >> i;
1550 value = i;
1551 }
1552 else
1553 is >> value;
1554
1555 // If someone passes "123 abc" to the function, the method yields an
1556 // integer 123 alright, but the space terminates the read from the
1557 // string although there is more to come. This case, however, is
1558 // checked for in the call p->match(s) at the beginning of this
1559 // function, and would throw earlier. Here it is safe to assume that
1560 // if we didn't fail the conversion with the operator >>, then we
1561 // are good to go.
1563 !is.fail(),
1564 ExcMessage("Failed to convert from \"" + s + "\" to the type \"" +
1565 boost::core::demangle(typeid(T).name()) + "\""));
1566 }
1567 return value;
1568 }
1569 };
1570
1571 namespace internal
1572 {
1573 constexpr std::array<const char *, 4> default_list_separator{
1574 {",", ";", "|", "%"}};
1575 constexpr std::array<const char *, 4> default_map_separator{
1576 {":", "=", "@", "#"}};
1577
1578 // specialize a type for all of the STL containers and maps
1579 template <typename T>
1580 struct is_list_compatible : std::false_type
1581 {};
1582 template <typename... Args>
1583 struct is_list_compatible<std::vector<Args...>> : std::true_type
1584 {};
1585 template <typename... Args>
1586 struct is_list_compatible<std::deque<Args...>> : std::true_type
1587 {};
1588 template <typename... Args>
1589 struct is_list_compatible<std::list<Args...>> : std::true_type
1590 {};
1591 template <typename... Args>
1592 struct is_list_compatible<std::set<Args...>> : std::true_type
1593 {};
1594 template <typename... Args>
1595 struct is_list_compatible<std::multiset<Args...>> : std::true_type
1596 {};
1597 template <typename... Args>
1598 struct is_list_compatible<std::unordered_set<Args...>> : std::true_type
1599 {};
1600 template <typename... Args>
1601 struct is_list_compatible<std::unordered_multiset<Args...>>
1602 : std::true_type
1603 {};
1604
1605 template <typename T>
1606 struct is_map_compatible : std::false_type
1607 {};
1608 template <class Key, class T, class Compare, class Allocator>
1609 struct is_map_compatible<std::map<Key, T, Compare, Allocator>>
1610 : std::true_type
1611 {};
1612 template <class Key, class T, class Compare, class Allocator>
1613 struct is_map_compatible<std::multimap<Key, T, Compare, Allocator>>
1614 : std::true_type
1615 {};
1616 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
1618 std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type
1619 {};
1620 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
1622 std::unordered_multimap<Key, T, Hash, KeyEqual, Allocator>>
1623 : std::true_type
1624 {};
1625 } // namespace internal
1626
1627 // type trait to use the implementation type traits as well as decay the
1628 // type
1629 template <typename T>
1631 {
1632 static constexpr bool const value =
1634 };
1635
1636 template <typename T>
1638 {
1639 static constexpr bool const value =
1641 };
1642
1643 namespace internal
1644 {
1645 // Helper function for list_rank
1646 template <class T>
1647 constexpr int
1649 {
1651 }
1652
1653 template <class T1, class T2, class... Types>
1654 constexpr int
1656 {
1657 return std::max(RankInfo<T1>::list_rank, max_list_rank<T2, Types...>());
1658 }
1659
1660 // Helper function for map_rank
1661 template <class T>
1662 constexpr int
1664 {
1665 return RankInfo<T>::map_rank;
1666 }
1667
1668 template <class T1, class T2, class... Types>
1669 constexpr int
1671 {
1672 return std::max(RankInfo<T1>::map_rank, max_map_rank<T2, Types...>());
1673 }
1674
1675 // Rank of vector types
1676 template <class T>
1677 struct RankInfo<T, std::enable_if_t<is_list_compatible<T>::value>>
1678 {
1679 static constexpr int list_rank =
1681 static constexpr int map_rank =
1683 };
1684
1685 // Rank of map types
1686 template <class T>
1687 struct RankInfo<T, std::enable_if_t<is_map_compatible<T>::value>>
1688 {
1689 static constexpr int list_rank =
1690 max_list_rank<typename T::key_type, typename T::mapped_type>() + 1;
1691 static constexpr int map_rank =
1692 max_map_rank<typename T::key_type, typename T::mapped_type>() + 1;
1693 };
1694
1695 // Rank of Tensor types
1696 template <int rank, int dim, class Number>
1697 struct RankInfo<Tensor<rank, dim, Number>>
1698 {
1699 static constexpr int list_rank = rank + RankInfo<Number>::list_rank;
1700 static constexpr int map_rank = RankInfo<Number>::map_rank;
1701 };
1702
1703 template <int dim, class Number>
1704 struct RankInfo<Point<dim, Number>> : RankInfo<Tensor<1, dim, Number>>
1705 {};
1706
1707 // Rank of complex types
1708 template <class Number>
1709 struct RankInfo<std::complex<Number>>
1710 {
1711 static constexpr int list_rank = RankInfo<Number>::list_rank + 1;
1712 static constexpr int map_rank = RankInfo<Number>::map_rank;
1713 };
1714
1715 // Rank of FunctionParser
1716 template <int dim>
1717 struct RankInfo<std::unique_ptr<FunctionParser<dim>>>
1718 {
1719 static constexpr int list_rank = 1;
1720 static constexpr int map_rank = 0;
1721 };
1722
1723 // Rank of ComponentMask
1724 template <>
1726 {
1727 static constexpr int list_rank = 1;
1728 static constexpr int map_rank = 0;
1729 };
1730
1731 // Rank of std::pair
1732 template <class Key, class Value>
1733 struct RankInfo<std::pair<Key, Value>>
1734 {
1735 static constexpr int list_rank =
1737 static constexpr int map_rank =
1739 };
1740
1741 // Rank of std::tuple types
1742 template <class... Types>
1743 struct RankInfo<std::tuple<Types...>>
1744 {
1745 static constexpr int list_rank = max_list_rank<Types...>();
1746 static constexpr int map_rank = max_map_rank<Types...>() + 1;
1747 };
1748
1749 // Rank of std::array types
1750 template <class T, std::size_t N>
1751 struct RankInfo<std::array<T, N>>
1752 {
1753 static constexpr int list_rank = RankInfo<T>::list_rank + 1;
1754 static constexpr int map_rank = RankInfo<T>::map_rank;
1755 };
1756 } // namespace internal
1757
1758 // stl containers
1759 template <class T>
1760 struct Convert<T, std::enable_if_t<is_list_compatible<T>::value>>
1761 {
1762 static std::unique_ptr<Patterns::PatternBase>
1764 {
1765 static_assert(internal::RankInfo<T>::list_rank > 0,
1766 "Cannot use this class for non List-compatible types.");
1767 return std::make_unique<Patterns::List>(
1769 0,
1770 std::numeric_limits<unsigned int>::max(),
1772 1]);
1773 }
1774
1775 static std::string
1777 const T & t,
1779 {
1780 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1781 AssertThrow(p,
1782 ExcMessage("I need a List pattern to convert a "
1783 "string to a List type."));
1784 auto base_p = p->get_base_pattern().clone();
1785 std::vector<std::string> vec(t.size());
1786
1787 std::transform(
1788 t.cbegin(), t.cend(), vec.begin(), [&base_p](const auto &entry) {
1789 return Convert<typename T::value_type>::to_string(entry, *base_p);
1790 });
1791
1792 std::string s;
1793 if (vec.size() > 0)
1794 s = vec[0];
1795 for (unsigned int i = 1; i < vec.size(); ++i)
1796 s += p->get_separator() + " " + vec[i];
1797
1798 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
1799 return s;
1800 }
1801
1802 static T
1803 to_value(const std::string & s,
1805 {
1806 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1807
1808 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1809 AssertThrow(p,
1810 ExcMessage("I need a List pattern to convert a string "
1811 "to a List type."));
1812
1813 auto base_p = p->get_base_pattern().clone();
1814 T t;
1815
1816 auto v = Utilities::split_string_list(s, p->get_separator());
1817 for (const auto &str : v)
1818 t.insert(t.end(),
1820
1821 return t;
1822 }
1823 };
1824
1825 // stl maps
1826 template <class T>
1827 struct Convert<T, std::enable_if_t<is_map_compatible<T>::value>>
1828 {
1829 static std::unique_ptr<Patterns::PatternBase>
1831 {
1832 static_assert(internal::RankInfo<T>::list_rank > 0,
1833 "Cannot use this class for non List-compatible types.");
1834 static_assert(internal::RankInfo<T>::map_rank > 0,
1835 "Cannot use this class for non Map-compatible types.");
1836 return std::make_unique<Patterns::Map>(
1839 0,
1840 std::numeric_limits<unsigned int>::max(),
1842 1],
1844 }
1845
1846 static std::string
1848 const T & t,
1850 {
1851 auto p = dynamic_cast<const Patterns::Map *>(&pattern);
1852 AssertThrow(p,
1853 ExcMessage("I need a Map pattern to convert a string to "
1854 "a Map compatible type."));
1855 auto key_p = p->get_key_pattern().clone();
1856 auto val_p = p->get_value_pattern().clone();
1857 std::vector<std::string> vec(t.size());
1858
1859 unsigned int i = 0;
1860 for (const auto &ti : t)
1861 vec[i++] =
1863 p->get_key_value_separator() +
1865
1866 std::string s;
1867 if (vec.size() > 0)
1868 s = vec[0];
1869 for (unsigned int i = 1; i < vec.size(); ++i)
1870 s += p->get_separator() + " " + vec[i];
1871
1872 AssertThrow(p->match(s), ExcNoMatch(s, p->description()));
1873 return s;
1874 }
1875
1876 static T
1877 to_value(const std::string & s,
1879 {
1880 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1881
1882 auto p = dynamic_cast<const Patterns::Map *>(&pattern);
1883 AssertThrow(p,
1884 ExcMessage("I need a Map pattern to convert a "
1885 "string to a Map compatible type."));
1886
1887 auto key_p = p->get_key_pattern().clone();
1888 auto val_p = p->get_value_pattern().clone();
1889 T t;
1890
1891 auto v = Utilities::split_string_list(s, p->get_separator());
1892 for (const auto &str : v)
1893 {
1894 auto key_val =
1895 Utilities::split_string_list(str, p->get_key_value_separator());
1896 AssertDimension(key_val.size(), 2);
1897 t.insert(std::make_pair(
1898 Convert<typename T::key_type>::to_value(key_val[0], *key_p),
1899 Convert<typename T::mapped_type>::to_value(key_val[1], *val_p)));
1900 }
1901
1902 return t;
1903 }
1904 };
1905
1906 // std::array
1907 template <class ValueType, std::size_t N>
1908 struct Convert<std::array<ValueType, N>>
1909 {
1910 using T = std::array<ValueType, N>;
1911
1912 static std::unique_ptr<Patterns::PatternBase>
1914 {
1915 static_assert(internal::RankInfo<T>::list_rank > 0,
1916 "Cannot use this class for non List-compatible types.");
1917 return std::make_unique<Patterns::List>(
1919 N,
1920 N,
1922 1]);
1923 }
1924
1925 static std::string
1927 const T & t,
1929 {
1930 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1931 AssertThrow(p,
1932 ExcMessage("I need a List pattern to convert a "
1933 "string to a std::array."));
1934 auto base_p = p->get_base_pattern().clone();
1935 std::vector<std::string> vec(t.size());
1936
1937 std::transform(
1938 t.cbegin(), t.cend(), vec.begin(), [&base_p](const auto &entry) {
1939 return Convert<typename T::value_type>::to_string(entry, *base_p);
1940 });
1941
1942 std::string s;
1943 if (vec.size() > 0)
1944 s = vec[0];
1945 for (unsigned int i = 1; i < vec.size(); ++i)
1946 s += p->get_separator() + " " + vec[i];
1947
1948 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
1949 return s;
1950 }
1951
1952 static T
1953 to_value(const std::string & s,
1955 {
1956 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1957
1958 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1959 AssertThrow(p,
1960 ExcMessage("I need a List pattern to convert a string "
1961 "to a std::array."));
1962
1963 auto base_p = p->get_base_pattern().clone();
1964 T t;
1965
1966 auto v = Utilities::split_string_list(s, p->get_separator());
1967 AssertDimension(v.size(), N);
1968 for (unsigned int i = 0; i < N; ++i)
1969 t[i] = Convert<typename T::value_type>::to_value(v[i], *base_p);
1970 return t;
1971 }
1972 };
1973
1974 // Tensors
1975 template <int rank, int dim, class Number>
1976 struct Convert<Tensor<rank, dim, Number>>
1977 {
1979 static std::unique_ptr<Patterns::PatternBase>
1981 {
1982 static_assert(internal::RankInfo<T>::list_rank > 0,
1983 "Cannot use this class for non List-compatible types.");
1984 return std::make_unique<Patterns::List>(
1986 dim,
1987 dim,
1989 1]);
1990 }
1991
1992 static std::string
1994 const T & t,
1996 {
1997 auto p = dynamic_cast<const Patterns::List *>(&pattern);
1998 AssertThrow(p,
1999 ExcMessage("I need a List pattern to convert a string "
2000 "to a List compatible type."));
2001 auto base_p = p->get_base_pattern().clone();
2002 std::vector<std::string> vec(dim);
2003
2004 for (unsigned int i = 0; i < dim; ++i)
2005 vec[i] = Convert<typename T::value_type>::to_string(t[i], *base_p);
2006
2007 std::string s;
2008 if (vec.size() > 0)
2009 s = vec[0];
2010 for (unsigned int i = 1; i < vec.size(); ++i)
2011 s += p->get_separator() + " " + vec[i];
2012
2013 AssertThrow(p->match(s), ExcNoMatch(s, p->description()));
2014 return s;
2015 }
2016
2017 static T
2018 to_value(const std::string & s,
2020 {
2021 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2022
2023 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2024 AssertThrow(p,
2025 ExcMessage("I need a List pattern to convert a string "
2026 "to a List compatible type."));
2027
2028 auto base_p = p->get_base_pattern().clone();
2029 T t;
2030
2031 auto v = Utilities::split_string_list(s, p->get_separator());
2032 unsigned int i = 0;
2033 for (const auto &str : v)
2034 t[i++] = Convert<typename T::value_type>::to_value(str, *base_p);
2035
2036 return t;
2037 }
2038 };
2039
2040 // Points
2041 template <int dim, class Number>
2042 struct Convert<Point<dim, Number>>
2043 {
2045
2046 static std::unique_ptr<Patterns::PatternBase>
2048 {
2050 }
2051
2052 static std::string
2054 const T & t,
2056 {
2058 Tensor<1, dim, Number>(t), pattern);
2059 }
2060
2061 static T
2062 to_value(const std::string & s,
2064 {
2065 return T(Convert<Tensor<1, dim, Number>>::to_value(s, pattern));
2066 }
2067 };
2068
2069 // Functions::FunctionParser
2070 template <int dim>
2071 struct Convert<std::unique_ptr<FunctionParser<dim>>>
2072 {
2073 using T = std::unique_ptr<FunctionParser<dim>>;
2074
2075 static std::unique_ptr<Patterns::PatternBase>
2077 {
2078 static_assert(internal::RankInfo<T>::list_rank > 0,
2079 "Cannot use this class for non List-compatible types.");
2080
2081 return std::make_unique<Patterns::List>(
2083 1,
2086 1]);
2087 }
2088
2089 static std::string
2091 const T & t,
2093 {
2094 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2095 AssertThrow(p,
2096 ExcMessage("I need a List pattern to convert a string "
2097 "to a List compatible type."));
2098
2099 const auto &expressions = t->get_expressions();
2100 if (expressions.size() == 0)
2101 return std::string();
2102
2103 std::string s = expressions[0];
2104 for (unsigned int i = 1; i < expressions.size(); ++i)
2105 s = s + p->get_separator() + expressions[i];
2106
2107 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
2108 return s;
2109 }
2110
2111 static T
2112 to_value(const std::string & s,
2114 {
2115 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2116
2117 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2118 AssertThrow(p,
2119 ExcMessage("I need a List pattern to convert a string "
2120 "to a List compatible type."));
2121
2122 const auto expressions =
2123 Utilities::split_string_list(s, p->get_separator());
2124
2125 T t = std::make_unique<FunctionParser<dim>>(expressions.size());
2126 const std::string var =
2128 const typename FunctionParser<dim>::ConstMap constants;
2129 t->initialize(var, expressions, constants, true);
2130 return t;
2131 }
2132 };
2133
2134 // ComponentMask
2135 template <>
2137 {
2139
2140 static std::unique_ptr<Patterns::PatternBase>
2142 {
2144 }
2145
2146 static std::string
2148 const T & t,
2150 {
2151 std::vector<bool> mask(t.size());
2152 for (unsigned int i = 0; i < t.size(); ++i)
2153 mask[i] = t[i];
2154
2155 return Convert<std::vector<bool>>::to_string(mask, pattern);
2156 }
2157
2158 static T
2159 to_value(const std::string & s,
2161 {
2162 const auto mask = Convert<std::vector<bool>>::to_value(s, pattern);
2163 return ComponentMask(mask);
2164 }
2165 };
2166
2167 // Complex numbers
2168 template <class Number>
2169 struct Convert<std::complex<Number>>
2170 {
2171 using T = std::complex<Number>;
2172
2173 static std::unique_ptr<Patterns::PatternBase>
2175 {
2176 static_assert(internal::RankInfo<T>::list_rank > 0,
2177 "Cannot use this class for non List-compatible types.");
2178 return std::make_unique<Patterns::List>(
2180 2,
2181 2,
2183 1]);
2184 }
2185
2186 static std::string
2188 const T & t,
2190 {
2191 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2192 AssertThrow(p,
2193 ExcMessage("I need a List pattern to convert a string "
2194 "to a List compatible type."));
2195
2196 auto base_p = p->get_base_pattern().clone();
2197 std::string s =
2199 p->get_separator() + " " +
2201
2202 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
2203 return s;
2204 }
2205
2209 static T
2210 to_value(const std::string & s,
2212 {
2213 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2214
2215 auto p = dynamic_cast<const Patterns::List *>(&pattern);
2216 AssertThrow(p,
2217 ExcMessage("I need a List pattern to convert a string "
2218 "to a List compatible type."));
2219
2220 auto base_p = p->get_base_pattern().clone();
2221
2222 auto v = Utilities::split_string_list(s, p->get_separator());
2223 AssertDimension(v.size(), 2);
2226 return t;
2227 }
2228 };
2229
2230 // Strings
2231 template <>
2232 struct Convert<std::string>
2233 {
2234 using T = std::string;
2235
2236 static std::unique_ptr<Patterns::PatternBase>
2238 {
2239 return std::make_unique<Patterns::Anything>();
2240 }
2241
2242 static std::string
2244 const T & t,
2246 {
2247 AssertThrow(pattern.match(t), ExcNoMatch(t, pattern.description()));
2248 return t;
2249 }
2250
2251 static T
2252 to_value(const std::string & s,
2254 {
2255 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2256 return s;
2257 }
2258 };
2259
2260 // Pairs
2261 template <class Key, class Value>
2262 struct Convert<std::pair<Key, Value>>
2263 {
2264 using T = std::pair<Key, Value>;
2265
2266 static std::unique_ptr<Patterns::PatternBase>
2268 {
2269 static_assert(internal::RankInfo<T>::map_rank > 0,
2270 "Cannot use this class for non Map-compatible types.");
2271 return std::make_unique<Patterns::Tuple>(
2275 }
2276
2277 static std::string
2279 const T & t,
2281 {
2282 std::tuple<Key, Value> m(t);
2283 std::string s = Convert<decltype(m)>::to_string(m, pattern);
2284 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2285 return s;
2286 }
2287
2288 static T
2289 to_value(const std::string & s,
2291 {
2292 std::tuple<Key, Value> m;
2293 m = Convert<decltype(m)>::to_value(s, pattern);
2294 return std::make_pair(std::get<0>(m), std::get<1>(m));
2295 }
2296 };
2297
2298 // Tuples
2299 template <class... Args>
2300 struct Convert<std::tuple<Args...>>
2301 {
2302 using T = std::tuple<Args...>;
2303
2304 static std::unique_ptr<Patterns::PatternBase>
2306 {
2307 static_assert(internal::RankInfo<T>::map_rank > 0,
2308 "Cannot use this class for non tuple-compatible types.");
2309 return std::make_unique<Patterns::Tuple>(
2312 }
2313
2314 static std::string
2316 const T & t,
2318 {
2319 auto p = dynamic_cast<const Patterns::Tuple *>(&pattern);
2320 AssertThrow(p,
2321 ExcMessage("I need a Tuple pattern to convert a tuple "
2322 "to a string."));
2323
2324 const auto string_array = Convert<T>::to_string_internal_2(t, *p);
2325 std::string str;
2326 for (unsigned int i = 0; i < string_array.size(); ++i)
2327 str +=
2328 (i != 0u ? " " + p->get_separator() + " " : "") + string_array[i];
2329 AssertThrow(p->match(str), ExcNoMatch(str, p->description()));
2330 return str;
2331 }
2332
2333 static T
2334 to_value(const std::string & s,
2336 {
2337 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2338
2339 auto p = dynamic_cast<const Patterns::Tuple *>(&pattern);
2340 AssertThrow(p,
2341 ExcMessage("I need a Tuple pattern to convert a string "
2342 "to a tuple type."));
2343
2344 auto v = Utilities::split_string_list(s, p->get_separator());
2345
2346 return Convert<T>::to_value_internal_2(v, *p);
2347 }
2348
2349 private:
2350 template <std::size_t... U>
2351 static std::array<std::string, std::tuple_size<T>::value>
2353 const Patterns::Tuple &pattern,
2354 std::index_sequence<U...>)
2355 {
2356 std::array<std::string, std::tuple_size<T>::value> a = {
2358 std::get<U>(t), pattern.get_pattern(U))...}};
2359 return a;
2360 }
2361
2362 static std::array<std::string, std::tuple_size<T>::value>
2363 to_string_internal_2(const T &t, const Patterns::Tuple &pattern)
2364 {
2366 t, pattern, std::make_index_sequence<std::tuple_size<T>::value>{});
2367 }
2368
2369 template <std::size_t... U>
2370 static T
2371 to_value_internal_1(const std::vector<std::string> &s,
2372 const Patterns::Tuple & pattern,
2373 std::index_sequence<U...>)
2374 {
2375 return std::make_tuple(
2376 Convert<typename std::tuple_element<U, T>::type>::to_value(
2377 s[U], pattern.get_pattern(U))...);
2378 }
2379
2380 static T
2381 to_value_internal_2(const std::vector<std::string> &s,
2382 const Patterns::Tuple & pattern)
2383 {
2385 s, pattern, std::make_index_sequence<std::tuple_size<T>::value>{});
2386 }
2387 };
2388
2389 // Utility function with default Pattern
2390 template <typename T>
2391 std::string
2392 to_string(const T &t)
2393 {
2394 return Convert<T>::to_string(t);
2395 }
2396
2397 // Utility function with default Pattern
2398 template <typename T>
2399 void
2400 to_value(const std::string &s, T &t)
2401 {
2402 t = Convert<T>::to_value(s);
2403 }
2404 } // namespace Tools
2405} // namespace Patterns
2406
2407
2409
2410#endif
unsigned int size() const
std::map< std::string, double > ConstMap
static std::string default_variable_names()
static std::unique_ptr< Anything > create(const std::string &description)
Definition patterns.cc:1511
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1467
static const char * description_init
Definition patterns.h:1064
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1475
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1503
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1414
static const char * description_init
Definition patterns.h:1015
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1442
static std::unique_ptr< Bool > create(const std::string &description)
Definition patterns.cc:1450
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1653
static const char * description_init
Definition patterns.h:1204
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1625
static std::unique_ptr< DirectoryName > create(const std::string &description)
Definition patterns.cc:1661
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1617
static std::unique_ptr< Double > create(const std::string &description)
Definition patterns.cc:489
static const char * description_init
Definition patterns.h:369
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:481
const double lower_bound
Definition patterns.h:356
const double upper_bound
Definition patterns.h:364
static const double max_double_value
Definition patterns.h:304
static const double min_double_value
Definition patterns.h:298
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:381
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:358
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1533
static const char * description_init
Definition patterns.h:1146
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1577
static std::unique_ptr< FileName > create(const std::string &description)
Definition patterns.cc:1585
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1541
static std::unique_ptr< Integer > create(const std::string &description)
Definition patterns.cc:310
static const char * description_init
Definition patterns.h:271
const int upper_bound
Definition patterns.h:266
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:302
const int lower_bound
Definition patterns.h:258
static const int min_int_value
Definition patterns.h:196
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:241
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:219
static const int max_int_value
Definition patterns.h:203
const unsigned int max_elements
Definition patterns.h:555
static const char * description_init
Definition patterns.h:565
const unsigned int min_elements
Definition patterns.h:550
std::unique_ptr< PatternBase > pattern
Definition patterns.h:545
const std::string separator
Definition patterns.h:560
std::size_t memory_consumption() const override
Definition patterns.cc:766
static std::unique_ptr< List > create(const std::string &description)
Definition patterns.cc:775
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:714
const PatternBase & get_base_pattern() const
Definition patterns.cc:686
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:694
const std::string & get_separator() const
Definition patterns.cc:678
static const unsigned int max_int_value
Definition patterns.h:457
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:758
static std::unique_ptr< Map > create(const std::string &description)
Definition patterns.cc:984
std::unique_ptr< PatternBase > value_pattern
Definition patterns.h:694
const unsigned int min_elements
Definition patterns.h:699
const PatternBase & get_key_pattern() const
Definition patterns.cc:1039
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:880
const unsigned int max_elements
Definition patterns.h:704
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:960
const PatternBase & get_value_pattern() const
Definition patterns.cc:1047
const std::string & get_separator() const
Definition patterns.cc:1055
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:910
static const unsigned int max_int_value
Definition patterns.h:591
std::unique_ptr< PatternBase > key_pattern
Definition patterns.h:693
const std::string separator
Definition patterns.h:709
std::size_t memory_consumption() const override
Definition patterns.cc:972
static const char * description_init
Definition patterns.h:720
const std::string & get_key_value_separator() const
Definition patterns.cc:1062
const std::string key_value_separator
Definition patterns.h:715
static std::unique_ptr< MultipleSelection > create(const std::string &description)
Definition patterns.cc:1385
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1271
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1369
static const char * description_init
Definition patterns.h:973
std::size_t memory_consumption() const override
Definition patterns.cc:1376
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1334
virtual std::size_t memory_consumption() const
Definition patterns.cc:190
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:438
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:576
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:611
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:544
static std::unique_ptr< Selection > create(const std::string &description)
Definition patterns.cc:627
std::size_t memory_consumption() const override
Definition patterns.cc:618
std::string sequence
Definition patterns.h:433
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1105
std::size_t memory_consumption() const override
Definition patterns.cc:1181
static std::unique_ptr< Tuple > create(const std::string &description)
Definition patterns.cc:1190
std::vector< std::unique_ptr< PatternBase > > patterns
Definition patterns.h:879
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1174
Tuple(const Patterns &...patterns)
const std::string separator
Definition patterns.h:884
static const char * description_init
Definition patterns.h:889
Tuple(const std::vector< std::unique_ptr< PatternBase > > &patterns, const std::string &separator=":")
Definition patterns.cc:1072
const std::string & get_separator() const
Definition patterns.cc:1246
const PatternBase & get_pattern(const unsigned int i) const
Definition patterns.cc:1238
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1124
Definition point.h:112
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
static ::ExceptionBase & ExcInvalidRange(int arg1, int arg2)
static ::ExceptionBase & ExcInvalidRange(int arg1, int arg2)
static ::ExceptionBase & ExcNoMatch(std::string arg1, std::string arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:533
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcCommasNotAllowed(int arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:510
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr std::array< const char *, 4 > default_map_separator
Definition patterns.h:1575
constexpr int max_map_rank()
Definition patterns.h:1663
constexpr int max_list_rank()
Definition patterns.h:1648
constexpr std::array< const char *, 4 > default_list_separator
Definition patterns.h:1573
void to_value(const std::string &s, T &t)
Definition patterns.h:2400
std::string to_string(const T &t)
Definition patterns.h:2392
std::string escape(const std::string &input, const PatternBase::OutputStyle style)
Definition patterns.cc:53
std::unique_ptr< PatternBase > pattern_factory(const std::string &description)
Definition patterns.cc:138
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition utilities.cc:702
STL namespace.
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2141
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2159
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2147
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2047
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2053
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2062
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1803
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1776
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1847
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1877
static std::string to_string(const T &value, const Patterns::PatternBase &p= *Convert< T >::to_pattern())
Definition patterns.h:1518
static std::enable_if_t< std::is_same< Dummy, T >::value &&std::is_same< T, bool >::value, std::unique_ptr< Patterns::PatternBase > > to_pattern()
Definition patterns.h:1490
static std::enable_if_t< std::is_same< Dummy, T >::value &&!std::is_same< T, bool >::value &&std::is_floating_point< T >::value, std::unique_ptr< Patterns::PatternBase > > to_pattern()
Definition patterns.h:1511
static T to_value(const std::string &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())
Definition patterns.h:1534
static std::enable_if_t< std::is_same< Dummy, T >::value &&!std::is_same< T, bool >::value &&std::is_integral< T >::value, std::unique_ptr< Patterns::PatternBase > > to_pattern()
Definition patterns.h:1500
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:1980
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2018
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1993
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:1913
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1953
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1926
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2174
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2210
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2187
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2267
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2289
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2278
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2237
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2252
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2243
static T to_value_internal_2(const std::vector< std::string > &s, const Patterns::Tuple &pattern)
Definition patterns.h:2381
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2334
static std::array< std::string, std::tuple_size< T >::value > to_string_internal_2(const T &t, const Patterns::Tuple &pattern)
Definition patterns.h:2363
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2305
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:2352
static T to_value_internal_1(const std::vector< std::string > &s, const Patterns::Tuple &pattern, std::index_sequence< U... >)
Definition patterns.h:2371
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2315
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2076
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2112
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2090
static std::unique_ptr< Patterns::PatternBase > to_pattern()=delete
static T to_value(const std::string &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())=delete
static std::string to_string(const T &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())=delete
static constexpr int list_rank
Definition patterns.h:1477
static constexpr int map_rank
Definition patterns.h:1478
static constexpr bool const value
Definition patterns.h:1632
static constexpr bool const value
Definition patterns.h:1639