minor
This commit is contained in:
parent
f87a098fe4
commit
62beed20a9
@ -1074,7 +1074,7 @@ Str8 fmt_vtoken_slice(SliceMem buffer, SliceFmtTokEntry tokens, Str8 fmt_templat
|
||||
// Sync cursor format to after the processed token
|
||||
cursor_fmt = cursor_potential_token + potential_token_length + 1;
|
||||
curr_code = * cursor_fmt;
|
||||
left_fmt -= potential_token_length + 2; // The 2 here ar ethe '<' & '>' delimiters being omitted.
|
||||
left_fmt -= potential_token_length + 2; // The 2 here are the '<' & '>' delimiters being omitted.
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1116,16 +1116,27 @@ Str8 fmt__vtoken(SliceMem backing, Str8 fmt_template, SliceStr8* tokens)
|
||||
return result;
|
||||
}
|
||||
|
||||
#define fmt_vtoken(backing, fmt_template, tokens) fmt__vtoken(backing, fmt_template, &(SliceStr8){.ptr = tokens, .len = size_of(tokens) / size_of(Str8) })
|
||||
// Expected to take a Str8 array of entries formatted as a 2D array of key-value pairs (Str8[length][2])
|
||||
// The array will be tracked using a SliceStr8 structure.
|
||||
#define fmt_vtoken(backing, fmt_template, tokens) fmt__vtoken(backing, fmt_template, &(SliceStr8){.ptr = cast(Str8*, tokens), .len = size_of(tokens) / size_of(Str8) })
|
||||
|
||||
/*
|
||||
Define a mapping array:
|
||||
Str8 mappings [][2] = {
|
||||
fmt_vtoken_entry("key", "value"),
|
||||
^^ Add entries as above ^^
|
||||
}
|
||||
*/
|
||||
#define fmt_vtoken_entry(key, value) { lit(key), lit(value) }
|
||||
|
||||
#ifdef DEMO__WATL_DUMP_V1
|
||||
int main()
|
||||
{
|
||||
SliceMem scratch = slicemem_alloc(MEGABYTES(64));
|
||||
Str8 mappings [] = {
|
||||
lit("maybe_sub"), lit("IT SUBST!!!!"),
|
||||
Str8 subst_table [][2] = {
|
||||
fmt_vtoken_entry("maybe_sub", "IT SUBST!!!"),
|
||||
};
|
||||
Str8 test_str = fmt_vtoken(scratch, lit("Will this work? <maybe_sub>"), mappings);
|
||||
Str8 test_str = fmt_vtoken(scratch, lit("Will this work? <maybe_sub>"), subst_table);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user