libfort/src/string_buffer.h

70 lines
1.8 KiB
C
Raw Normal View History

2018-01-17 19:22:57 +01:00
#ifndef STRING_BUFFER_H
#define STRING_BUFFER_H
2018-05-06 15:36:53 +02:00
#include "fort_utils.h"
2018-01-17 19:22:57 +01:00
/*****************************************************************************
* STRING BUFFER
* ***************************************************************************/
2018-05-06 16:04:34 +02:00
enum str_buf_type {
2018-03-05 19:08:14 +01:00
CharBuf,
2018-11-02 22:16:20 +01:00
#ifdef FT_HAVE_WCHAR
2018-03-05 19:08:14 +01:00
WCharBuf
2018-11-02 22:16:20 +01:00
#endif /* FT_HAVE_WCHAR */
2018-03-05 19:08:14 +01:00
};
2018-05-06 16:04:34 +02:00
struct string_buffer {
2018-03-05 19:08:14 +01:00
union {
char *cstr;
wchar_t *wstr;
void *data;
2018-05-06 16:04:34 +02:00
} str;
2018-03-05 19:08:14 +01:00
size_t data_sz;
enum str_buf_type type;
2018-01-17 19:22:57 +01:00
};
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-05-06 16:04:34 +02:00
string_buffer_t *create_string_buffer(size_t number_of_chars, enum str_buf_type type);
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-01-17 19:22:57 +01:00
void destroy_string_buffer(string_buffer_t *buffer);
2018-09-01 14:37:01 +02:00
2018-11-02 22:16:20 +01:00
FT_INTERNAL
string_buffer_t *copy_string_buffer(string_buffer_t *buffer);
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-01-17 19:22:57 +01:00
fort_status_t realloc_string_buffer_without_copy(string_buffer_t *buffer);
2018-03-05 19:08:14 +01:00
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-01-17 19:22:57 +01:00
fort_status_t fill_buffer_from_string(string_buffer_t *buffer, const char *str);
2018-03-05 19:08:14 +01:00
2018-09-01 14:37:01 +02:00
#ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *str);
#endif /* FT_HAVE_WCHAR */
2018-01-17 19:22:57 +01:00
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-01-17 19:22:57 +01:00
size_t buffer_text_height(string_buffer_t *buffer);
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-03-05 19:08:14 +01:00
size_t string_buffer_capacity(const string_buffer_t *buffer);
2018-01-17 19:22:57 +01:00
2018-09-01 14:37:01 +02:00
FT_INTERNAL
void *buffer_get_data(string_buffer_t *buffer);
2018-01-17 19:22:57 +01:00
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-01-17 19:22:57 +01:00
size_t buffer_text_width(string_buffer_t *buffer);
2018-09-01 14:37:01 +02:00
FT_INTERNAL
2018-11-10 07:58:21 +01:00
int buffer_printf(string_buffer_t *buffer, size_t buffer_row, char *buf, size_t total_buf_len,
const context_t *context, const char *content_style_tag, const char *reset_content_style_tag);
2018-09-01 14:37:01 +02:00
#ifdef FT_HAVE_WCHAR
FT_INTERNAL
2018-11-10 07:58:21 +01:00
int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, size_t total_buf_len,
const context_t *context, const char *content_style_tag, const char *reset_content_style_tag);
2018-09-01 14:37:01 +02:00
#endif /* FT_HAVE_WCHAR */
2018-03-05 19:08:14 +01:00
2018-03-09 10:44:16 +01:00
#endif /* STRING_BUFFER_H */