From 2002f5bd071b451442f066c215120dd4708dcf69 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 6 Apr 2018 11:30:10 +0100 Subject: C++17 Remove all boost things now in the standard library from lexer. --- libadhocutil/lexer-regex.cpp | 6 +++--- libadhocutil/lexer.cpp | 8 ++++---- libadhocutil/lexer.h | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libadhocutil/lexer-regex.cpp b/libadhocutil/lexer-regex.cpp index 2e3d7cf..c283798 100644 --- a/libadhocutil/lexer-regex.cpp +++ b/libadhocutil/lexer-regex.cpp @@ -49,16 +49,16 @@ namespace AdHoc { return end - start; } - boost::optional match(int n) const override + std::optional match(int n) const override { gint start, end; if (g_match_info_fetch_pos(info, n, &start, &end)) { if (start == -1 && end == -1) { - return boost::optional(); + return {}; } return Glib::ustring(str + start, str + end); } - return boost::optional(); + return {}; } private: diff --git a/libadhocutil/lexer.cpp b/libadhocutil/lexer.cpp index 3dd1e0e..7c25688 100644 --- a/libadhocutil/lexer.cpp +++ b/libadhocutil/lexer.cpp @@ -20,11 +20,11 @@ namespace AdHoc { while (es.pos < length) { const Rule * selected = nullptr; for (const auto & r : rules) { - const auto & s = boost::get<0>(r); + const auto & s = std::get<0>(r); if (s.find(es.getState()) == s.end()) { continue; } - const auto & p = boost::get<1>(r); + const auto & p = std::get<1>(r); if (p->matches(string, length, es.pos)) { selected = &r; break; @@ -33,8 +33,8 @@ namespace AdHoc { if (!selected) { throw std::runtime_error(UnexpectedInputState::get(es.getState(), string + es.pos)); } - es.pat = boost::get<1>(*selected); - const auto & h = boost::get<2>(*selected); + es.pat = std::get<1>(*selected); + const auto & h = std::get<2>(*selected); h(&es); es.pos += es.pat->matchedLength(); } diff --git a/libadhocutil/lexer.h b/libadhocutil/lexer.h index 98cbd3c..be39525 100644 --- a/libadhocutil/lexer.h +++ b/libadhocutil/lexer.h @@ -4,10 +4,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "visibility.h" namespace AdHoc { @@ -24,10 +24,10 @@ namespace AdHoc { /// Get the total amount of input matched. virtual size_t matchedLength() const = 0; /// Get an extracted value from the pattern. - virtual boost::optional match(int) const = 0; + virtual std::optional match(int) const = 0; }; /// Smart pointer to Pattern. - typedef boost::shared_ptr PatternPtr; + typedef std::shared_ptr PatternPtr; /// Lexer state identifiers. typedef std::string State; /// Collection of States. @@ -63,14 +63,14 @@ namespace AdHoc { }; /// Callback for handling matched patterns. - typedef boost::function Handler; + typedef std::function Handler; /** * Rule definition: * States: in which states should the rule be considered? * Pattern: the pattern matcher to test against the input. * Handler: the callback to execute when a match succeeds. */ - typedef boost::tuple Rule; + typedef std::tuple Rule; /// Collection of Rules that make up the lexer configuration. typedef std::vector Rules; /// The initial state of applied to the lexer. -- cgit v1.2.3