JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
IOrigin.h
Go to the documentation of this file.
1 //
2 // Created by Nico Schäfer on 30/07/18.
3 //
4 
5 #ifndef JODA_IORIGIN_H
6 #define JODA_IORIGIN_H
7 
8 #include <glog/logging.h>
9 
10 #include <boost/operators.hpp>
11 #include <memory>
12 
13 #include "joda/misc/RJFwd.h"
14 
21 class IOrigin {
22  public:
23  virtual ~IOrigin() = default;
24 
29  virtual bool isReparsable() const { return false; }
30 
35  virtual std::string toString() const = 0;
36 
43  virtual std::unique_ptr<RJDocument> reparse(RJMemoryPoolAlloc &alloc) const {
44  DCHECK(isReparsable())
45  << "Origin not reparsable, should be checked before calling function";
46  return nullptr;
47  }
48 
53  virtual std::unique_ptr<IOrigin> clone() const = 0;
54 
55  /*
56  * Change
57  */
58  virtual bool operator<(const IOrigin &x) const {
59  return typeid(*this).before(typeid(x));
60  };
61 
62  bool operator==(const IOrigin &x) const {
63  return false;
64  };
65 
66 
67  /*
68  * Keep
69  */
70  virtual bool operator<=(const IOrigin &x) const {
71  return (*this < x) || (*this == x);
72  };
73 
74  virtual bool operator>(const IOrigin &x) const { return x < *this; };
75 
76  virtual bool operator>=(const IOrigin &x) const { return x <= *this; };
77 
78 
79  protected:
80 };
81 
82 #endif // JODA_IORIGIN_H
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
Definition: IOrigin.h:21
virtual bool operator>(const IOrigin &x) const
Definition: IOrigin.h:74
virtual bool operator>=(const IOrigin &x) const
Definition: IOrigin.h:76
virtual std::unique_ptr< RJDocument > reparse(RJMemoryPoolAlloc &alloc) const
Definition: IOrigin.h:43
virtual bool operator<(const IOrigin &x) const
Definition: IOrigin.h:58
virtual std::unique_ptr< IOrigin > clone() const =0
virtual std::string toString() const =0
virtual bool isReparsable() const
Definition: IOrigin.h:29
bool operator==(const IOrigin &x) const
Definition: IOrigin.h:62
virtual ~IOrigin()=default
virtual bool operator<=(const IOrigin &x) const
Definition: IOrigin.h:70