actf 0.0.1
An acute CTF reader
Loading...
Searching...
No Matches
/home/adwe/code/actf/fld.h
Go to the documentation of this file.
1/*
2 * This file is a part of ACTF.
3 *
4 * Copyright (C) 2024 Adam Wendelin <adwe live se>
5 *
6 * ACTF is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * ACTF is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with ACTF. If not, see
18 * <https://www.gnu.org/licenses/>.
19 */
20
25#ifndef ACTF_FLD_H
26#define ACTF_FLD_H
27
28#include <stdbool.h>
29#include <stdint.h>
30#include <stddef.h>
31
32#include "fld_cls.h"
33#include "types.h"
34
37 ACTF_FLD_TYPE_NIL,
38 ACTF_FLD_TYPE_BOOL,
39 ACTF_FLD_TYPE_SINT,
40 ACTF_FLD_TYPE_UINT,
41 ACTF_FLD_TYPE_BIT_MAP,
42 ACTF_FLD_TYPE_REAL,
43 ACTF_FLD_TYPE_STR,
44 ACTF_FLD_TYPE_BLOB,
45 ACTF_FLD_TYPE_ARR,
46 ACTF_FLD_TYPE_STRUCT,
47};
48
55
62
68const char *actf_fld_type_name(enum actf_fld_type type);
69
81bool actf_fld_bool(const actf_fld *fld);
82
95uint64_t actf_fld_uint64(const actf_fld *fld);
96
109int64_t actf_fld_int64(const actf_fld *fld);
110
124float actf_fld_float(const actf_fld *fld);
125
139double actf_fld_double(const actf_fld *fld);
140
159const char *actf_fld_str_raw(const actf_fld *fld);
160
171size_t actf_fld_str_sz(const actf_fld *fld);
172
184const void *actf_fld_blob(const actf_fld *fld);
185
195size_t actf_fld_blob_sz(const actf_fld *fld);
196
206size_t actf_fld_arr_len(const actf_fld *fld);
207
218const actf_fld *actf_fld_arr_idx(const actf_fld *fld, size_t i);
219
230const actf_fld *actf_fld_struct_fld(const actf_fld *fld, const char *key);
231
233const actf_fld *actf_fld_struct_fldn(const actf_fld *fld, const char *key, size_t len);
234
244size_t actf_fld_struct_len(const actf_fld *fld);
245
256const actf_fld *actf_fld_struct_fld_idx(const actf_fld *fld, size_t i);
257
268const char *actf_fld_struct_fld_name_idx(const actf_fld *fld, size_t i);
269
270#endif /* ACTF_FLD_H */
size_t actf_fld_arr_len(const actf_fld *fld)
Get the number of elements in an array field.
const char * actf_fld_type_name(enum actf_fld_type type)
Get the name of a type.
int64_t actf_fld_int64(const actf_fld *fld)
Get an int64 representation of the field.
const actf_fld * actf_fld_struct_fld_idx(const actf_fld *fld, size_t i)
Get the i:th member of a struct field.
bool actf_fld_bool(const actf_fld *fld)
Get a bool representation of a field.
const actf_fld_cls * actf_fld_fld_cls(const actf_fld *fld)
Get the class of a field.
actf_fld_type
Field types.
Definition fld.h:36
size_t actf_fld_blob_sz(const actf_fld *fld)
Get the number of bytes a blob field occupies.
size_t actf_fld_str_sz(const actf_fld *fld)
Get the number of bytes the string data of a field occupies, including the null-terminator if it exis...
const actf_fld * actf_fld_struct_fldn(const actf_fld *fld, const char *key, size_t len)
Same as actf_fld_struct_fld() but with an explicit key length.
const actf_fld * actf_fld_arr_idx(const actf_fld *fld, size_t i)
Get the element of a specific index in an array field.
double actf_fld_double(const actf_fld *fld)
Get a double representation of the field.
uint64_t actf_fld_uint64(const actf_fld *fld)
Get a uint64 representation of the field.
float actf_fld_float(const actf_fld *fld)
Get a float representation of the field.
const char * actf_fld_struct_fld_name_idx(const actf_fld *fld, size_t i)
Get the name of the ith member in a struct field.
const void * actf_fld_blob(const actf_fld *fld)
Get data of a blob field.
const actf_fld * actf_fld_struct_fld(const actf_fld *fld, const char *key)
Get the member with a name matching key in a struct field.
size_t actf_fld_struct_len(const actf_fld *fld)
Get the number of members in a struct field.
const char * actf_fld_str_raw(const actf_fld *fld)
Get the raw string data representation of a field.
Field class related methods.
Basic types used by ACTF.
struct actf_fld actf_fld
A field.
Definition types.h:91
struct actf_fld_cls actf_fld_cls
A field class.
Definition types.h:93