| 1 |
/* |
| 2 |
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2020 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 29 окт. 2019 г. |
| 7 |
* |
| 8 |
* lsp-runtime-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-runtime-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef LSP_PLUG_IN_FMT_XML_PUSHPARSER_H_ |
| 23 |
#define LSP_PLUG_IN_FMT_XML_PUSHPARSER_H_ |
| 24 |
|
| 25 |
#include <lsp-plug.in/runtime/version.h> |
| 26 |
#include <lsp-plug.in/fmt/xml/PullParser.h> |
| 27 |
#include <lsp-plug.in/fmt/xml/IXMLHandler.h> |
| 28 |
#include <lsp-plug.in/lltl/parray.h> |
| 29 |
|
| 30 |
namespace lsp |
| 31 |
{ |
| 32 |
namespace xml |
| 33 |
{ |
| 34 |
|
| 35 |
class PushParser |
| 36 |
{ |
| 37 |
private: |
| 38 |
PullParser sParser; |
| 39 |
|
| 40 |
private: |
| 41 |
status_t parse_document(IXMLHandler *handler); |
| 42 |
void drop_list(lltl::parray<LSPString> *list); |
| 43 |
|
| 44 |
public: |
| 45 |
explicit PushParser(); |
| 46 |
virtual ~PushParser(); |
| 47 |
|
| 48 |
public: |
| 49 |
/** |
| 50 |
* Parse file |
| 51 |
* @param handler XML handler |
| 52 |
* @param path UTF-8 path to the file |
| 53 |
* @param charset character set encoding of the file |
| 54 |
* @return status of operation |
| 55 |
*/ |
| 56 |
status_t parse_file(IXMLHandler *handler, const char *path, const char *charset = NULL); |
| 57 |
|
| 58 |
/** |
| 59 |
* Parse file |
| 60 |
* @param handler XML handler |
| 61 |
* @param path path to the file |
| 62 |
* @param charset character set encoding of the file |
| 63 |
* @return status of operation |
| 64 |
*/ |
| 65 |
status_t parse_file(IXMLHandler *handler, const LSPString *path, const char *charset = NULL); |
| 66 |
|
| 67 |
/** |
| 68 |
* Parse file |
| 69 |
* @param handler XML handler |
| 70 |
* @param path path to the file |
| 71 |
* @param charset character set encoding of the file |
| 72 |
* @return status of operation |
| 73 |
*/ |
| 74 |
status_t parse_file(IXMLHandler *handler, const io::Path *path, const char *charset = NULL); |
| 75 |
|
| 76 |
/** |
| 77 |
* Parse data from input stream |
| 78 |
* @param handler XML handler |
| 79 |
* @param is input stream |
| 80 |
* @param flags wrap flags |
| 81 |
* @param charset character set |
| 82 |
* @return status of operation |
| 83 |
*/ |
| 84 |
status_t parse_data(IXMLHandler *handler, io::IInStream *is, size_t flags = WRAP_NONE, const char *charset = NULL); |
| 85 |
|
| 86 |
/** |
| 87 |
* Parse data from UTF-8 encoded string |
| 88 |
* @param handler XML handler |
| 89 |
* @param str data input |
| 90 |
* @param charset character set |
| 91 |
* @return status of operation |
| 92 |
*/ |
| 93 |
status_t parse_data(IXMLHandler *handler, const char *str, const char *charset = NULL); |
| 94 |
|
| 95 |
/** |
| 96 |
* Parse data from text string |
| 97 |
* @param handler XML handler |
| 98 |
* @param str data input |
| 99 |
* @return status of operation |
| 100 |
*/ |
| 101 |
status_t parse_data(IXMLHandler *handler, const LSPString *str); |
| 102 |
|
| 103 |
/** |
| 104 |
* Parse data from character sequence |
| 105 |
* @param handler XML handler |
| 106 |
* @param seq input sequence |
| 107 |
* @param flags wrap flags |
| 108 |
* @return status of operation |
| 109 |
*/ |
| 110 |
status_t parse_data(IXMLHandler *handler, io::IInSequence *seq, size_t flags = WRAP_NONE); |
| 111 |
}; |
| 112 |
|
| 113 |
} /* namespace xml */ |
| 114 |
} /* namespace lsp */ |
| 115 |
|
| 116 |
#endif /* LSP_PLUG_IN_FMT_XML_PUSHPARSER_H_ */ |