mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
io: add support for configurable line and column separators/delimiters
This commit is contained in:
parent
88af9b8c8d
commit
95e78be9ce
3 changed files with 7 additions and 3 deletions
|
@ -97,8 +97,10 @@ struct format_type {
|
|||
|
||||
/** @} */
|
||||
|
||||
size_t size; /**< Number of bytes to allocate for io::_vd */
|
||||
int flags; /**< A set of flags which is automatically used. */
|
||||
size_t size; /**< Number of bytes to allocate for io::_vd */
|
||||
int flags; /**< A set of flags which is automatically used. */
|
||||
char delimiter; /**< Newline delimiter. */
|
||||
char separator; /**< Column separator (used by csv and villas.human formats only) */
|
||||
};
|
||||
|
||||
struct format_type * format_type_lookup(const char *name);
|
||||
|
|
|
@ -41,6 +41,7 @@ struct io {
|
|||
enum state state;
|
||||
int flags;
|
||||
char delimiter; /**< Newline delimiter. */
|
||||
char separator; /**< Column separator (used by csv and villas.human formats only) */
|
||||
|
||||
struct {
|
||||
/** A format type can use this file handle or overwrite the
|
||||
|
|
3
lib/io.c
3
lib/io.c
|
@ -89,7 +89,8 @@ int io_init(struct io *io, struct format_type *fmt, struct node *n, int flags)
|
|||
io->_vd = alloc(fmt->size);
|
||||
|
||||
io->flags = flags | io->_vt->flags;
|
||||
io->delimiter = '\n';
|
||||
io->delimiter = io->_vt->delimiter ? io->_vt->delimiter : '\n';
|
||||
io->separator = io->_vt->separator ? io->_vt->separator : '\t';
|
||||
|
||||
io->input.buflen =
|
||||
io->output.buflen = 4096;
|
||||
|
|
Loading…
Add table
Reference in a new issue