| 1 |
/* |
| 2 |
* Copyright (C) 2026 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2026 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 18 янв. 2026 г. |
| 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_XPM_XPM_H_ |
| 23 |
#define LSP_PLUG_IN_FMT_XPM_XPM_H_ |
| 24 |
|
| 25 |
#include <lsp-plug.in/runtime/version.h> |
| 26 |
|
| 27 |
#include <lsp-plug.in/fmt/xpm/Parser.h> |
| 28 |
|
| 29 |
namespace lsp |
| 30 |
{ |
| 31 |
namespace xpm |
| 32 |
{ |
| 33 |
/** |
| 34 |
* Open parser for reading file |
| 35 |
* |
| 36 |
* @param path UTF-8 path to the file |
| 37 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 38 |
* responsible for calling close() and delete the parser. |
| 39 |
* @return status of operation |
| 40 |
*/ |
| 41 |
status_t open(Parser **dst, const char *path); |
| 42 |
|
| 43 |
/** |
| 44 |
* Open parser for reading file |
| 45 |
* |
| 46 |
* @param path string representation of path to the file |
| 47 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 48 |
* responsible for calling close() and delete the parser. |
| 49 |
* @return status of operation |
| 50 |
*/ |
| 51 |
status_t open(Parser **dst, const LSPString *path); |
| 52 |
|
| 53 |
/** |
| 54 |
* Open parser for reading file |
| 55 |
* @param path path to the file |
| 56 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 57 |
* responsible for calling close() and delete the parser. |
| 58 |
* @return status of operation |
| 59 |
*/ |
| 60 |
status_t open(Parser **dst, const io::Path *path); |
| 61 |
|
| 62 |
/** |
| 63 |
* Wrap memory chunk with parser |
| 64 |
* @param str string to wrap |
| 65 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 66 |
* responsible for calling close() and delete the parser. |
| 67 |
* @return status of operation |
| 68 |
*/ |
| 69 |
status_t wrap(Parser **dst, const char *str); |
| 70 |
|
| 71 |
/** |
| 72 |
* Wrap buffer with parser |
| 73 |
* @param buf buffer to wrap |
| 74 |
* @param len length of buffer to wrap |
| 75 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 76 |
* responsible for calling close() and delete the parser. |
| 77 |
* @return status of operation |
| 78 |
*/ |
| 79 |
status_t wrap(Parser **dst, const void *buf, size_t len); |
| 80 |
|
| 81 |
/** |
| 82 |
* Wrap buffer with parser |
| 83 |
* @param buf buffer to wrap |
| 84 |
* @param len length of buffer to wrap |
| 85 |
* @param drop memory dropping flags |
| 86 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 87 |
* responsible for calling close() and delete the parser. |
| 88 |
* @return status of operation |
| 89 |
*/ |
| 90 |
status_t wrap(Parser **dst, void *buf, size_t len, lsp_memdrop_t drop = MEMDROP_NONE); |
| 91 |
|
| 92 |
/** |
| 93 |
* Wrap input stream with parser |
| 94 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 95 |
* responsible for calling close() and delete the parser. |
| 96 |
* @param is input stream |
| 97 |
* @param flags wrap flags |
| 98 |
* @return status of operation |
| 99 |
*/ |
| 100 |
status_t wrap(Parser **dst, io::IInStream *is, size_t flags = WRAP_NONE); |
| 101 |
|
| 102 |
/** |
| 103 |
* Make an XPM1 parser for built-in image |
| 104 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 105 |
* responsible for calling close() and delete the parser. |
| 106 |
* @param width the width of image in pixels |
| 107 |
* @param height the height of image in pixels |
| 108 |
* @param num_colors the number of colors |
| 109 |
* @param chars_per_pixel number of characters per pixel |
| 110 |
* @param colors array of color definitions |
| 111 |
* @param pixels array of pixel definitions |
| 112 |
* @return status of operation |
| 113 |
*/ |
| 114 |
status_t make_xpm1(Parser **dst, |
| 115 |
size_t width, |
| 116 |
size_t height, |
| 117 |
size_t num_colors, |
| 118 |
size_t chars_per_pixel, |
| 119 |
const char * const * colors, |
| 120 |
const char * const * pixels); |
| 121 |
|
| 122 |
/** |
| 123 |
* Make an XPM3 parser for built-in image |
| 124 |
* @param dst pointer to store pointer to the parser. The caller code is |
| 125 |
* responsible for calling close() and delete the parser. |
| 126 |
* @param lines the XPM3 data lines |
| 127 |
* @param count number of data lines |
| 128 |
* @return status of operation |
| 129 |
*/ |
| 130 |
status_t make_xpm3(Parser **dst, const char * const * lines, size_t count); |
| 131 |
|
| 132 |
} /* namespace xpm */ |
| 133 |
} /* namespace lsp */ |
| 134 |
|
| 135 |
|
| 136 |
#endif /* LSP_PLUG_IN_FMT_XPM_XPM_H_ */ |