Reference documentation for deal.II version GIT relicensing-43-g3fc2fae7c3 2024-03-03 21:10:02+00:00
\(\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// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2017 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_patterns_h
16#define dealii_patterns_h
17
18
19#include <deal.II/base/config.h>
20
22#include <deal.II/base/point.h>
26
28
29#include <boost/archive/basic_archive.hpp>
30#include <boost/core/demangle.hpp>
31#include <boost/property_tree/ptree_fwd.hpp>
32#include <boost/property_tree/ptree_serialization.hpp>
33#include <boost/serialization/split_member.hpp>
34
35#include <algorithm>
36#include <array>
37#include <deque>
38#include <limits>
39#include <list>
40#include <map>
41#include <memory>
42#include <set>
43#include <sstream>
44#include <string>
45#include <type_traits>
46#include <unordered_map>
47#include <unordered_set>
48#include <utility>
49#include <vector>
50
52
53// forward declarations for interfaces and friendship
54#ifndef DOXYGEN
55class LogStream;
57template <int dim>
58class FunctionParser;
59#endif
60
69namespace Patterns
70{
78 {
79 public:
83 virtual ~PatternBase() = default;
84
88 virtual bool
89 match(const std::string &test_string) const = 0;
90
115
119 virtual std::string
120 description(const OutputStyle style = Machine) const = 0;
121
131 virtual std::unique_ptr<PatternBase>
132 clone() const = 0;
133
149 virtual std::size_t
150 memory_consumption() const;
151 };
152
156 std::unique_ptr<PatternBase>
157 pattern_factory(const std::string &description);
158
159 namespace internal
160 {
166 std::string
167 escape(const std::string &input, const PatternBase::OutputStyle style);
168
169 } // namespace internal
170
187 class Integer : public PatternBase
188 {
189 public:
195 static const int min_int_value;
196
202 static const int max_int_value;
203
217 const int upper_bound = max_int_value);
218
223 virtual bool
224 match(const std::string &test_string) const override;
225
231 virtual std::string
232 description(const OutputStyle style = Machine) const override;
233
239 virtual std::unique_ptr<PatternBase>
240 clone() const override;
241
247 static std::unique_ptr<Integer>
248 create(const std::string &description);
249
250 private:
257 const int lower_bound;
258
265 const int upper_bound;
266
270 static const char *description_init;
271 };
272
290 class Double : public PatternBase
291 {
292 public:
297 static const double min_double_value;
298
303 static const double max_double_value;
304
312 Double(const double lower_bound = min_double_value,
313 const double upper_bound = max_double_value);
314
319 virtual bool
320 match(const std::string &test_string) const override;
321
327 virtual std::string
328 description(const OutputStyle style = Machine) const override;
329
335 virtual std::unique_ptr<PatternBase>
336 clone() const override;
337
345 static std::unique_ptr<Double>
346 create(const std::string &description);
347
348 private:
355 const double lower_bound;
356
363 const double upper_bound;
364
368 static const char *description_init;
369 };
370
380 class Selection : public PatternBase
381 {
382 public:
387 Selection(const std::string &seq);
388
393 virtual bool
394 match(const std::string &test_string) const override;
395
401 virtual std::string
402 description(const OutputStyle style = Machine) const override;
403
409 virtual std::unique_ptr<PatternBase>
410 clone() const override;
411
416 std::size_t
417 memory_consumption() const override;
418
424 static std::unique_ptr<Selection>
425 create(const std::string &description);
426
427 private:
432 std::string sequence;
433
437 static const char *description_init;
438 };
439
440
448 class List : public PatternBase
449 {
450 public:
456 static const unsigned int max_int_value;
457
466 List(const PatternBase &base_pattern,
467 const unsigned int min_elements = 0,
468 const unsigned int max_elements = max_int_value,
469 const std::string &separator = ",");
470
471
475 const std::string &
476 get_separator() const;
477
481 const PatternBase &
482 get_base_pattern() const;
483
487 List(const List &other);
488
493 virtual bool
494 match(const std::string &test_string) const override;
495
500 virtual std::string
501 description(const OutputStyle style = Machine) const override;
502
508 virtual std::unique_ptr<PatternBase>
509 clone() const override;
510
516 static std::unique_ptr<List>
517 create(const std::string &description);
518
523 std::size_t
524 memory_consumption() const override;
525
535 int,
536 int,
537 << "The values " << arg1 << " and " << arg2
538 << " do not form a valid range.");
540 private:
544 std::unique_ptr<PatternBase> pattern;
545
549 const unsigned int min_elements;
550
554 const unsigned int max_elements;
555
559 const std::string separator;
560
564 static const char *description_init;
565 };
566
567
582 class Map : public PatternBase
583 {
584 public:
590 static const unsigned int max_int_value;
591
602 const unsigned int min_elements = 0,
603 const unsigned int max_elements = max_int_value,
604 const std::string &separator = ",",
605 const std::string &key_value_separator = ":");
606
610 Map(const Map &other);
611
616 virtual bool
617 match(const std::string &test_string) const override;
618
623 virtual std::string
624 description(const OutputStyle style = Machine) const override;
625
631 virtual std::unique_ptr<PatternBase>
632 clone() const override;
633
639 static std::unique_ptr<Map>
640 create(const std::string &description);
641
646 std::size_t
647 memory_consumption() const override;
648
652 const PatternBase &
653 get_key_pattern() const;
654
658 const PatternBase &
659 get_value_pattern() const;
660
664 const std::string &
665 get_separator() const;
666
670 const std::string &
672
682 int,
683 int,
684 << "The values " << arg1 << " and " << arg2
685 << " do not form a valid range.");
687 private:
692 std::unique_ptr<PatternBase> key_pattern;
693 std::unique_ptr<PatternBase> value_pattern;
694
698 const unsigned int min_elements;
699
703 const unsigned int max_elements;
704
708 const std::string separator;
709
710
714 const std::string key_value_separator;
715
719 static const char *description_init;
720 };
721
722
723
769 class Tuple : public PatternBase
770 {
771 public:
780 Tuple(const std::vector<std::unique_ptr<PatternBase>> &patterns,
781 const std::string &separator = ":");
782
788 Tuple(const std::vector<std::unique_ptr<PatternBase>> &patterns,
789 const char *separator);
790
791
799 template <class... PatternTypes>
800 Tuple(const std::string &separator, const PatternTypes &...patterns);
801
809 template <class... PatternTypes>
810 Tuple(const char *separator, const PatternTypes &...patterns);
811
817 template <typename... Patterns>
819
823 Tuple(const Tuple &other);
824
829 virtual bool
830 match(const std::string &test_string) const override;
831
836 virtual std::string
837 description(const OutputStyle style = Machine) const override;
838
844 virtual std::unique_ptr<PatternBase>
845 clone() const override;
846
852 static std::unique_ptr<Tuple>
853 create(const std::string &description);
854
859 std::size_t
860 memory_consumption() const override;
861
865 const PatternBase &
866 get_pattern(const unsigned int i) const;
867
871 const std::string &
872 get_separator() const;
873
874 private:
878 std::vector<std::unique_ptr<PatternBase>> patterns;
879
883 const std::string separator;
884
888 static const char *description_init;
889 };
890
891
903 {
904 public:
908 MultipleSelection(const std::string &seq);
909
914 virtual bool
915 match(const std::string &test_string) const override;
916
922 virtual std::string
923 description(const OutputStyle style = Machine) const override;
924
930 virtual std::unique_ptr<PatternBase>
931 clone() const override;
932
938 static std::unique_ptr<MultipleSelection>
939 create(const std::string &description);
940
945 std::size_t
946 memory_consumption() const override;
947
958 int,
959 << "A comma was found at position " << arg1
960 << " of your input string, but commas are not allowed here.");
962 private:
967 std::string sequence;
968
972 static const char *description_init;
973 };
974
979 class Bool : public Selection
980 {
981 public:
985 Bool();
986
991 virtual std::string
992 description(const OutputStyle style = Machine) const override;
993
999 virtual std::unique_ptr<PatternBase>
1000 clone() const override;
1001
1007 static std::unique_ptr<Bool>
1008 create(const std::string &description);
1009
1010 private:
1014 static const char *description_init;
1015 };
1016
1020 class Anything : public PatternBase
1021 {
1022 public:
1027 Anything() = default;
1028
1033 virtual bool
1034 match(const std::string &test_string) const override;
1035
1040 virtual std::string
1041 description(const OutputStyle style = Machine) const override;
1042
1048 virtual std::unique_ptr<PatternBase>
1049 clone() const override;
1050
1056 static std::unique_ptr<Anything>
1057 create(const std::string &description);
1058
1059 private:
1063 static const char *description_init;
1064 };
1065
1066
1081 class FileName : public PatternBase
1082 {
1083 public:
1089 {
1097 output = 1
1099
1104 FileName(const FileType type = input);
1105
1110 virtual bool
1111 match(const std::string &test_string) const override;
1112
1117 virtual std::string
1118 description(const OutputStyle style = Machine) const override;
1119
1125 virtual std::unique_ptr<PatternBase>
1126 clone() const override;
1127
1132
1138 static std::unique_ptr<FileName>
1139 create(const std::string &description);
1140
1141 private:
1145 static const char *description_init;
1146 };
1147
1148
1162 {
1163 public:
1167 DirectoryName() = default;
1168
1173 virtual bool
1174 match(const std::string &test_string) const override;
1175
1180 virtual std::string
1181 description(const OutputStyle style = Machine) const override;
1182
1188 virtual std::unique_ptr<PatternBase>
1189 clone() const override;
1190
1196 static std::unique_ptr<DirectoryName>
1197 create(const std::string &description);
1198
1199 private:
1203 static const char *description_init;
1204 };
1205
1206
1285 namespace Tools
1286 {
1296 template <class T, class Enable = void>
1297 struct Convert
1298 {
1308 static std::unique_ptr<Patterns::PatternBase>
1309 to_pattern() = delete;
1310
1321 static std::string
1322 to_string(const T &s,
1324 delete;
1325
1335 static T
1336 to_value(const std::string &s,
1338 delete;
1339 };
1340
1359 template <typename T>
1360 std::string
1361 to_string(const T &t);
1362
1388 template <typename T>
1389 void
1390 to_value(const std::string &s, T &t);
1391
1401 std::string,
1402 std::string,
1403 << "The string \"" << arg1
1404 << "\" does not match the pattern \"" << arg2 << "\"");
1406 } // namespace Tools
1407} // namespace Patterns
1408
1409
1410// ---------------------- inline and template functions --------------------
1411namespace Patterns
1412{
1413 template <class... PatternTypes>
1414 Tuple::Tuple(const char *separator, const PatternTypes &...ps)
1415 : // forward to the version with std::string argument
1416 Tuple(std::string(separator), ps...)
1417 {}
1418
1419
1420
1421 template <class... PatternTypes>
1422 Tuple::Tuple(const std::string &separator, const PatternTypes &...ps)
1423 : separator(separator)
1424 {
1425 static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
1426 "Not all of the input arguments of this function "
1427 "are derived from PatternBase");
1428 static_assert(sizeof...(ps) > 0,
1429 "The number of PatternTypes must be greater than zero!");
1430 const auto pattern_pointers = {(static_cast<const PatternBase *>(&ps))...};
1431 for (const auto p : pattern_pointers)
1432 patterns.push_back(p->clone());
1433 }
1434
1435
1436
1437 template <class... PatternTypes>
1438 Tuple::Tuple(const PatternTypes &...ps)
1439 : // forward to the version with the separator argument
1440 Tuple(std::string(":"), ps...)
1441 {}
1442
1443
1444
1445 namespace Tools
1446 {
1447 namespace internal
1448 {
1473 template <class T, class Enable = void>
1475 {
1476 static constexpr int list_rank = 0;
1477 static constexpr int map_rank = 0;
1478 };
1479 } // namespace internal
1480
1481 // Arithmetic types
1482 template <class T>
1483 struct Convert<T, std::enable_if_t<std::is_arithmetic_v<T>>>
1484 {
1485 template <typename Dummy = T>
1486 static std::enable_if_t<std::is_same_v<Dummy, T> &&
1487 std::is_same_v<T, bool>,
1488 std::unique_ptr<Patterns::PatternBase>>
1490 {
1491 return std::make_unique<Patterns::Bool>();
1492 }
1493
1494 template <typename Dummy = T>
1495 static std::enable_if_t<std::is_same_v<Dummy, T> &&
1496 !std::is_same_v<T, bool> &&
1497 std::is_integral_v<T>,
1498 std::unique_ptr<Patterns::PatternBase>>
1500 {
1501 return std::make_unique<Patterns::Integer>(
1502 std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
1503 }
1504
1505 template <typename Dummy = T>
1506 static std::enable_if_t<std::is_same_v<Dummy, T> &&
1507 !std::is_same_v<T, bool> &&
1508 std::is_floating_point_v<T>,
1509 std::unique_ptr<Patterns::PatternBase>>
1511 {
1512 return std::make_unique<Patterns::Double>(
1513 std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
1514 }
1515
1516 static std::string
1517 to_string(const T &value,
1519 {
1520 std::stringstream str;
1521 if (std::is_same_v<T, unsigned char> ||
1522 std::is_same_v<T, signed char> || std::is_same_v<T, char>)
1523 str << static_cast<int>(value);
1524 else if (std::is_same_v<T, bool>)
1525 str << (static_cast<bool>(value) ? "true" : "false");
1526 else
1527 str << value;
1528 AssertThrow(p.match(str.str()), ExcNoMatch(str.str(), p.description()));
1529 return str.str();
1530 }
1531
1532 static T
1533 to_value(const std::string &s,
1535 {
1536 AssertThrow(p.match(s), ExcNoMatch(s, p.description()));
1537 T value;
1538 if (std::is_same_v<T, bool>)
1539 value = (s == "true");
1540 else
1541 {
1542 std::istringstream is(s);
1543 if (std::is_same_v<T, unsigned char> ||
1544 std::is_same_v<T, signed char> || std::is_same_v<T, char>)
1545 {
1546 int i;
1547 is >> i;
1548 value = i;
1549 }
1550 else
1551 is >> value;
1552
1553 // If someone passes "123 abc" to the function, the method yields an
1554 // integer 123 alright, but the space terminates the read from the
1555 // string although there is more to come. This case, however, is
1556 // checked for in the call p->match(s) at the beginning of this
1557 // function, and would throw earlier. Here it is safe to assume that
1558 // if we didn't fail the conversion with the operator >>, then we
1559 // are good to go.
1561 !is.fail(),
1562 ExcMessage("Failed to convert from \"" + s + "\" to the type \"" +
1563 boost::core::demangle(typeid(T).name()) + "\""));
1564 }
1565 return value;
1566 }
1567 };
1568
1569 namespace internal
1570 {
1571 constexpr std::array<const char *, 4> default_list_separator{
1572 {",", ";", "|", "%"}};
1573 constexpr std::array<const char *, 4> default_map_separator{
1574 {":", "=", "@", "#"}};
1575
1576 // specialize a type for all of the STL containers and maps
1577 template <typename T>
1578 struct is_list_compatible : std::false_type
1579 {};
1580 template <typename... Args>
1581 struct is_list_compatible<std::vector<Args...>> : std::true_type
1582 {};
1583 template <typename... Args>
1584 struct is_list_compatible<std::deque<Args...>> : std::true_type
1585 {};
1586 template <typename... Args>
1587 struct is_list_compatible<std::list<Args...>> : std::true_type
1588 {};
1589 template <typename... Args>
1590 struct is_list_compatible<std::set<Args...>> : std::true_type
1591 {};
1592 template <typename... Args>
1593 struct is_list_compatible<std::multiset<Args...>> : std::true_type
1594 {};
1595 template <typename... Args>
1596 struct is_list_compatible<std::unordered_set<Args...>> : std::true_type
1597 {};
1598 template <typename... Args>
1599 struct is_list_compatible<std::unordered_multiset<Args...>>
1600 : std::true_type
1601 {};
1602
1603 template <typename T>
1604 struct is_map_compatible : std::false_type
1605 {};
1606 template <class Key, class T, class Compare, class Allocator>
1607 struct is_map_compatible<std::map<Key, T, Compare, Allocator>>
1608 : std::true_type
1609 {};
1610 template <class Key, class T, class Compare, class Allocator>
1611 struct is_map_compatible<std::multimap<Key, T, Compare, Allocator>>
1612 : std::true_type
1613 {};
1614 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
1616 std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type
1617 {};
1618 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
1620 std::unordered_multimap<Key, T, Hash, KeyEqual, Allocator>>
1621 : std::true_type
1622 {};
1623 } // namespace internal
1624
1625 // type trait to use the implementation type traits as well as decay the
1626 // type
1627 template <typename T>
1629 {
1630 static constexpr const bool value =
1632 };
1633
1634 template <typename T>
1636 {
1637 static constexpr const bool value =
1639 };
1640
1641 namespace internal
1642 {
1643 // Helper function for list_rank
1644 template <class T>
1645 constexpr int
1647 {
1649 }
1650
1651 template <class T1, class T2, class... Types>
1652 constexpr int
1654 {
1655 return std::max(RankInfo<T1>::list_rank, max_list_rank<T2, Types...>());
1656 }
1657
1658 // Helper function for map_rank
1659 template <class T>
1660 constexpr int
1662 {
1663 return RankInfo<T>::map_rank;
1664 }
1665
1666 template <class T1, class T2, class... Types>
1667 constexpr int
1669 {
1670 return std::max(RankInfo<T1>::map_rank, max_map_rank<T2, Types...>());
1671 }
1672
1673 // Rank of vector types
1674 template <class T>
1675 struct RankInfo<T, std::enable_if_t<is_list_compatible<T>::value>>
1676 {
1677 static constexpr int list_rank =
1679 static constexpr int map_rank =
1681 };
1682
1683 // Rank of map types
1684 template <class T>
1685 struct RankInfo<T, std::enable_if_t<is_map_compatible<T>::value>>
1686 {
1687 static constexpr int list_rank =
1688 max_list_rank<typename T::key_type, typename T::mapped_type>() + 1;
1689 static constexpr int map_rank =
1690 max_map_rank<typename T::key_type, typename T::mapped_type>() + 1;
1691 };
1692
1693 // Rank of Tensor types
1694 template <int rank, int dim, class Number>
1695 struct RankInfo<Tensor<rank, dim, Number>>
1696 {
1697 static constexpr int list_rank = rank + RankInfo<Number>::list_rank;
1698 static constexpr int map_rank = RankInfo<Number>::map_rank;
1699 };
1700
1701 template <int dim, class Number>
1702 struct RankInfo<Point<dim, Number>> : RankInfo<Tensor<1, dim, Number>>
1703 {};
1704
1705 // Rank of complex types
1706 template <class Number>
1707 struct RankInfo<std::complex<Number>>
1708 {
1709 static constexpr int list_rank = RankInfo<Number>::list_rank + 1;
1710 static constexpr int map_rank = RankInfo<Number>::map_rank;
1711 };
1712
1713 // Rank of FunctionParser
1714 template <int dim>
1715 struct RankInfo<std::unique_ptr<FunctionParser<dim>>>
1716 {
1717 static constexpr int list_rank = 1;
1718 static constexpr int map_rank = 0;
1719 };
1720
1721 // Rank of ComponentMask
1722 template <>
1724 {
1725 static constexpr int list_rank = 1;
1726 static constexpr int map_rank = 0;
1727 };
1728
1729 // Rank of std::pair
1730 template <class Key, class Value>
1731 struct RankInfo<std::pair<Key, Value>>
1732 {
1733 static constexpr int list_rank =
1735 static constexpr int map_rank =
1737 };
1738
1739 // Rank of std::tuple types
1740 template <class... Types>
1741 struct RankInfo<std::tuple<Types...>>
1742 {
1743 static constexpr int list_rank = max_list_rank<Types...>();
1744 static constexpr int map_rank = max_map_rank<Types...>() + 1;
1745 };
1746
1747 // Rank of std::array types
1748 template <class T, std::size_t N>
1749 struct RankInfo<std::array<T, N>>
1750 {
1751 static constexpr int list_rank = RankInfo<T>::list_rank + 1;
1752 static constexpr int map_rank = RankInfo<T>::map_rank;
1753 };
1754 } // namespace internal
1755
1756 // stl containers
1757 template <class T>
1758 struct Convert<T, std::enable_if_t<is_list_compatible<T>::value>>
1759 {
1760 static std::unique_ptr<Patterns::PatternBase>
1762 {
1763 static_assert(internal::RankInfo<T>::list_rank > 0,
1764 "Cannot use this class for non List-compatible types.");
1765 return std::make_unique<Patterns::List>(
1767 0,
1768 std::numeric_limits<unsigned int>::max(),
1770 1]);
1771 }
1772
1773 static std::string
1775 const T &t,
1777 {
1778 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
1779 AssertThrow(p,
1780 ExcMessage("I need a List pattern to convert a "
1781 "string to a List type."));
1782 auto base_p = p->get_base_pattern().clone();
1783 std::vector<std::string> vec(t.size());
1784
1785 std::transform(
1786 t.cbegin(), t.cend(), vec.begin(), [&base_p](const auto &entry) {
1787 return Convert<typename T::value_type>::to_string(entry, *base_p);
1788 });
1789
1790 std::string s;
1791 if (vec.size() > 0)
1792 s = vec[0];
1793 for (unsigned int i = 1; i < vec.size(); ++i)
1794 s += p->get_separator() + " " + vec[i];
1795
1796 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
1797 return s;
1798 }
1799
1800 static T
1801 to_value(const std::string &s,
1803 {
1804 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1805
1806 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
1807 AssertThrow(p,
1808 ExcMessage("I need a List pattern to convert a string "
1809 "to a List type."));
1810
1811 auto base_p = p->get_base_pattern().clone();
1812 T t;
1813
1814 auto v = Utilities::split_string_list(s, p->get_separator());
1815 for (const auto &str : v)
1816 t.insert(t.end(),
1818
1819 return t;
1820 }
1821 };
1822
1823 // stl maps
1824 template <class T>
1825 struct Convert<T, std::enable_if_t<is_map_compatible<T>::value>>
1826 {
1827 static std::unique_ptr<Patterns::PatternBase>
1829 {
1830 static_assert(internal::RankInfo<T>::list_rank > 0,
1831 "Cannot use this class for non List-compatible types.");
1832 static_assert(internal::RankInfo<T>::map_rank > 0,
1833 "Cannot use this class for non Map-compatible types.");
1834 return std::make_unique<Patterns::Map>(
1837 0,
1838 std::numeric_limits<unsigned int>::max(),
1840 1],
1842 }
1843
1844 static std::string
1846 const T &t,
1848 {
1849 const auto *p = dynamic_cast<const Patterns::Map *>(&pattern);
1850 AssertThrow(p,
1851 ExcMessage("I need a Map pattern to convert a string to "
1852 "a Map compatible type."));
1853 auto key_p = p->get_key_pattern().clone();
1854 auto val_p = p->get_value_pattern().clone();
1855 std::vector<std::string> vec(t.size());
1856
1857 unsigned int i = 0;
1858 for (const auto &ti : t)
1859 vec[i++] =
1861 p->get_key_value_separator() +
1863
1864 std::string s;
1865 if (vec.size() > 0)
1866 s = vec[0];
1867 for (unsigned int i = 1; i < vec.size(); ++i)
1868 s += p->get_separator() + " " + vec[i];
1869
1870 AssertThrow(p->match(s), ExcNoMatch(s, p->description()));
1871 return s;
1872 }
1873
1874 static T
1875 to_value(const std::string &s,
1877 {
1878 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1879
1880 const auto *p = dynamic_cast<const Patterns::Map *>(&pattern);
1881 AssertThrow(p,
1882 ExcMessage("I need a Map pattern to convert a "
1883 "string to a Map compatible type."));
1884
1885 auto key_p = p->get_key_pattern().clone();
1886 auto val_p = p->get_value_pattern().clone();
1887 T t;
1888
1889 auto v = Utilities::split_string_list(s, p->get_separator());
1890 for (const auto &str : v)
1891 {
1892 auto key_val =
1893 Utilities::split_string_list(str, p->get_key_value_separator());
1894 AssertDimension(key_val.size(), 2);
1895 t.insert(std::make_pair(
1896 Convert<typename T::key_type>::to_value(key_val[0], *key_p),
1897 Convert<typename T::mapped_type>::to_value(key_val[1], *val_p)));
1898 }
1899
1900 return t;
1901 }
1902 };
1903
1904 // std::array
1905 template <typename ValueType, std::size_t N>
1906 struct Convert<std::array<ValueType, N>>
1907 {
1908 using T = std::array<ValueType, N>;
1909
1910 static std::unique_ptr<Patterns::PatternBase>
1912 {
1913 static_assert(internal::RankInfo<T>::list_rank > 0,
1914 "Cannot use this class for non List-compatible types.");
1915 return std::make_unique<Patterns::List>(
1917 N,
1918 N,
1920 1]);
1921 }
1922
1923 static std::string
1925 const T &t,
1927 {
1928 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
1929 AssertThrow(p,
1930 ExcMessage("I need a List pattern to convert a "
1931 "string to a std::array."));
1932 auto base_p = p->get_base_pattern().clone();
1933 std::vector<std::string> vec(t.size());
1934
1935 std::transform(
1936 t.cbegin(), t.cend(), vec.begin(), [&base_p](const auto &entry) {
1937 return Convert<typename T::value_type>::to_string(entry, *base_p);
1938 });
1939
1940 std::string s;
1941 if (vec.size() > 0)
1942 s = vec[0];
1943 for (unsigned int i = 1; i < vec.size(); ++i)
1944 s += p->get_separator() + " " + vec[i];
1945
1946 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
1947 return s;
1948 }
1949
1950 static T
1951 to_value(const std::string &s,
1953 {
1954 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
1955
1956 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
1957 AssertThrow(p,
1958 ExcMessage("I need a List pattern to convert a string "
1959 "to a std::array."));
1960
1961 auto base_p = p->get_base_pattern().clone();
1962 T t;
1963
1964 auto v = Utilities::split_string_list(s, p->get_separator());
1965 AssertDimension(v.size(), N);
1966 for (unsigned int i = 0; i < N; ++i)
1967 t[i] = Convert<typename T::value_type>::to_value(v[i], *base_p);
1968 return t;
1969 }
1970 };
1971
1972 // Tensors
1973 template <int rank, int dim, class Number>
1974 struct Convert<Tensor<rank, dim, Number>>
1975 {
1977 static std::unique_ptr<Patterns::PatternBase>
1979 {
1980 static_assert(internal::RankInfo<T>::list_rank > 0,
1981 "Cannot use this class for non List-compatible types.");
1982 return std::make_unique<Patterns::List>(
1984 dim,
1985 dim,
1987 1]);
1988 }
1989
1990 static std::string
1992 const T &t,
1994 {
1995 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
1996 AssertThrow(p,
1997 ExcMessage("I need a List pattern to convert a string "
1998 "to a List compatible type."));
1999 auto base_p = p->get_base_pattern().clone();
2000 std::vector<std::string> vec(dim);
2001
2002 for (unsigned int i = 0; i < dim; ++i)
2003 vec[i] = Convert<typename T::value_type>::to_string(t[i], *base_p);
2004
2005 std::string s;
2006 if (vec.size() > 0)
2007 s = vec[0];
2008 for (unsigned int i = 1; i < vec.size(); ++i)
2009 s += p->get_separator() + " " + vec[i];
2010
2011 AssertThrow(p->match(s), ExcNoMatch(s, p->description()));
2012 return s;
2013 }
2014
2015 static T
2016 to_value(const std::string &s,
2018 {
2019 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2020
2021 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
2022 AssertThrow(p,
2023 ExcMessage("I need a List pattern to convert a string "
2024 "to a List compatible type."));
2025
2026 auto base_p = p->get_base_pattern().clone();
2027 T t;
2028
2029 auto v = Utilities::split_string_list(s, p->get_separator());
2030 unsigned int i = 0;
2031 for (const auto &str : v)
2032 t[i++] = Convert<typename T::value_type>::to_value(str, *base_p);
2033
2034 return t;
2035 }
2036 };
2037
2038 // Points
2039 template <int dim, class Number>
2040 struct Convert<Point<dim, Number>>
2041 {
2043
2044 static std::unique_ptr<Patterns::PatternBase>
2049
2050 static std::string
2052 const T &t,
2054 {
2056 Tensor<1, dim, Number>(t), pattern);
2057 }
2058
2059 static T
2060 to_value(const std::string &s,
2062 {
2063 return T(Convert<Tensor<1, dim, Number>>::to_value(s, pattern));
2064 }
2065 };
2066
2067 // Functions::FunctionParser
2068 template <int dim>
2069 struct Convert<std::unique_ptr<FunctionParser<dim>>>
2070 {
2071 using T = std::unique_ptr<FunctionParser<dim>>;
2072
2073 static std::unique_ptr<Patterns::PatternBase>
2075 {
2076 static_assert(internal::RankInfo<T>::list_rank > 0,
2077 "Cannot use this class for non List-compatible types.");
2078
2079 return std::make_unique<Patterns::List>(
2081 1,
2084 1]);
2085 }
2086
2087 static std::string
2089 const T &t,
2091 {
2092 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
2093 AssertThrow(p,
2094 ExcMessage("I need a List pattern to convert a string "
2095 "to a List compatible type."));
2096
2097 const auto &expressions = t->get_expressions();
2098 if (expressions.empty())
2099 return std::string();
2100
2101 std::string s = expressions[0];
2102 for (unsigned int i = 1; i < expressions.size(); ++i)
2103 s = s + p->get_separator() + expressions[i];
2104
2105 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
2106 return s;
2107 }
2108
2109 static T
2110 to_value(const std::string &s,
2112 {
2113 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2114
2115 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
2116 AssertThrow(p,
2117 ExcMessage("I need a List pattern to convert a string "
2118 "to a List compatible type."));
2119
2120 const auto expressions =
2121 Utilities::split_string_list(s, p->get_separator());
2122
2123 T t = std::make_unique<FunctionParser<dim>>(expressions.size());
2124 const std::string var =
2126 const typename FunctionParser<dim>::ConstMap constants;
2127 t->initialize(var, expressions, constants, true);
2128 return t;
2129 }
2130 };
2131
2132 // ComponentMask
2133 template <>
2135 {
2137
2138 static std::unique_ptr<Patterns::PatternBase>
2140 {
2142 }
2143
2144 static std::string
2146 const T &t,
2148 {
2149 std::vector<bool> mask(t.size());
2150 for (unsigned int i = 0; i < t.size(); ++i)
2151 mask[i] = t[i];
2152
2153 return Convert<std::vector<bool>>::to_string(mask, pattern);
2154 }
2155
2156 static T
2157 to_value(const std::string &s,
2159 {
2160 const auto mask = Convert<std::vector<bool>>::to_value(s, pattern);
2161 return ComponentMask(mask);
2162 }
2163 };
2164
2165 // Complex numbers
2166 template <class Number>
2167 struct Convert<std::complex<Number>>
2168 {
2169 using T = std::complex<Number>;
2170
2171 static std::unique_ptr<Patterns::PatternBase>
2173 {
2174 static_assert(internal::RankInfo<T>::list_rank > 0,
2175 "Cannot use this class for non List-compatible types.");
2176 return std::make_unique<Patterns::List>(
2178 2,
2179 2,
2181 1]);
2182 }
2183
2184 static std::string
2186 const T &t,
2188 {
2189 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
2190 AssertThrow(p,
2191 ExcMessage("I need a List pattern to convert a string "
2192 "to a List compatible type."));
2193
2194 auto base_p = p->get_base_pattern().clone();
2195 std::string s =
2197 p->get_separator() + " " +
2199
2200 AssertThrow(pattern.match(s), ExcNoMatch(s, p->description()));
2201 return s;
2202 }
2203
2207 static T
2208 to_value(const std::string &s,
2210 {
2211 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2212
2213 const auto *p = dynamic_cast<const Patterns::List *>(&pattern);
2214 AssertThrow(p,
2215 ExcMessage("I need a List pattern to convert a string "
2216 "to a List compatible type."));
2217
2218 auto base_p = p->get_base_pattern().clone();
2219
2220 auto v = Utilities::split_string_list(s, p->get_separator());
2221 AssertDimension(v.size(), 2);
2224 return t;
2225 }
2226 };
2227
2228 // Strings
2229 template <>
2230 struct Convert<std::string>
2231 {
2232 using T = std::string;
2233
2234 static std::unique_ptr<Patterns::PatternBase>
2236 {
2237 return std::make_unique<Patterns::Anything>();
2238 }
2239
2240 static std::string
2242 const T &t,
2244 {
2245 AssertThrow(pattern.match(t), ExcNoMatch(t, pattern.description()));
2246 return t;
2247 }
2248
2249 static T
2250 to_value(const std::string &s,
2252 {
2253 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2254 return s;
2255 }
2256 };
2257
2258 // Pairs
2259 template <class Key, class Value>
2260 struct Convert<std::pair<Key, Value>>
2261 {
2262 using T = std::pair<Key, Value>;
2263
2264 static std::unique_ptr<Patterns::PatternBase>
2266 {
2267 static_assert(internal::RankInfo<T>::map_rank > 0,
2268 "Cannot use this class for non Map-compatible types.");
2269 return std::make_unique<Patterns::Tuple>(
2273 }
2274
2275 static std::string
2277 const T &t,
2279 {
2280 std::tuple<Key, Value> m(t);
2281 std::string s = Convert<decltype(m)>::to_string(m, pattern);
2282 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2283 return s;
2284 }
2285
2286 static T
2287 to_value(const std::string &s,
2289 {
2290 std::tuple<Key, Value> m;
2291 m = Convert<decltype(m)>::to_value(s, pattern);
2292 return std::make_pair(std::get<0>(m), std::get<1>(m));
2293 }
2294 };
2295
2296 // Tuples
2297 template <class... Args>
2298 struct Convert<std::tuple<Args...>>
2299 {
2300 using T = std::tuple<Args...>;
2301
2302 static std::unique_ptr<Patterns::PatternBase>
2304 {
2305 static_assert(internal::RankInfo<T>::map_rank > 0,
2306 "Cannot use this class for non tuple-compatible types.");
2307 return std::make_unique<Patterns::Tuple>(
2310 }
2311
2312 static std::string
2314 const T &t,
2316 {
2317 const auto *p = dynamic_cast<const Patterns::Tuple *>(&pattern);
2318 AssertThrow(p,
2319 ExcMessage("I need a Tuple pattern to convert a tuple "
2320 "to a string."));
2321
2322 const auto string_array = Convert<T>::to_string_internal_2(t, *p);
2323 std::string str;
2324 for (unsigned int i = 0; i < string_array.size(); ++i)
2325 str +=
2326 (i != 0u ? " " + p->get_separator() + " " : "") + string_array[i];
2327 AssertThrow(p->match(str), ExcNoMatch(str, p->description()));
2328 return str;
2329 }
2330
2331 static T
2332 to_value(const std::string &s,
2334 {
2335 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
2336
2337 const auto *p = dynamic_cast<const Patterns::Tuple *>(&pattern);
2338 AssertThrow(p,
2339 ExcMessage("I need a Tuple pattern to convert a string "
2340 "to a tuple type."));
2341
2342 auto v = Utilities::split_string_list(s, p->get_separator());
2343
2344 return Convert<T>::to_value_internal_2(v, *p);
2345 }
2346
2347 private:
2348 template <std::size_t... U>
2349 static std::array<std::string, std::tuple_size<T>::value>
2351 const Patterns::Tuple &pattern,
2352 std::index_sequence<U...>)
2353 {
2354 std::array<std::string, std::tuple_size<T>::value> a = {
2356 std::get<U>(t), pattern.get_pattern(U))...}};
2357 return a;
2358 }
2359
2360 static std::array<std::string, std::tuple_size<T>::value>
2361 to_string_internal_2(const T &t, const Patterns::Tuple &pattern)
2362 {
2364 t, pattern, std::make_index_sequence<std::tuple_size<T>::value>{});
2365 }
2366
2367 template <std::size_t... U>
2368 static T
2369 to_value_internal_1(const std::vector<std::string> &s,
2370 const Patterns::Tuple &pattern,
2371 std::index_sequence<U...>)
2372 {
2373 return std::make_tuple(
2374 Convert<typename std::tuple_element<U, T>::type>::to_value(
2375 s[U], pattern.get_pattern(U))...);
2376 }
2377
2378 static T
2379 to_value_internal_2(const std::vector<std::string> &s,
2380 const Patterns::Tuple &pattern)
2381 {
2383 s, pattern, std::make_index_sequence<std::tuple_size<T>::value>{});
2384 }
2385 };
2386
2387 // Utility function with default Pattern
2388 template <typename T>
2389 std::string
2390 to_string(const T &t)
2391 {
2392 return Convert<T>::to_string(t);
2393 }
2394
2395 // Utility function with default Pattern
2396 template <typename T>
2397 void
2398 to_value(const std::string &s, T &t)
2399 {
2400 t = Convert<T>::to_value(s);
2401 }
2402 } // namespace Tools
2403} // namespace Patterns
2404
2405
2407
2408#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:1510
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1466
static const char * description_init
Definition patterns.h:1063
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1474
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1502
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1413
static const char * description_init
Definition patterns.h:1014
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1441
static std::unique_ptr< Bool > create(const std::string &description)
Definition patterns.cc:1449
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1652
static const char * description_init
Definition patterns.h:1203
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1624
static std::unique_ptr< DirectoryName > create(const std::string &description)
Definition patterns.cc:1660
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1616
static std::unique_ptr< Double > create(const std::string &description)
Definition patterns.cc:488
static const char * description_init
Definition patterns.h:368
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:480
const double lower_bound
Definition patterns.h:355
const double upper_bound
Definition patterns.h:363
static const double max_double_value
Definition patterns.h:303
static const double min_double_value
Definition patterns.h:297
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:380
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:357
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1532
static const char * description_init
Definition patterns.h:1145
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1576
static std::unique_ptr< FileName > create(const std::string &description)
Definition patterns.cc:1584
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1540
static std::unique_ptr< Integer > create(const std::string &description)
Definition patterns.cc:309
static const char * description_init
Definition patterns.h:270
const int upper_bound
Definition patterns.h:265
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:301
const int lower_bound
Definition patterns.h:257
static const int min_int_value
Definition patterns.h:195
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:240
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:218
static const int max_int_value
Definition patterns.h:202
const unsigned int max_elements
Definition patterns.h:554
static const char * description_init
Definition patterns.h:564
const unsigned int min_elements
Definition patterns.h:549
std::unique_ptr< PatternBase > pattern
Definition patterns.h:544
const std::string separator
Definition patterns.h:559
std::size_t memory_consumption() const override
Definition patterns.cc:765
static std::unique_ptr< List > create(const std::string &description)
Definition patterns.cc:774
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:713
const PatternBase & get_base_pattern() const
Definition patterns.cc:685
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:693
const std::string & get_separator() const
Definition patterns.cc:677
static const unsigned int max_int_value
Definition patterns.h:456
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:757
static std::unique_ptr< Map > create(const std::string &description)
Definition patterns.cc:983
std::unique_ptr< PatternBase > value_pattern
Definition patterns.h:693
const unsigned int min_elements
Definition patterns.h:698
const PatternBase & get_key_pattern() const
Definition patterns.cc:1038
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:879
const unsigned int max_elements
Definition patterns.h:703
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:959
const PatternBase & get_value_pattern() const
Definition patterns.cc:1046
const std::string & get_separator() const
Definition patterns.cc:1054
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:909
static const unsigned int max_int_value
Definition patterns.h:590
std::unique_ptr< PatternBase > key_pattern
Definition patterns.h:692
const std::string separator
Definition patterns.h:708
std::size_t memory_consumption() const override
Definition patterns.cc:971
static const char * description_init
Definition patterns.h:719
const std::string & get_key_value_separator() const
Definition patterns.cc:1061
const std::string key_value_separator
Definition patterns.h:714
static std::unique_ptr< MultipleSelection > create(const std::string &description)
Definition patterns.cc:1384
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1270
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1368
static const char * description_init
Definition patterns.h:972
std::size_t memory_consumption() const override
Definition patterns.cc:1375
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1333
virtual std::size_t memory_consumption() const
Definition patterns.cc:189
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:437
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:575
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:610
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:543
static std::unique_ptr< Selection > create(const std::string &description)
Definition patterns.cc:626
std::size_t memory_consumption() const override
Definition patterns.cc:617
std::string sequence
Definition patterns.h:432
virtual bool match(const std::string &test_string) const override
Definition patterns.cc:1104
std::size_t memory_consumption() const override
Definition patterns.cc:1180
static std::unique_ptr< Tuple > create(const std::string &description)
Definition patterns.cc:1189
std::vector< std::unique_ptr< PatternBase > > patterns
Definition patterns.h:878
virtual std::unique_ptr< PatternBase > clone() const override
Definition patterns.cc:1173
Tuple(const Patterns &...patterns)
const std::string separator
Definition patterns.h:883
static const char * description_init
Definition patterns.h:888
Tuple(const std::vector< std::unique_ptr< PatternBase > > &patterns, const std::string &separator=":")
Definition patterns.cc:1071
const std::string & get_separator() const
Definition patterns.cc:1245
const PatternBase & get_pattern(const unsigned int i) const
Definition patterns.cc:1237
virtual std::string description(const OutputStyle style=Machine) const override
Definition patterns.cc:1123
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
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:539
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcCommasNotAllowed(int arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:516
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr std::array< const char *, 4 > default_map_separator
Definition patterns.h:1573
constexpr int max_map_rank()
Definition patterns.h:1661
constexpr int max_list_rank()
Definition patterns.h:1646
constexpr std::array< const char *, 4 > default_list_separator
Definition patterns.h:1571
void to_value(const std::string &s, T &t)
Definition patterns.h:2398
std::string to_string(const T &t)
Definition patterns.h:2390
std::string escape(const std::string &input, const PatternBase::OutputStyle style)
Definition patterns.cc:52
std::unique_ptr< PatternBase > pattern_factory(const std::string &description)
Definition patterns.cc:137
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition utilities.cc:701
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:2139
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2157
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2145
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2045
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2051
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2060
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1801
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1774
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1845
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1875
static std::enable_if_t< std::is_same_v< Dummy, T > &&!std::is_same_v< T, bool > &&std::is_floating_point_v< T >, std::unique_ptr< Patterns::PatternBase > > to_pattern()
Definition patterns.h:1510
static T to_value(const std::string &s, const Patterns::PatternBase &p= *Convert< T >::to_pattern())
Definition patterns.h:1533
static std::enable_if_t< std::is_same_v< Dummy, T > &&!std::is_same_v< T, bool > &&std::is_integral_v< T >, std::unique_ptr< Patterns::PatternBase > > to_pattern()
Definition patterns.h:1499
static std::enable_if_t< std::is_same_v< Dummy, T > &&std::is_same_v< T, bool >, std::unique_ptr< Patterns::PatternBase > > to_pattern()
Definition patterns.h:1489
static std::string to_string(const T &value, const Patterns::PatternBase &p= *Convert< T >::to_pattern())
Definition patterns.h:1517
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:1978
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2016
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1991
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:1911
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1951
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:1924
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2172
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2208
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2185
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2265
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2287
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2276
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2235
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2250
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2241
static T to_value_internal_2(const std::vector< std::string > &s, const Patterns::Tuple &pattern)
Definition patterns.h:2379
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2332
static std::array< std::string, std::tuple_size< T >::value > to_string_internal_2(const T &t, const Patterns::Tuple &pattern)
Definition patterns.h:2361
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2303
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:2350
static T to_value_internal_1(const std::vector< std::string > &s, const Patterns::Tuple &pattern, std::index_sequence< U... >)
Definition patterns.h:2369
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2313
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition patterns.h:2074
static T to_value(const std::string &s, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2110
static std::string to_string(const T &t, const Patterns::PatternBase &pattern= *Convert< T >::to_pattern())
Definition patterns.h:2088
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:1476
static constexpr int map_rank
Definition patterns.h:1477
static constexpr const bool value
Definition patterns.h:1630
static constexpr const bool value
Definition patterns.h:1637