@@ -41,49 +41,6 @@ static std::string build_repetition(const std::string & item_rule, int min_items
41
41
return result;
42
42
}
43
43
44
- /* Minimalistic replacement for std::string_view, which is only available from C++17 onwards */
45
- class string_view {
46
- const std::string & _str;
47
- const size_t _start;
48
- const size_t _end;
49
- public:
50
- string_view (const std::string & str, size_t start = 0 , size_t end = std::string::npos) : _str(str), _start(start), _end(end == std::string::npos ? str.length() : end) {}
51
-
52
- size_t size () const {
53
- return _end - _start;
54
- }
55
-
56
- size_t length () const {
57
- return size ();
58
- }
59
-
60
- operator std::string () const {
61
- return str ();
62
- }
63
-
64
- std::string str () const {
65
- return _str.substr (_start, _end - _start);
66
- }
67
-
68
- string_view substr (size_t pos, size_t len = std::string::npos) const {
69
- return string_view (_str, _start + pos, len == std::string::npos ? _end : _start + pos + len);
70
- }
71
-
72
- char operator [](size_t pos) const {
73
- auto index = _start + pos;
74
- if (index >= _end) {
75
- throw std::out_of_range (" string_view index out of range" );
76
- }
77
- return _str[_start + pos];
78
- }
79
-
80
- bool operator ==(const string_view & other) const {
81
- std::string this_str = *this ;
82
- std::string other_str = other;
83
- return this_str == other_str;
84
- }
85
- };
86
-
87
44
static void _build_min_max_int (int min_value, int max_value, std::stringstream & out, int decimals_left = 16 , bool top_level = true ) {
88
45
auto has_min = min_value != std::numeric_limits<int >::min ();
89
46
auto has_max = max_value != std::numeric_limits<int >::max ();
@@ -112,14 +69,14 @@ static void _build_min_max_int(int min_value, int max_value, std::stringstream &
112
69
}
113
70
out << " }" ;
114
71
};
115
- std::function<void (const string_view &, const string_view &)> uniform_range =
116
- [&](const string_view & from, const string_view & to) {
72
+ std::function<void (const std:: string_view &, const std:: string_view &)> uniform_range =
73
+ [&](const std:: string_view & from, const std:: string_view & to) {
117
74
size_t i = 0 ;
118
75
while (i < from.length () && i < to.length () && from[i] == to[i]) {
119
76
i++;
120
77
}
121
78
if (i > 0 ) {
122
- out << " \" " << from.substr (0 , i). str () << " \" " ;
79
+ out << " \" " << from.substr (0 , i) << " \" " ;
123
80
}
124
81
if (i < from.length () && i < to.length ()) {
125
82
if (i > 0 ) {
0 commit comments