Orcus
Loading...
Searching...
No Matches
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
16namespace orcus {
17
29class ORCUS_PSR_DLLPUBLIC tokens
30{
31public:
32 tokens() = delete;
33 tokens(const tokens&) = delete;
34 tokens(const char** token_names, size_t token_name_count);
35 ~tokens();
36
42 bool is_valid_token(xml_token_t token) const;
43
51 xml_token_t get_token(std::string_view name) const;
52
61 std::string_view get_token_name(xml_token_t token) const;
62
63private:
64 using token_map_type = std::unordered_map<std::string_view, xml_token_t>;
65
66 token_map_type m_tokens;
67 const char** m_token_names;
68 size_t m_token_name_count;
69};
70
71}
72
73#endif
74/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition tokens.hpp:30
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