From 30eb9178bda956407929396b51de04adce090f92 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 17 Mar 2018 10:44:40 -0700 Subject: [PATCH] ircd: Consolidate spirit typedefs from all relevant units into spirit.h. --- include/ircd/spirit.h | 38 ++++++++++++++++++++++++++++++++++++++ ircd/fmt.cc | 13 +------------ ircd/http.cc | 20 +------------------- ircd/json.cc | 29 +---------------------------- ircd/m/id.cc | 37 +++++-------------------------------- ircd/rfc1459.cc | 29 +++++++++-------------------- ircd/rfc3986.cc | 29 +++++------------------------ 7 files changed, 60 insertions(+), 135 deletions(-) diff --git a/include/ircd/spirit.h b/include/ircd/spirit.h index dc9ebee5a..e77f98a54 100644 --- a/include/ircd/spirit.h +++ b/include/ircd/spirit.h @@ -21,3 +21,41 @@ #include #include #include + +namespace ircd::spirit +{ + namespace spirit = boost::spirit; + namespace ascii = spirit::ascii; + namespace karma = spirit::karma; + namespace qi = spirit::qi; + + using spirit::unused_type; + + using qi::lit; + using qi::char_; + using qi::string; + using qi::short_; + using qi::int_; + using qi::long_; + using qi::double_; + using qi::raw; + using qi::omit; + using qi::matches; + using qi::hold; + using qi::eoi; + using qi::eps; + using qi::attr; + using qi::attr_cast; + using qi::repeat; + using qi::_r1_type; + + using karma::lit; + using karma::char_; + using karma::long_; + using karma::double_; + using karma::bool_; + using karma::eps; + using karma::attr_cast; + using karma::maxwidth; + using karma::buffer; +} diff --git a/ircd/fmt.cc b/ircd/fmt.cc index e9ef8a9ed..14ce9342b 100644 --- a/ircd/fmt.cc +++ b/ircd/fmt.cc @@ -21,18 +21,7 @@ BOOST_FUSION_ADAPT_STRUCT namespace ircd { namespace fmt { -namespace qi = boost::spirit::qi; -namespace karma = boost::spirit::karma; - -using qi::lit; -using qi::char_; -using qi::ushort_; -using qi::int_; -using qi::eps; -using qi::raw; -using qi::repeat; -using qi::omit; -using qi::unused_type; +using namespace ircd::spirit; std::map> _specifiers; diff --git a/ircd/http.cc b/ircd/http.cc index 4bbdc1e10..05ea791eb 100644 --- a/ircd/http.cc +++ b/ircd/http.cc @@ -12,25 +12,7 @@ namespace ircd::http { - namespace spirit = boost::spirit; - namespace qi = spirit::qi; - namespace karma = spirit::karma; - namespace ascii = qi::ascii; - - using qi::lit; - using qi::string; - using qi::char_; - using qi::short_; - using qi::int_; - using qi::long_; - using qi::repeat; - using qi::omit; - using qi::raw; - using qi::attr; - using qi::eps; - using qi::attr_cast; - using karma::maxwidth; - using spirit::unused_type; + using namespace ircd::spirit; template struct grammar; struct parser extern const parser; diff --git a/ircd/json.cc b/ircd/json.cc index 894d7fa06..704aa50ed 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -13,34 +13,7 @@ namespace ircd::json { - namespace spirit = boost::spirit; - namespace ascii = spirit::ascii; - namespace karma = spirit::karma; - namespace qi = spirit::qi; - - using spirit::unused_type; - - using qi::lit; - using qi::char_; - using qi::long_; - using qi::double_; - using qi::raw; - using qi::omit; - using qi::matches; - using qi::hold; - using qi::eoi; - using qi::eps; - using qi::attr; - using qi::repeat; - using qi::_r1_type; - - using karma::lit; - using karma::char_; - using karma::long_; - using karma::double_; - using karma::bool_; - using karma::eps; - using karma::attr_cast; + using namespace ircd::spirit; template struct input; template struct output; diff --git a/ircd/m/id.cc b/ircd/m/id.cc index 3bc790640..42f80f23e 100644 --- a/ircd/m/id.cc +++ b/ircd/m/id.cc @@ -13,43 +13,16 @@ namespace ircd::m { - namespace spirit = boost::spirit; - namespace qi = spirit::qi; - namespace karma = spirit::karma; - namespace ascii = qi::ascii; - - using qi::lit; - using qi::string; - using qi::char_; - using qi::short_; - using qi::ushort_; - using qi::int_; - using qi::long_; - using qi::repeat; - using qi::omit; - using qi::raw; - using qi::attr; - using qi::eps; - using qi::eoi; - using qi::attr_cast; - - using karma::lit; - using karma::char_; - using karma::long_; - using karma::double_; - using karma::bool_; - using karma::maxwidth; - using karma::eps; - using karma::attr_cast; + using namespace ircd::spirit; [[noreturn]] void failure(const qi::expectation_failure &, const string_view &); } template struct ircd::m::id::input -:qi::grammar +:qi::grammar { - template using rule = qi::rule; + template using rule = qi::rule; // Sigils const rule event_id_sigil { lit(char(m::id::EVENT)) ,"event_id sigil" }; @@ -252,9 +225,9 @@ struct ircd::m::id::input template struct ircd::m::id::output -:karma::grammar +:karma::grammar { - template using rule = karma::rule; + template using rule = karma::rule; output() :output::base_type{rule<>{}} diff --git a/ircd/rfc1459.cc b/ircd/rfc1459.cc index 85d889c28..154d1a29f 100644 --- a/ircd/rfc1459.cc +++ b/ircd/rfc1459.cc @@ -12,21 +12,11 @@ namespace ircd::rfc1459 { - namespace spirit = boost::spirit; - namespace karma = spirit::karma; - namespace qi = spirit::qi; + using namespace ircd::spirit; } namespace ircd::rfc1459::parse { - using qi::lit; - using qi::char_; - using qi::repeat; - using qi::attr; - using qi::eps; - using qi::raw; - using qi::omit; - template struct grammar; struct capstan extern const capstan; struct head extern const head; @@ -34,11 +24,7 @@ namespace ircd::rfc1459::parse namespace ircd::rfc1459::gen { - using karma::lit; - using karma::int_; - using karma::char_; - using karma::buffer; - using karma::repeat; + using ircd::spirit::buffer; template struct grammar; } @@ -438,11 +424,14 @@ try qi::parse(start, stop, grammar, *this); } -catch(const boost::spirit::qi::expectation_failure &e) +catch(const qi::expectation_failure &e) { - throw syntax_error("@%d expecting :%s", - int(e.last - e.first), - string(e.what_).c_str()); + throw syntax_error + { + "@%d expecting :%s", + int(e.last - e.first), + ircd::string(e.what_).c_str() + }; } bool diff --git a/ircd/rfc3986.cc b/ircd/rfc3986.cc index e8f8b6f50..743308757 100644 --- a/ircd/rfc3986.cc +++ b/ircd/rfc3986.cc @@ -10,37 +10,18 @@ #include -namespace spirit = boost::spirit; -namespace qi = spirit::qi; -namespace karma = spirit::karma; -namespace ascii = qi::ascii; - -using qi::lit; -using qi::string; -using qi::char_; -using qi::short_; -using qi::ushort_; -using qi::int_; -using qi::long_; -using qi::repeat; -using qi::omit; -using qi::raw; -using qi::attr; -using qi::eps; -using qi::attr_cast; - -using karma::maxwidth; - namespace ircd::rfc3986 { + using namespace ircd::spirit; + template struct grammar; } template struct ircd::rfc3986::grammar -:qi::grammar +:qi::grammar { - template using rule = qi::rule; + template using rule = qi::rule; const rule<> port { @@ -206,7 +187,7 @@ ircd::rfc3986::encode(const string_view &url, struct ircd::rfc3986::decoder :qi::grammar { - template using rule = qi::rule; + template using rule = qi::rule; rule<> url_illegal {