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 "orcus/types.hpp"
12 #include "orcus/pstring.hpp"
13 
14 #include <algorithm>
15 #include <unordered_map>
16 
17 namespace orcus {
18 
19 class pstring;
20 
21 class ORCUS_PSR_DLLPUBLIC tokens
22 {
23  tokens() = delete;
24 public:
25 
26  tokens(const char** token_names, size_t token_name_count);
27 
33  bool is_valid_token(xml_token_t token) const;
34 
42  xml_token_t get_token(const pstring& name) const;
43 
52  const char* get_token_name(xml_token_t token) const;
53 
54 private:
55  typedef std::unordered_map<pstring, xml_token_t, pstring::hash> token_map_type;
56 
57  token_map_type m_tokens;
58  const char** m_token_names;
59  size_t m_token_name_count;
60 };
61 
62 }
63 
64 #endif
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:24
Definition: tokens.hpp:21
Definition: base64.hpp:15