Orcus
tokens.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_ORCUS_TOKENS_HPP
9 #define INCLUDED_ORCUS_TOKENS_HPP
10 
11 #include "types.hpp"
12 
13 #include <algorithm>
14 #include <unordered_map>
15 
16 namespace orcus {
17 
18 class ORCUS_PSR_DLLPUBLIC tokens
19 {
20 public:
21  tokens() = delete;
22  tokens(const char** token_names, size_t token_name_count);
23 
29  bool is_valid_token(xml_token_t token) const;
30 
38  xml_token_t get_token(std::string_view name) const;
39 
48  std::string_view get_token_name(xml_token_t token) const;
49 
50 private:
51  using token_map_type = std::unordered_map<std::string_view, xml_token_t>;
52 
53  token_map_type m_tokens;
54  const char** m_token_names;
55  size_t m_token_name_count;
56 };
57 
58 }
59 
60 #endif
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: tokens.hpp:19
bool is_valid_token(xml_token_t token) const
xml_token_t get_token(std::string_view name) const
std::string_view get_token_name(xml_token_t token) const