From c10187f6baa0f134301cb30953719b91d79de412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 10 May 2017 16:12:37 +0200 Subject: [PATCH] Minor refactoring to simplify parser classes. --- .../include/parsebase/ParserPolicy.h | 70 +++++++++---------- lib/parsebase/include/parsebase/Stream.h | 21 ++---- .../include/pddlparse/detail/Parser.h | 43 ++++++------ 3 files changed, 59 insertions(+), 75 deletions(-) diff --git a/lib/parsebase/include/parsebase/ParserPolicy.h b/lib/parsebase/include/parsebase/ParserPolicy.h index a45c862..6f681e0 100644 --- a/lib/parsebase/include/parsebase/ParserPolicy.h +++ b/lib/parsebase/include/parsebase/ParserPolicy.h @@ -12,54 +12,52 @@ namespace parsebase // //////////////////////////////////////////////////////////////////////////////////////////////////// -class CaseSensitiveParserPolicy +struct CaseSensitiveParserPolicy { - public: - static constexpr char transformCharacter(char c) noexcept - { - return c; - } + static constexpr char transformCharacter(char c) noexcept + { + return c; + } - static bool isWhiteSpaceCharacter(char c) - { - return std::iswspace(c); - } + static bool isWhiteSpaceCharacter(char c) + { + return std::iswspace(c); + } - static bool isBlankCharacter(char c) - { - return std::isblank(c); - } + static bool isBlankCharacter(char c) + { + return std::isblank(c); + } - static bool isIdentifierCharacter(char c) - { - return std::isgraph(c); - } + static bool isIdentifierCharacter(char c) + { + return std::isgraph(c); + } }; //////////////////////////////////////////////////////////////////////////////////////////////////// -class CaseInsensitiveParserPolicy +struct CaseInsensitiveParserPolicy { - public: - static char transformCharacter(char c) noexcept - { - return std::tolower(c); - } + static char transformCharacter(char c) noexcept + { + return std::tolower(c); + } - static bool isWhiteSpaceCharacter(char c) - { - return std::iswspace(c); - } + static bool isWhiteSpaceCharacter(char c) + { + return std::iswspace(c); + } - static bool isBlankCharacter(char c) - { - return std::isblank(c); - } + static bool isBlankCharacter(char c) + { + return std::isblank(c); + } - static bool isIdentifierCharacter(char c) - { - return std::isgraph(c); - } + static bool isIdentifierCharacter(char c) + { + return std::isgraph(c); + } }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/lib/parsebase/include/parsebase/Stream.h b/lib/parsebase/include/parsebase/Stream.h index 702bfed..205cefb 100644 --- a/lib/parsebase/include/parsebase/Stream.h +++ b/lib/parsebase/include/parsebase/Stream.h @@ -30,27 +30,14 @@ class Stream }; public: - explicit Stream(); + Stream(); explicit Stream(std::string streamName, std::istream &istream); + ~Stream() = default; Stream(const Stream &other) = delete; Stream &operator=(const Stream &other) = delete; - - Stream(Stream &&other) - : m_stream{std::move(other.m_stream)}, - m_delimiters{std::move(other.m_delimiters)} - { - } - - Stream &operator=(Stream &&other) - { - m_stream = std::move(other.m_stream); - m_delimiters = std::move(other.m_delimiters); - - return *this; - } - - ~Stream() = default; + Stream(Stream &&other) = default; + Stream &operator=(Stream &&other) = default; void read(std::string streamName, std::istream &istream); void read(const std::experimental::filesystem::path &path); diff --git a/lib/pddlparse/include/pddlparse/detail/Parser.h b/lib/pddlparse/include/pddlparse/detail/Parser.h index b9170b2..65f5f07 100644 --- a/lib/pddlparse/include/pddlparse/detail/Parser.h +++ b/lib/pddlparse/include/pddlparse/detail/Parser.h @@ -16,32 +16,31 @@ namespace detail // //////////////////////////////////////////////////////////////////////////////////////////////////// -class PDDLParserPolicy +struct PDDLParserPolicy { - public: - static char transformCharacter(char c) noexcept - { - return std::tolower(c); - } + static char transformCharacter(char c) noexcept + { + return std::tolower(c); + } - static bool isWhiteSpaceCharacter(char c) - { - return std::iswspace(c); - } + static bool isWhiteSpaceCharacter(char c) + { + return std::iswspace(c); + } - static bool isBlankCharacter(char c) - { - return std::isblank(c); - } + static bool isBlankCharacter(char c) + { + return std::isblank(c); + } - static bool isIdentifierCharacter(char c) - { - return c != '?' - && c != '(' - && c != ')' - && c != ';' - && std::isgraph(c); - } + static bool isIdentifierCharacter(char c) + { + return c != '?' + && c != '(' + && c != ')' + && c != ';' + && std::isgraph(c); + } }; ////////////////////////////////////////////////////////////////////////////////////////////////////