runtime: format: add truncation and single-line support to value_writer
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <fx/reflection/property.h>
|
||||
#include <fx/reflection/type.h>
|
||||
#include <fx/stream.h>
|
||||
#include <fx/stringstream.h>
|
||||
#include <fx/value.h>
|
||||
|
||||
#define TABLE_COLUMN(display_name, property_name, width) \
|
||||
@@ -18,6 +19,12 @@
|
||||
}
|
||||
#define COL_WIDTH_INFINITE ((size_t)-1)
|
||||
|
||||
enum bshell_value_writer_flags {
|
||||
BSHELL_VALUE_WRITER_ONELINE = 0x01u,
|
||||
BSHELL_VALUE_WRITER_TRUNCATE = 0x02u,
|
||||
BSHELL_VALUE_WRITER_NO_NEWLINE = 0x04u,
|
||||
};
|
||||
|
||||
struct bshell_table_column {
|
||||
const char *col_display_name;
|
||||
const char *col_property_name;
|
||||
@@ -49,7 +56,10 @@ struct bshell_table_ctx {
|
||||
|
||||
struct bshell_value_writer {
|
||||
struct bshell_table_ctx w_table_ctx;
|
||||
enum bshell_value_writer_flags w_flags;
|
||||
size_t w_max_width;
|
||||
bool w_table_initialised;
|
||||
fx_stringstream *w_tmp;
|
||||
fx_stream *w_dest;
|
||||
};
|
||||
|
||||
@@ -82,8 +92,10 @@ extern enum bshell_status bshell_table_ctx_print_record(
|
||||
|
||||
extern void bshell_value_writer_init(
|
||||
struct bshell_value_writer *w,
|
||||
enum bshell_value_writer_flags flags,
|
||||
size_t max_width,
|
||||
fx_stream *dest);
|
||||
extern void bshell_value_writer_write(
|
||||
extern size_t bshell_value_writer_write(
|
||||
struct bshell_value_writer *w,
|
||||
const fx_value *value);
|
||||
extern void bshell_value_writer_cleanup(struct bshell_value_writer *w);
|
||||
|
||||
Reference in New Issue
Block a user