diff options
Diffstat (limited to 'generator/selrestr.h')
| -rw-r--r-- | generator/selrestr.h | 88 |
1 files changed, 88 insertions, 0 deletions
| diff --git a/generator/selrestr.h b/generator/selrestr.h new file mode 100644 index 0000000..5000970 --- /dev/null +++ b/generator/selrestr.h | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | #ifndef SELRESTR_H_50652FB7 | ||
| 2 | #define SELRESTR_H_50652FB7 | ||
| 3 | |||
| 4 | #include <list> | ||
| 5 | #include <string> | ||
| 6 | #include <json.hpp> | ||
| 7 | |||
| 8 | namespace verbly { | ||
| 9 | namespace generator { | ||
| 10 | |||
| 11 | class selrestr { | ||
| 12 | public: | ||
| 13 | enum class type { | ||
| 14 | empty, | ||
| 15 | singleton, | ||
| 16 | group | ||
| 17 | }; | ||
| 18 | |||
| 19 | // Copy and move constructors | ||
| 20 | |||
| 21 | selrestr(const selrestr& other); | ||
| 22 | selrestr(selrestr&& other); | ||
| 23 | |||
| 24 | // Assignment | ||
| 25 | |||
| 26 | selrestr& operator=(selrestr other); | ||
| 27 | |||
| 28 | // Swap | ||
| 29 | |||
| 30 | friend void swap(selrestr& first, selrestr& second); | ||
| 31 | |||
| 32 | // Destructor | ||
| 33 | |||
| 34 | ~selrestr(); | ||
| 35 | |||
| 36 | // Generic accessors | ||
| 37 | |||
| 38 | type getType() const | ||
| 39 | { | ||
| 40 | return type_; | ||
| 41 | } | ||
| 42 | |||
| 43 | // Empty | ||
| 44 | |||
| 45 | selrestr(); | ||
| 46 | |||
| 47 | // Singleton | ||
| 48 | |||
| 49 | selrestr(std::string restriction, bool pos); | ||
| 50 | |||
| 51 | std::string getRestriction() const; | ||
| 52 | |||
| 53 | bool getPos() const; | ||
| 54 | |||
| 55 | // Group | ||
| 56 | |||
| 57 | selrestr(std::list<selrestr> children, bool orlogic); | ||
| 58 | |||
| 59 | std::list<selrestr> getChildren() const; | ||
| 60 | |||
| 61 | std::list<selrestr>::const_iterator begin() const; | ||
| 62 | |||
| 63 | std::list<selrestr>::const_iterator end() const; | ||
| 64 | |||
| 65 | bool getOrlogic() const; | ||
| 66 | |||
| 67 | // Helpers | ||
| 68 | |||
| 69 | nlohmann::json toJson() const; | ||
| 70 | |||
| 71 | private: | ||
| 72 | union { | ||
| 73 | struct { | ||
| 74 | bool pos; | ||
| 75 | std::string restriction; | ||
| 76 | } singleton_; | ||
| 77 | struct { | ||
| 78 | std::list<selrestr> children; | ||
| 79 | bool orlogic; | ||
| 80 | } group_; | ||
| 81 | }; | ||
| 82 | type type_; | ||
| 83 | }; | ||
| 84 | |||
| 85 | }; | ||
| 86 | }; | ||
| 87 | |||
| 88 | #endif /* end of include guard: SELRESTR_H_50652FB7 */ | ||
