| 1 | /* File: io_md_writer.h; Copyright and License: see below */ |
| 2 | |
| 3 | #ifndef IO_MD_WRITER_H |
| 4 | #define IO_MD_WRITER_H |
| 5 | |
| 6 | /* public file for the doxygen documentation: */ |
| 7 | /*! |
| 8 | * \file |
| 9 | * \brief parses some md-like and link features of the input string to an xml writer. |
| 10 | * |
| 11 | * This class is a filter in the sense of the pipes-and-filters architecture pattern: |
| 12 | * It modifies and enriches the piped-through data. |
| 13 | */ |
| 14 | |
| 15 | #include "format/io_xml_writer.h" |
| 16 | #include "utf8stringbuf/utf8stringbuf.h" |
| 17 | #include "storage/data_database_reader.h" |
| 18 | #include "entity/data_diagram.h" |
| 19 | #include "u8/u8_error.h" |
| 20 | |
| 21 | /*! |
| 22 | * \brief constants for max string sizes |
| 23 | */ |
| 24 | enum io_md_writer_max_enum { |
| 25 | IO_MD_WRITER_MAX_STRING_SIZE = DATA_DIAGRAM_MAX_DESCRIPTION_LENGTH + DATA_CLASSIFIER_MAX_DESCRIPTION_LENGTH, |
| 26 | }; |
| 27 | |
| 28 | /*! |
| 29 | * \brief attributes of the xml writer |
| 30 | */ |
| 31 | struct io_md_writer_struct { |
| 32 | data_database_reader_t *db_reader; /*!< pointer to external database reader */ |
| 33 | io_xml_writer_t *sink; /*!< output sink */ |
| 34 | |
| 35 | const char * tag_linebreak; /*!< tag for linebreak */ |
| 36 | const char * tag_xref_start; /*!< tag for xref_start */ |
| 37 | const char * tag_xref_middle; /*!< tag for xref_middle */ |
| 38 | const char * tag_xref_end; /*!< tag for xref_end */ |
| 39 | |
| 40 | data_diagram_t temp_diagram; /*!< memory for temporary diagram storage */ |
| 41 | }; |
| 42 | |
| 43 | typedef struct io_md_writer_struct io_md_writer_t; |
| 44 | |
| 45 | /*! |
| 46 | * \brief initializes the markdown writer |
| 47 | * |
| 48 | * \param this_ pointer to own object attributes |
| 49 | * \param db_reader pointer to a database reader object |
| 50 | * \param tag_linebreak tag for linebreak |
| 51 | * \param tag_xref_start tag for xref_start |
| 52 | * \param tag_xref_middle tag for xref_middle |
| 53 | * \param tag_xref_end tag for xref_end |
| 54 | * \param sink stream sink where to write the output to |
| 55 | */ |
| 56 | void io_md_writer_init( io_md_writer_t *this_, |
| 57 | data_database_reader_t *db_reader, |
| 58 | const char * tag_linebreak, |
| 59 | const char * tag_xref_start, |
| 60 | const char * tag_xref_middle, |
| 61 | const char * tag_xref_end, |
| 62 | io_xml_writer_t *sink |
| 63 | ); |
| 64 | |
| 65 | /*! |
| 66 | * \brief destroys the markdown writer |
| 67 | * |
| 68 | * \param this_ pointer to own object attributes |
| 69 | */ |
| 70 | void io_md_writer_destroy( io_md_writer_t *this_ ); |
| 71 | |
| 72 | /*! |
| 73 | * \brief parses the string, enriches it by links and paragraph-breaks and writes it to the sink |
| 74 | * |
| 75 | * \param this_ pointer to own object attributes |
| 76 | * \param text string to parse |
| 77 | * \return U8_ERROR_NONE in case of success |
| 78 | */ |
| 79 | u8_error_t io_md_writer_transform ( io_md_writer_t *this_, const char *text ); |
| 80 | |
| 81 | #endif /* IO_MD_WRITER_H */ |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | Copyright 2019-2026 Andreas Warnke |
| 86 | |
| 87 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 88 | you may not use this file except in compliance with the License. |
| 89 | You may obtain a copy of the License at |
| 90 | |
| 91 | http://www.apache.org/licenses/LICENSE-2.0 |
| 92 | |
| 93 | Unless required by applicable law or agreed to in writing, software |
| 94 | distributed under the License is distributed on an "AS IS" BASIS, |
| 95 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 96 | See the License for the specific language governing permissions and |
| 97 | limitations under the License. |
| 98 | */ |