diff --git a/server/modules/filter/hintfilter/hintparser.cc b/server/modules/filter/hintfilter/hintparser.cc index 9b0c31367..ad2599d75 100644 --- a/server/modules/filter/hintfilter/hintparser.cc +++ b/server/modules/filter/hintfilter/hintparser.cc @@ -24,6 +24,8 @@ * Code for parsing SQL comments and processing them into MaxScale hints */ +using InputIter = mxs::Buffer::iterator; + /* Parser tokens for the hint parser */ typedef enum { @@ -52,7 +54,6 @@ typedef enum * * @return The iterator pointing at the first occurrence of the character or `end` if one was not found */ -template InputIter skip_until(InputIter it, InputIter end, char c) { while (it != end) @@ -84,7 +85,6 @@ InputIter skip_until(InputIter it, InputIter end, char c) * @return A pair of iterators pointing to the range the comment spans. The comment tags themselves are not * included in this range. If no comment is found, a pair of `end` iterators is returned. */ -template std::pair get_comment(InputIter it, InputIter end) { while (it != end) @@ -158,7 +158,6 @@ std::pair get_comment(InputIter it, InputIter end) * * @return A list of iterator pairs pointing to all comments in the query */ -template std::vector> get_all_comments(InputIter start, InputIter end) { std::vector> rval; @@ -180,7 +179,6 @@ std::vector> get_all_comments(InputIter start, I } // Simple container for two iterators and a token type -template struct Token { InputIter begin; @@ -212,8 +210,7 @@ static const std::unordered_map tokens * * @return The next token */ -template -Token next_token(InputIter* iter, InputIter end) +Token next_token(InputIter* iter, InputIter end) { InputIter& it = *iter; @@ -265,7 +262,6 @@ Token next_token(InputIter* iter, InputIter end) * * @return The processed hint or NULL on invalid input */ -template HINT* process_definition(InputIter it, InputIter end) { HINT* rval = nullptr; @@ -324,7 +320,6 @@ HINT* process_definition(InputIter it, InputIter end) return rval; } -template HINT* HINT_SESSION::process_comment(InputIter it, InputIter end) { HINT* rval = nullptr; diff --git a/server/modules/filter/hintfilter/mysqlhint.hh b/server/modules/filter/hintfilter/mysqlhint.hh index b0de5394c..b6af3eba2 100644 --- a/server/modules/filter/hintfilter/mysqlhint.hh +++ b/server/modules/filter/hintfilter/mysqlhint.hh @@ -39,7 +39,7 @@ private: std::vector stack; std::unordered_map named_hints; - template + using InputIter = mxs::Buffer::iterator; HINT* process_comment(InputIter it, InputIter end); void process_hints(GWBUF* buffer); diff --git a/server/modules/filter/hintfilter/test/test_hintparser.cc b/server/modules/filter/hintfilter/test/test_hintparser.cc index d4ea3b8d9..eb99e3604 100644 --- a/server/modules/filter/hintfilter/test/test_hintparser.cc +++ b/server/modules/filter/hintfilter/test/test_hintparser.cc @@ -27,8 +27,9 @@ void test(const std::string& input, std::initializer_list expected) { bool rval = true; auto it = expected.begin(); + mxs::Buffer buffer(input.c_str(), input.size()); - for (auto output : get_all_comments(input.begin(), input.end())) + for (auto output : get_all_comments(buffer.begin(), buffer.end())) { if (it == expected.end()) { @@ -76,7 +77,9 @@ static HINT_SESSION session(nullptr); void test_parse(const std::string& input, int expected_type) { - for (auto comment : get_all_comments(input.begin(), input.end())) + mxs::Buffer buffer(input.c_str(), input.size()); + + for (auto comment : get_all_comments(buffer.begin(), buffer.end())) { std::string comment_str(comment.first, comment.second); HINT* hint = session.process_comment(comment.first, comment.second); @@ -100,8 +103,9 @@ void test_parse(const std::string& input, int expected_type) void count_hints(const std::string& input, int num_expected) { int n = 0; + mxs::Buffer buffer(input.c_str(), input.size()); - for (auto comment : get_all_comments(input.begin(), input.end())) + for (auto comment : get_all_comments(buffer.begin(), buffer.end())) { if (session.process_comment(comment.first, comment.second)) {