From e02e3d57dc090c8fd333812b84e91805921e398c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 21 Jan 2017 18:51:41 -0500 Subject: Moved some generator classes into the main namespace --- lib/selrestr.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lib/selrestr.h (limited to 'lib/selrestr.h') diff --git a/lib/selrestr.h b/lib/selrestr.h new file mode 100644 index 0000000..9f82e3e --- /dev/null +++ b/lib/selrestr.h @@ -0,0 +1,90 @@ +#ifndef SELRESTR_H_50652FB7 +#define SELRESTR_H_50652FB7 + +#include +#include +#include "../vendor/json/json.hpp" + +namespace verbly { + + class selrestr { + public: + enum class type { + empty, + singleton, + group + }; + + // Construct from json + + explicit selrestr(nlohmann::json json); + + // Copy and move constructors + + selrestr(const selrestr& other); + selrestr(selrestr&& other); + + // Assignment + + selrestr& operator=(selrestr other); + + // Swap + + friend void swap(selrestr& first, selrestr& second); + + // Destructor + + ~selrestr(); + + // Generic accessors + + type getType() const + { + return type_; + } + + // Empty + + selrestr(); + + // Singleton + + selrestr(std::string restriction, bool pos); + + std::string getRestriction() const; + + bool getPos() const; + + // Group + + selrestr(std::list children, bool orlogic); + + std::list getChildren() const; + + std::list::const_iterator begin() const; + + std::list::const_iterator end() const; + + bool getOrlogic() const; + + // Helpers + + nlohmann::json toJson() const; + + private: + union { + struct { + bool pos; + std::string restriction; + } singleton_; + struct { + std::list children; + bool orlogic; + } group_; + }; + type type_; + }; + +}; + +#endif /* end of include guard: SELRESTR_H_50652FB7 */ -- cgit 1.4.1