From e1fa4a088dd95caef22045f905a9d5d22b71bef0 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 24 Jan 2017 21:50:39 -0500 Subject: Whitespace changes --- lib/selrestr.cpp | 102 +++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'lib/selrestr.cpp') diff --git a/lib/selrestr.cpp b/lib/selrestr.cpp index 74ea726..8646871 100644 --- a/lib/selrestr.cpp +++ b/lib/selrestr.cpp @@ -1,7 +1,7 @@ #include "selrestr.h" namespace verbly { - + selrestr::selrestr(nlohmann::json data) { if (data.find("children") != data.end()) @@ -13,7 +13,7 @@ namespace verbly { { group_.children.emplace_back(child); } - + group_.orlogic = (data["logic"] == "or"); } else if (data.find("type") != data.end()) { @@ -24,139 +24,139 @@ namespace verbly { type_ = type::empty; } } - + selrestr::selrestr(const selrestr& other) { type_ = other.type_; - + switch (type_) { case type::singleton: { singleton_.pos = other.singleton_.pos; new(&singleton_.restriction) std::string(other.singleton_.restriction); - + break; } - + case type::group: { new(&group_.children) std::list(other.group_.children); group_.orlogic = other.group_.orlogic; - + break; } - + case type::empty: { break; } } } - + selrestr::selrestr(selrestr&& other) : selrestr() { swap(*this, other); } - + selrestr& selrestr::operator=(selrestr other) { swap(*this, other); - + return *this; } - + void swap(selrestr& first, selrestr& second) { using type = selrestr::type; - + type tempType = first.type_; int tempPos; std::string tempRestriction; std::list tempChildren; bool tempOrlogic; - + switch (tempType) { case type::singleton: { tempPos = first.singleton_.pos; tempRestriction = std::move(first.singleton_.restriction); - + break; } - + case type::group: { tempChildren = std::move(first.group_.children); tempOrlogic = first.group_.orlogic; - + break; } - + case type::empty: { break; } } - + first.~selrestr(); - + first.type_ = second.type_; - + switch (first.type_) { case type::singleton: { first.singleton_.pos = second.singleton_.pos; new(&first.singleton_.restriction) std::string(std::move(second.singleton_.restriction)); - + break; } - + case type::group: { new(&first.group_.children) std::list(std::move(second.group_.children)); first.group_.orlogic = second.group_.orlogic; - + break; } - + case type::empty: { break; } } - + second.~selrestr(); - + second.type_ = tempType; - + switch (second.type_) { case type::singleton: { second.singleton_.pos = tempPos; new(&second.singleton_.restriction) std::string(std::move(tempRestriction)); - + break; } - + case type::group: { new(&second.group_.children) std::list(std::move(tempChildren)); second.group_.orlogic = tempOrlogic; - + break; } - + case type::empty: { break; } } } - + selrestr::~selrestr() { switch (type_) @@ -165,29 +165,29 @@ namespace verbly { { using string_type = std::string; singleton_.restriction.~string_type(); - + break; } - + case type::group: { using list_type = std::list; group_.children.~list_type(); - + break; } - + case type::empty: { break; } } } - + selrestr::selrestr() : type_(type::empty) { } - + selrestr::selrestr( std::string restriction, bool pos) : @@ -196,7 +196,7 @@ namespace verbly { new(&singleton_.restriction) std::string(std::move(restriction)); singleton_.pos = pos; } - + std::string selrestr::getRestriction() const { if (type_ == type::singleton) @@ -206,7 +206,7 @@ namespace verbly { throw std::domain_error("Only singleton selrestrs have restrictions"); } } - + bool selrestr::getPos() const { if (type_ == type::singleton) @@ -216,7 +216,7 @@ namespace verbly { throw std::domain_error("Only singleton selrestrs have positivity flags"); } } - + selrestr::selrestr( std::list children, bool orlogic) : @@ -225,7 +225,7 @@ namespace verbly { new(&group_.children) std::list(std::move(children)); group_.orlogic = orlogic; } - + std::list selrestr::getChildren() const { if (type_ == type::group) @@ -235,7 +235,7 @@ namespace verbly { throw std::domain_error("Only group selrestrs have children"); } } - + std::list::const_iterator selrestr::begin() const { if (type_ == type::group) @@ -245,7 +245,7 @@ namespace verbly { throw std::domain_error("Only group selrestrs have children"); } } - + std::list::const_iterator selrestr::end() const { if (type_ == type::group) @@ -255,7 +255,7 @@ namespace verbly { throw std::domain_error("Only group selrestrs have children"); } } - + bool selrestr::getOrlogic() const { if (type_ == type::group) @@ -265,7 +265,7 @@ namespace verbly { throw std::domain_error("Only group selrestrs have logic"); } } - + nlohmann::json selrestr::toJson() const { switch (type_) @@ -274,7 +274,7 @@ namespace verbly { { return {}; } - + case type::singleton: { return { @@ -282,7 +282,7 @@ namespace verbly { {"pos", singleton_.pos} }; } - + case type::group: { std::string logic; @@ -292,12 +292,12 @@ namespace verbly { } else { logic = "and"; } - + std::list children; std::transform(std::begin(group_.children), std::end(group_.children), std::back_inserter(children), [] (const selrestr& child) { return child.toJson(); }); - + return { {"logic", logic}, {"children", children} -- cgit 1.4.1