/src/libreoffice/xmloff/inc/fasttokenhandler.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #pragma once |
11 | | |
12 | | #include <sax/fastattribs.hxx> |
13 | | #include <xmloff/token/tokens.hxx> |
14 | | #include <sal/log.hxx> |
15 | | |
16 | | namespace xmloff::token { |
17 | | |
18 | | namespace TokenMap |
19 | | { |
20 | | /** Returns the UTF-8 name of the passed token identifier as byte sequence. */ |
21 | | css::uno::Sequence<sal_Int8> const& getUtf8TokenName(sal_Int32 nToken); |
22 | | |
23 | | /** Returns the token identifier for a UTF-8 string */ |
24 | | sal_Int32 getTokenFromUtf8(std::string_view token); |
25 | | }; |
26 | | |
27 | | class FastTokenHandler final : |
28 | | public sax_fastparser::FastTokenHandlerBase |
29 | | { |
30 | | public: |
31 | 57 | explicit FastTokenHandler() = default; |
32 | | |
33 | | // XFastTokenHandler |
34 | | virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken ) override; |
35 | | virtual sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override; |
36 | | |
37 | | static const OUString& getIdentifier(sal_Int32 nToken); |
38 | | |
39 | | // Much faster direct C++ shortcut to the method that matters |
40 | | virtual sal_Int32 getTokenDirect(std::string_view token) const override; |
41 | | }; |
42 | | |
43 | | } // namespace xmloff::token |
44 | | |
45 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |