diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-06 11:30:10 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-06 11:38:37 +0100 |
commit | 2002f5bd071b451442f066c215120dd4708dcf69 (patch) | |
tree | 03e39a35c9129eb9f1c2777aa48061449ea33a8f | |
parent | C++17 (diff) | |
download | libadhocutil-2002f5bd071b451442f066c215120dd4708dcf69.tar.bz2 libadhocutil-2002f5bd071b451442f066c215120dd4708dcf69.tar.xz libadhocutil-2002f5bd071b451442f066c215120dd4708dcf69.zip |
C++17
Remove all boost things now in the standard library from lexer.
-rw-r--r-- | libadhocutil/lexer-regex.cpp | 6 | ||||
-rw-r--r-- | libadhocutil/lexer.cpp | 8 | ||||
-rw-r--r-- | 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<Glib::ustring> match(int n) const override + std::optional<Glib::ustring> 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<Glib::ustring>(); + return {}; } return Glib::ustring(str + start, str + end); } - return boost::optional<Glib::ustring>(); + 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 <vector> #include <glibmm/ustring.h> #include <set> -#include <boost/tuple/tuple.hpp> -#include <boost/function.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/optional.hpp> +#include <tuple> +#include <functional> +#include <memory> +#include <optional> #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<Glib::ustring> match(int) const = 0; + virtual std::optional<Glib::ustring> match(int) const = 0; }; /// Smart pointer to Pattern. - typedef boost::shared_ptr<Pattern> PatternPtr; + typedef std::shared_ptr<Pattern> 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<void(ExecuteState *)> Handler; + typedef std::function<void(ExecuteState *)> 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<States, PatternPtr, Handler> Rule; + typedef std::tuple<States, PatternPtr, Handler> Rule; /// Collection of Rules that make up the lexer configuration. typedef std::vector<Rule> Rules; /// The initial state of applied to the lexer. |