Awali
Another Weighted Automata library
node.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_JSON_NODE_HH
18 #define AWALI_JSON_NODE_HH
19 
22 #include<vector>
23 #include<unordered_map>
24 #include<cmath>
25 #include<memory>
26 
27 namespace awali {
28 namespace json {
29 
30 
31 /* =============================================================================
32  Forward declarations
33 ============================================================================= */
34 
35 class node_t;
36 class object_t;
37 class array_t;
38 class int_t;
39 class float_t;
40 class string_t;
41 class bool_t;
42 class null_t;
43 class parser_t;
44 
45 /* =============================================================================
46  uint_or_string and navigation path
47 ============================================================================= */
49 protected:
50  long i;
51  std::string str;
52 public:
53  uint_or_string_t(unsigned integer) : i(integer), str("") {}
54 
55  uint_or_string_t(std::string s) : i(-1), str(std::move(s)) {}
56 
58  : i(uos.i), str(uos.str) {}
59 
61  : i(uos.i), str(std::move(uos.str)) {}
62 
63  uint_or_string_t(char const* s) : i(-1), str(s?s:"") {}
64 
65  inline bool is_string() const {return i<0;}
66 
67  inline bool is_integer() const {return i>=0;}
68 
69  inline unsigned integer() const {return i;}
70 
71  inline std::string const& string() const {return str;}
72 
73 
74  inline operator std::string&() {return str;}
75  inline operator std::string() const {return str;}
76  inline operator unsigned() const {return i;}
77 
79  { if (this != &uos) { i = uos.i; str = uos.str;} return *this;}
80 
82  { i = uos.i, str = std::move(uos.str); return *this;}
83 };
84 
85 typedef std::vector<uint_or_string_t> path_t;
86 
87 
88 
89 /* =============================================================================
90  NODE KIND
91 ============================================================================= */
93  OBJECT = 0,
94  ARRAY = 1,
95  INTEGER = 2,
96  FLOATING = 3,
97  STRING = 4,
98  BOOLEAN = 5,
99  _NULL = 6
100 };
101 
102 std::string const& string_of(node_kind_t kind);
103 
104 std::ostream& operator<<(std::ostream& o, node_kind_t kind);
105 
106 /* =============================================================================
107  EXCEPTIONS
108 ============================================================================= */
109 
110 class exception : public std::exception {
111 public:
112  std::string message;
113  std::string caller;
114  node_t const* node;
117  std::string what_msg;
118 
119  exception(std::string const& message, std::string const& caller,
120  path_t path_to_root, int line, int col);
121 
122  exception(std::string const& message, std::string const& caller,
123  node_t const* node = nullptr);
124 
125  exception(std::string message, node_t const* node = nullptr)
126  : exception(message, "", node) {}
127 
128  virtual const char* what() const noexcept override
129  {return what_msg.c_str();}
130 };
131 
132 class parse_exception: public exception {
133 public:
134  parse_exception(std::string const& message, std::string const& caller,
135  path_t path_to_root, int line, int col):
136  exception(message, caller, path_to_root, line, col) {}
137  parse_exception(std::string const& message, std::string const& caller):
139 };
140 
141 
144 public:
145  coercion_exception(std::string const& message, std::string const& caller,
146  node_t const* node = nullptr)
147  : exception(message, caller, node) {}
148 
149  coercion_exception(std::string message, node_t const* node = nullptr)
150  : coercion_exception(message, "", node) {}
151 };
152 
153 
154 class out_of_range : public exception {
155 public:
156  out_of_range(std::string const& message, std::string const& caller,
157  node_t const* node = nullptr)
159  {}
160 
161  out_of_range(std::string const& message, node_t const* node = nullptr)
162  : out_of_range(message, "", node)
163  {}
164 };
165 
166 
167 
168 class kind_mismatch : public exception {
169 public:
170  std::vector<node_kind_t> expected_types;
171  kind_mismatch(std::string const& caller, node_t const* node,
172  node_kind_t expected_type)
173  : kind_mismatch(caller, node, {expected_type}){}
174 
175  kind_mismatch(std::string const& caller, node_t const* node,
176  std::initializer_list<node_kind_t> types);
177 
178 
179 protected:
180  static std::string message_builder(node_kind_t caller_kind,
181  std::initializer_list<node_kind_t> types);
182 
183 };
184 
185 
186 
187 
188 
189 /* =============================================================================
190  node_t
191 ============================================================================= */
192 
193 class node_t {
194 public:
195  node_t const* parent;
197 
198 // static node_t* parse(std::istream& i);
199 
200  virtual ~node_t() {}
201 
203  virtual inline object_t const* object() const
204  {throw kind_mismatch("node_t::object()", this, node_kind_t::OBJECT);}
205 
207  virtual inline array_t const* array() const
208  {throw kind_mismatch("node_t::array()", this, node_kind_t::ARRAY);}
209 
211  virtual inline int_t const* integer() const
212  {throw kind_mismatch("node_t::integer()", this, node_kind_t::INTEGER);}
213 
215  virtual inline string_t const* string() const
216  {throw kind_mismatch("node_t::string()", this, node_kind_t::STRING);}
217 
219  virtual inline float_t const* floating() const
220  {throw kind_mismatch("node_t::floating()", this, node_kind_t::FLOATING);}
221 
223  virtual inline bool_t const* boolean() const
224  {throw kind_mismatch("node_t::boolean()", this, node_kind_t::BOOLEAN);}
225 
227  virtual inline null_t const* null() const
228  {throw kind_mismatch("node_t::null()", this, node_kind_t::_NULL);}
229 
231  virtual inline object_t* object()
232  {throw kind_mismatch("node_t::object()", this, node_kind_t::OBJECT);}
233 
235  virtual inline array_t* array()
236  {throw kind_mismatch("node_t::array()", this, node_kind_t::ARRAY);}
237 
239  virtual inline int_t* integer()
240  {throw kind_mismatch("node_t::integer()", this, node_kind_t::INTEGER);}
241 
243  virtual inline string_t* string()
244  {throw kind_mismatch("node_t::string()", this, node_kind_t::STRING);}
245 
247  virtual inline float_t* floating()
248  {throw kind_mismatch("node_t::floating()", this, node_kind_t::FLOATING);}
249 
251  virtual inline bool_t* boolean()
252  {throw kind_mismatch("node_t::boolean()", this, node_kind_t::BOOLEAN);}
253 
255  virtual inline null_t* null()
256  {throw kind_mismatch("node_t::null()", this, node_kind_t::_NULL);}
257 
258  virtual node_t* copy() const =0;
259 
260  node_t* at_path(path_t const& path, unsigned i = 0);
261  node_t const* at_path(path_t const& path, unsigned i = 0) const;
262  bool has_path(json::path_t const& path) const;
263 
264  inline virtual unsigned height() const {return 0;}
265 
266 // template<typename T2, typename... Args>
267 // node_t* at(std::string const& str, T2 arg2, Args... args) {
268 // return this->at(str)->at(arg2, args...);
269 // }
270 
271 // template<typename T2, typename... Args>
272 // bool has_path(std::string const& str, T2 arg2, Args... args) const {
273 // if (!this->has_child(str))
274 // return false;
275 // return this->at(str)->has_path(arg2, args...);
276 // }
277 
278  //node_t* at(std::initializer_list<std::string> const&);
279  //node_t const* at(std::initializer_list<std::string> const&) const;
280  //bool has_child(std::initializer_list<std::string> const&l) const;
281 
282  virtual node_t* at(std::string const& key);
283  virtual node_t const* at(std::string const& key) const;
284  inline virtual bool has_child(std::string const&) const
285  {return false;}
286 
287 
288  //node_t const* at(std::initializer_list<unsigned> const&) const;
289  virtual node_t* at(unsigned i);
290  virtual node_t const* at(unsigned i) const;
291  inline virtual bool has_child(unsigned) const
292  {return false;}
293  //inline virtual bool has_child(std::initializer_list<unsigned> const& l) const
294  //{node_t const* n = this; for (auto x : l) if (n->has_child(x)) n = n->at(x); else return false; return true;}
295 
296 
306  virtual inline bool to_bool() const
307  {throw kind_mismatch("node_t::to_bool()", this,
310 
311 
321  virtual inline int to_int() const
322  {throw kind_mismatch("node_t::to_int()", this,
325 
326 
331  virtual std::string to_string() const
332  {throw kind_mismatch("node_t::to_string()", this, node_kind_t::STRING);}
333 
334 
343  virtual double to_double() const
344  {throw kind_mismatch("node_t::to_double()", this,
347 
348 
349  inline bool is(node_kind_t k) const {return (this-> kind == k);}
350  inline bool is(std::vector<node_kind_t>const& v) const
351  {for(auto k:v) if (this->is(k)) return true; return false;}
352 
353  inline bool is_leaf() const {return !this->is({OBJECT,ARRAY});}
354 
355  virtual inline unsigned arity() const {return 0u;}
356 
358 
359 protected:
360  node_t(node_kind_t k) : parent(nullptr), kind(k) {}
361 };
362 
363 
364 /* =============================================================================
365  OBJECT
366 ============================================================================= */
367 class object_t final : public node_t {
369 public:
373 
374  object_t() : node_t(node_kind_t::OBJECT), _fields(), fields(_fields) {}
375  object_t(std::string key, node_t* child) : object_t()
376  {this->push_back(std::move(key),child);}
377 
379 
380  inline virtual bool has_child(std::string const& key) const override
381  {return fields.find(key) != fields.end(); }
382 
383  virtual node_t* at(std::string const& key) override;
384 
385  virtual node_t const* at(std::string const& key) const override;
386 
387  object_t* push_back(std::string key, node_t* node);
388 
389  object_t* push_front(std::string key, node_t* node);
390 
391  object_t* insert_after(std::string const& ref_key,
392  std::string key, node_t* node);
393 
394  object_t* insert_before(std::string const& ref_key,
395  std::string key, node_t* node);
396 
397  inline void erase(std::string const& key) {
398  auto it = _fields.find(key);
399  if (it != _fields.end())
400  delete it->second;
401  _fields.erase(it);
402  }
403 
404  inline virtual object_t* object() override {return this;}
405  inline virtual object_t const* object() const override {return this;}
406 
407  virtual object_t* copy() const override ;
408 
409  inline virtual unsigned height() const override {
410  unsigned d = 0;
411  for (auto p : fields) {
412  unsigned x = p.second->height() + 1;
413  if (x > d)
414  d = x;
415  }
416  return d;
417  }
418 
419  inline iterator begin() {return _fields.begin();}
420  inline iterator end() {return _fields.end();}
421  inline const_iterator begin() const {return fields.begin();}
422  inline const_iterator end() const {return fields.end();}
423 
424  inline virtual unsigned arity() const override {return fields.size();}
425 };
426 
427 
428 /* =============================================================================
429  ARRAY
430 ============================================================================= */
431 class array_t final : public node_t {
432 protected:
433  std::vector<node_t*> _values;
434 
435 public:
436  std::vector<node_t*> const& values;
437 
438  typedef std::vector<node_t*>::iterator iterator;
439  typedef std::vector<node_t*>::const_iterator const_iterator;
440 
442  array_t(std::vector<node_t*> v)
443  : node_t(node_kind_t::ARRAY), _values(std::move(v)), values(_values) {}
444 
446 
447  inline virtual array_t* array() override {return this;}
448  inline virtual array_t const* array() const override {return this;}
449 
450  virtual array_t* copy() const override;
451 
452 
453  virtual node_t* at(unsigned i) override;
454 
455  virtual node_t const* at(unsigned i) const override;
456 
457  inline iterator begin() {return _values.begin();}
458  inline const_iterator begin() const {return values.begin();}
459 
460  inline iterator end() {return _values.end();}
461  inline const_iterator end() const {return values.end();}
462 
464 
465  inline unsigned arity() const override {return values.size();}
466 
467  inline unsigned empty() const {return arity() == 0;}
468 
469 
470  inline virtual bool has_child(unsigned i) const override
471  {return i < arity();}
472 
473  inline virtual unsigned height() const override {
474  unsigned d = 0;
475  for (auto p : values) {
476  unsigned x = p->height()+1;
477  if (x > d)
478  d = x;
479  }
480  return d;
481  }
482 };
483 
484 
485 /* =============================================================================
486  INTEGER
487 ============================================================================= */
488 class int_t final : public node_t {
489 public:
490  int value;
491 
493 
494  inline virtual int_t* copy() const override {return new int_t(value);}
495 
496  inline virtual int_t* integer() override {return this;}
497  inline virtual int_t const* integer() const override {return this;}
498 
499  virtual bool to_bool() const override;
500  virtual inline int to_int() const override {return value;}
501  virtual inline double to_double() const override {return value;}
502 };
503 
504 
505 /* =============================================================================
506  FLOATING
507 ============================================================================= */
508 class float_t final : public node_t {
509 public:
510  double value;
511 
512  float_t(double v) : node_t(node_kind_t::FLOATING), value(v) {}
513 
514  inline virtual float_t* copy() const override
515  {return new float_t(value);}
516 
517  inline virtual float_t* floating() override {return this;}
518  inline virtual float_t const* floating() const override {return this;}
519 
520  virtual bool to_bool() const override;
521  virtual int to_int() const override;
522  virtual inline double to_double() const override {return value;}
523 };
524 
525 
526 /* =============================================================================
527  STRING
528 ============================================================================= */
529 class string_t final : public node_t {
530 public:
531  std::string value;
532 
533  string_t(char c)
534  : node_t(node_kind_t::STRING), value(1,c) {}
535 
536  string_t(std::string v)
537  : node_t(node_kind_t::STRING), value(std::move(v)) {}
538 
539  inline virtual string_t* copy() const override
540  {return new string_t(value);}
541 
542  inline virtual string_t* string() override {return this;}
543  inline virtual string_t const* string() const override {return this;}
544 
545  virtual bool to_bool() const override;
546  virtual int to_int() const override;
547  virtual double to_double() const override;
548  virtual inline std::string to_string() const override {return this->value;}
549 };
550 
551 
552 /* =============================================================================
553  BOOLEAN
554 ============================================================================= */
555 class bool_t final : public node_t {
556 public:
557  bool value;
558 
559  bool_t(bool v) : node_t(node_kind_t::BOOLEAN), value(v) {}
560 
561  inline virtual bool_t* copy() const override
562  {return new bool_t(value);}
563 
564  inline virtual bool_t* boolean() override {return this;};
565  inline virtual bool_t const* boolean() const override {return this;};
566 
567 
568  virtual inline bool to_bool() const override {return this->value;}
569  virtual inline int to_int() const override {return this->value;}
570  virtual inline double to_double() const override {return this->value;}
571 
572 };
573 
574 
575 /* =============================================================================
576  NULL
577 ============================================================================= */
578 class null_t final : public node_t {
579 public:
581 
582  inline virtual null_t* copy() const override {return new null_t();}
583 
584  inline virtual null_t* null() override {return this;}
585 
586  inline virtual null_t const* null() const override {return this;}
587 };
588 
589 
590 
591 }// end of namespace awali::json
592 
593 
594 
595 }// end of namespace awali
596 
597 namespace std {
598 std::ostream& operator<<(std::ostream& o, awali::json::uint_or_string_t const& uos);
599 std::ostream& operator<<(std::ostream& o, awali::json::path_t const& path);
600 }
601 
602 #endif
Definition: node.hh:431
virtual node_t * at(unsigned i) override
const_iterator begin() const
Definition: node.hh:458
virtual unsigned height() const override
Definition: node.hh:473
const_iterator end() const
Definition: node.hh:461
virtual node_t const * at(unsigned i) const override
std::vector< node_t * >::iterator iterator
Definition: node.hh:438
array_t * push_back(node_t *p)
array_t()
Definition: node.hh:441
virtual array_t * array() override
Casts this node to array_t.
Definition: node.hh:447
iterator end()
Definition: node.hh:460
array_t(std::vector< node_t * > v)
Definition: node.hh:442
virtual array_t * copy() const override
unsigned arity() const override
Definition: node.hh:465
std::vector< node_t * > _values
Definition: node.hh:433
virtual bool has_child(unsigned i) const override
Definition: node.hh:470
iterator begin()
Definition: node.hh:457
std::vector< node_t * >::const_iterator const_iterator
Definition: node.hh:439
virtual array_t const * array() const override
Casts this node to array_t.
Definition: node.hh:448
std::vector< node_t * > const & values
Definition: node.hh:436
unsigned empty() const
Definition: node.hh:467
Definition: node.hh:555
bool value
Definition: node.hh:557
virtual bool to_bool() const override
Coerces this node_t to bool.
Definition: node.hh:568
bool_t(bool v)
Definition: node.hh:559
virtual bool_t * boolean() override
Casts this node to bool_t.
Definition: node.hh:564
virtual bool_t const * boolean() const override
Casts this node to bool_t.
Definition: node.hh:565
virtual double to_double() const override
Coerces this node_t to a double
Definition: node.hh:570
virtual int to_int() const override
Coerces this node_t to int.
Definition: node.hh:569
virtual bool_t * copy() const override
Definition: node.hh:561
Exception used when trying to coerce a node to a given type.
Definition: node.hh:143
coercion_exception(std::string const &message, std::string const &caller, node_t const *node=nullptr)
Definition: node.hh:145
coercion_exception(std::string message, node_t const *node=nullptr)
Definition: node.hh:149
Definition: node.hh:110
exception(std::string message, node_t const *node=nullptr)
Definition: node.hh:125
node_t const * node
Definition: node.hh:114
virtual const char * what() const noexcept override
Definition: node.hh:128
exception(std::string const &message, std::string const &caller, node_t const *node=nullptr)
exception(std::string const &message, std::string const &caller, path_t path_to_root, int line, int col)
std::string caller
Definition: node.hh:113
std::string what_msg
Definition: node.hh:117
node_t * attempted_parsed_tree
Definition: node.hh:115
path_t path_to_root
Definition: node.hh:116
std::string message
Definition: node.hh:112
Definition: node.hh:508
virtual float_t * floating() override
Casts this not to float_t.
Definition: node.hh:517
double value
Definition: node.hh:510
virtual double to_double() const override
Coerces this node_t to a double
Definition: node.hh:522
float_t(double v)
Definition: node.hh:512
virtual int to_int() const override
Coerces this node_t to int.
virtual float_t * copy() const override
Definition: node.hh:514
virtual float_t const * floating() const override
Casts this not to float_t.
Definition: node.hh:518
virtual bool to_bool() const override
Coerces this node_t to bool.
Definition: node.hh:488
virtual bool to_bool() const override
Coerces this node_t to bool.
virtual int_t * integer() override
Casts this node to int_t.
Definition: node.hh:496
virtual int to_int() const override
Coerces this node_t to int.
Definition: node.hh:500
int value
Definition: node.hh:490
virtual int_t * copy() const override
Definition: node.hh:494
virtual int_t const * integer() const override
Casts this node to int_t.
Definition: node.hh:497
virtual double to_double() const override
Coerces this node_t to a double
Definition: node.hh:501
int_t(int v)
Definition: node.hh:492
Definition: node.hh:168
std::vector< node_kind_t > expected_types
Definition: node.hh:170
static std::string message_builder(node_kind_t caller_kind, std::initializer_list< node_kind_t > types)
kind_mismatch(std::string const &caller, node_t const *node, std::initializer_list< node_kind_t > types)
kind_mismatch(std::string const &caller, node_t const *node, node_kind_t expected_type)
Definition: node.hh:171
Definition: node.hh:193
bool is(node_kind_t k) const
Definition: node.hh:349
node_t const * parent
Definition: node.hh:195
virtual float_t const * floating() const
Casts this not to float_t.
Definition: node.hh:219
virtual node_t * at(std::string const &key)
node_t * at_path(path_t const &path, unsigned i=0)
virtual bool_t const * boolean() const
Casts this node to bool_t.
Definition: node.hh:223
path_t path_to_root() const
virtual double to_double() const
Coerces this node_t to a double
Definition: node.hh:343
virtual std::string to_string() const
Coerces this node_t to an std::string.
Definition: node.hh:331
virtual node_t * at(unsigned i)
bool is(std::vector< node_kind_t >const &v) const
Definition: node.hh:350
virtual node_t const * at(unsigned i) const
virtual array_t * array()
Casts this node to array_t.
Definition: node.hh:235
bool has_path(json::path_t const &path) const
virtual int_t const * integer() const
Casts this node to int_t.
Definition: node.hh:211
virtual int to_int() const
Coerces this node_t to int.
Definition: node.hh:321
node_t const * at_path(path_t const &path, unsigned i=0) const
virtual unsigned height() const
Definition: node.hh:264
virtual string_t * string()
Casts this node to string_t.
Definition: node.hh:243
virtual bool to_bool() const
Coerces this node_t to bool.
Definition: node.hh:306
virtual float_t * floating()
Casts this not to float_t.
Definition: node.hh:247
virtual string_t const * string() const
Casts this node to string_t.
Definition: node.hh:215
virtual ~node_t()
Definition: node.hh:200
virtual bool has_child(std::string const &) const
Definition: node.hh:284
virtual node_t const * at(std::string const &key) const
virtual object_t * object()
Casts this node to object_t.
Definition: node.hh:231
virtual object_t const * object() const
Casts this node to object_t.
Definition: node.hh:203
node_kind_t const kind
Definition: node.hh:196
node_t(node_kind_t k)
Definition: node.hh:360
virtual node_t * copy() const =0
virtual bool has_child(unsigned) const
Definition: node.hh:291
virtual unsigned arity() const
Definition: node.hh:355
virtual bool_t * boolean()
Casts this node to bool_t.
Definition: node.hh:251
virtual int_t * integer()
Casts this node to int_t.
Definition: node.hh:239
bool is_leaf() const
Definition: node.hh:353
virtual array_t const * array() const
Casts this node to array_t.
Definition: node.hh:207
Definition: node.hh:578
null_t()
Definition: node.hh:580
virtual null_t * copy() const override
Definition: node.hh:582
Definition: node.hh:367
const_iterator end() const
Definition: node.hh:422
virtual bool has_child(std::string const &key) const override
Definition: node.hh:380
linked_map_t< std::string, node_t * >::const_iterator const_iterator
Definition: node.hh:372
iterator begin()
Definition: node.hh:419
object_t(std::string key, node_t *child)
Definition: node.hh:375
virtual node_t * at(std::string const &key) override
object_t * insert_after(std::string const &ref_key, std::string key, node_t *node)
object_t * push_back(std::string key, node_t *node)
virtual object_t * object() override
Casts this node to object_t.
Definition: node.hh:404
object_t()
Definition: node.hh:374
iterator end()
Definition: node.hh:420
virtual unsigned height() const override
Definition: node.hh:409
const_iterator begin() const
Definition: node.hh:421
void erase(std::string const &key)
Definition: node.hh:397
virtual object_t const * object() const override
Casts this node to object_t.
Definition: node.hh:405
linked_map_t< std::string, node_t * >::iterator iterator
Definition: node.hh:371
virtual object_t * copy() const override
object_t * insert_before(std::string const &ref_key, std::string key, node_t *node)
object_t * push_front(std::string key, node_t *node)
virtual node_t const * at(std::string const &key) const override
virtual unsigned arity() const override
Definition: node.hh:424
linked_map_t< std::string, node_t * > const & fields
Definition: node.hh:370
Definition: node.hh:154
out_of_range(std::string const &message, node_t const *node=nullptr)
Definition: node.hh:161
out_of_range(std::string const &message, std::string const &caller, node_t const *node=nullptr)
Definition: node.hh:156
Definition: node.hh:132
parse_exception(std::string const &message, std::string const &caller, path_t path_to_root, int line, int col)
Definition: node.hh:134
parse_exception(std::string const &message, std::string const &caller)
Definition: node.hh:137
Definition: node.hh:529
virtual int to_int() const override
Coerces this node_t to int.
virtual std::string to_string() const override
Coerces this node_t to an std::string.
Definition: node.hh:548
virtual bool to_bool() const override
Coerces this node_t to bool.
std::string value
Definition: node.hh:531
virtual string_t * string() override
Casts this node to string_t.
Definition: node.hh:542
virtual string_t * copy() const override
Definition: node.hh:539
virtual double to_double() const override
Coerces this node_t to a double
virtual string_t const * string() const override
Casts this node to string_t.
Definition: node.hh:543
string_t(std::string v)
Definition: node.hh:536
string_t(char c)
Definition: node.hh:533
Definition: node.hh:48
uint_or_string_t & operator=(uint_or_string_t const &uos)
Definition: node.hh:78
unsigned integer() const
Definition: node.hh:69
uint_or_string_t(std::string s)
Definition: node.hh:55
uint_or_string_t(char const *s)
Definition: node.hh:63
bool is_string() const
Definition: node.hh:65
std::string str
Definition: node.hh:51
uint_or_string_t(uint_or_string_t const &uos)
Definition: node.hh:57
long i
Definition: node.hh:50
uint_or_string_t(unsigned integer)
Definition: node.hh:53
std::string const & string() const
Definition: node.hh:71
bool is_integer() const
Definition: node.hh:67
uint_or_string_t & operator=(uint_or_string_t &&uos)
Definition: node.hh:81
uint_or_string_t(uint_or_string_t &&uos)
Definition: node.hh:60
Implemention of a linked hash-map.
Definition: linked_map.hxx:72
std::list< pair_t >::iterator iterator
Definition: linked_map.hxx:81
std::list< pair_t >::const_iterator const_iterator
Definition: linked_map.hxx:82
std::ostream & json(automaton_t aut, std::ostream &out)
std::vector< uint_or_string_t > path_t
Definition: node.hh:85
std::string const & string_of(node_kind_t kind)
std::ostream & operator<<(std::ostream &o, node_kind_t kind)
node_kind_t
Definition: node.hh:92
@ OBJECT
Definition: node.hh:93
@ INTEGER
Definition: node.hh:95
@ ARRAY
Definition: node.hh:94
@ BOOLEAN
Definition: node.hh:98
@ STRING
Definition: node.hh:97
@ FLOATING
Definition: node.hh:96
@ _NULL
Definition: node.hh:99
Main namespace of Awali.
Definition: ato.hh:22