CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
format_private.h
1#pragma once
2
3#include "format.h"
4#include "cx/container.h"
5#include "cx/string.h"
6
7enum FORMAT_TYPES {
8 FMT_string,
9 FMT_int,
10 FMT_uint,
11 FMT_float,
12 FMT_ptr,
13 FMT_suid,
14 FMT_object,
15 FMT_count
16};
17extern string _fmtTypeNames[FMT_count];
18extern uint8 _fmtTypeIdMask[FMT_count][2];
19extern bool(*_fmtTypeParseOpt[FMT_count])(FMTVar *v, strref opt);
20extern bool(*_fmtTypeParseFinalize[FMT_count])(FMTVar *v);
21extern bool(*_fmtTypeFormat[FMT_count])(FMTVar *v, string *out);
22
23typedef struct FMTContext {
24 int32 nargs;
25 stvar *args;
26 int32 startarg[FMT_count]; // where to start searching for each type
27 int32 arrayidx; // arrary index counter
28
29 string tmp; // temporary storage for high-level operations
30 string *dest; // output string so far
31
32 string fmt; // format string parse state
33 int32 vstart;
34 int32 vend;
35 int32 flen;
36
37 FMTVar v; // current variable
38} FMTContext;
39
40bool _fmtExtractVar(_Inout_ FMTContext *ctx);
41bool _fmtParseVar(_Inout_ FMTContext *ctx);
42bool _fmtFindData(_Inout_ FMTContext *ctx);
43void _fmtFormat(_Inout_ FMTContext *ctx);
44
45// type-specific formatters
46bool _fmtParseStringOpt(_Inout_ FMTVar *v, _In_ strref opt);
47bool _fmtString(_Inout_ FMTVar *v, _Inout_ string *out);
48bool _fmtParseIntOpt(_Inout_ FMTVar *v, _In_ strref opt);
49bool _fmtParseIntFinalize(_Inout_ FMTVar *v);
50bool _fmtInt(_Inout_ FMTVar *v, _Inout_ string *out);
51bool _fmtParseFloatOpt(_Inout_ FMTVar *v, _In_ strref opt);
52bool _fmtParseFloatFinalize(_Inout_ FMTVar *v);
53bool _fmtFloat(_Inout_ FMTVar *v, _Inout_ string *out);
54bool _fmtParsePtrOpt(_Inout_ FMTVar *v, _In_ strref opt);
55bool _fmtParsePtrFinalize(_Inout_ FMTVar *v);
56bool _fmtParseObjectOpt(_Inout_ FMTVar *v, _In_ strref opt);
57bool _fmtPtr(_Inout_ FMTVar *v, _Inout_ string *out);
58bool _fmtSUID(_Inout_ FMTVar *v, _Inout_ string *out);
59bool _fmtObject(_Inout_ FMTVar *v, _Inout_ string *out);
Generic type-safe containers with runtime type system integration.
#define stvar(typen, val)
Definition stvar.h:153
Copy-on-write strings with automatic memory management and rope optimization.
Format variable descriptor for Formattable interface implementations.
Definition format.h:165