43 for (p =
src; *p; p++) {
64 char meta_chars[] = { sep,
'"',
'\n',
'\r',
'\0' };
66 int needs_quoting = !!
src[strcspn(
src, meta_chars)];
93 const char * (*escape_str)(AVBPrint *
dst,
const char *
src,
const char sep,
void *log_ctx);
105#define OFFSET(x) offsetof(CompactContext, x)
131 av_log(wctx,
AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
181 if (parent_section &&
200 for (
const char *p = section->
get_type(
data); *p; p++) {
202 (*p >=
'0' && *p <=
'9') ||
203 (*p >=
'a' && *p <=
'z') ||
204 (*p >=
'A' && *p <=
'Z') ?
av_tolower(*p) :
'_';
284 snprintf(buf,
sizeof(buf),
"%"PRId64,
value);
298 .priv_class = &compact_class,
304#define OFFSET(x) offsetof(CompactContext, x)
330 .priv_class = &csv_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const AVTextFormatter avtextformatter_compact
#define AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE
For these sections the element_name field is mandatory.
#define SECTION_MAX_NB_LEVELS
#define AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS
const AVTextFormatter avtextformatter_csv
#define AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER
the section only contains other sections, but has no data at its own level
#define AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY
the section contains an array of elements of the same type
Convenience header that includes libavutil's core.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
int(* init)(AVBSFContext *ctx)
static void print_section(SectionID id, int level)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
int level
current level, starting from 0
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various formatters
const char * element_name
name of the contained element, if provided
const char *(* get_type)(const void *data)
function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
AVBPrint rows[SECTION_MAX_NB_LEVELS]
the lines of the rows nested in the row at this level
const char *(* escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
int row_level[SECTION_MAX_NB_LEVELS]
level of the row whose line the fields at this level belong to, -1 for none
AVBPrint line[SECTION_MAX_NB_LEVELS]
the line of the row at this level
int nb_fields[SECTION_MAX_NB_LEVELS]
number of fields written to the row at this level
static void compact_print_str(AVTextFormatContext *wctx, const char *key, const char *value)
static void compact_print_int(AVTextFormatContext *wctx, const char *key, int64_t value)
static void bprint_append_bprint(AVBPrint *dst, const AVBPrint *src)
static const AVOption csv_options[]
static const AVOption compact_options[]
static void compact_print_section_header(AVTextFormatContext *wctx, const void *data)
static const char * csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Quote fields containing special characters, check RFC4180.
static const char * c_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Apply C-language-like string escaping.
static void compact_print_field(AVTextFormatContext *wctx, const char *key, const char *value)
static void compact_print_section_footer(AVTextFormatContext *wctx)
static av_cold int compact_init(AVTextFormatContext *wctx)
static av_cold int compact_uninit(AVTextFormatContext *wctx)
static const char * none_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Internal utilities for text formatters.
static const AVTextFormatSection * tf_get_section(AVTextFormatContext *tfc, int level)
Safely validate and access a section at a given level.
static const AVTextFormatSection * tf_get_parent_section(AVTextFormatContext *tfc, int level)
Safely access the parent section.
#define DEFINE_FORMATTER_CLASS(name)
static void writer_put_str(AVTextFormatContext *wctx, const char *str)