FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
Loading...
Searching...
No Matches
fdl_custom_attr.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024-present American Society Of Cinematographers
2// SPDX-License-Identifier: Apache-2.0
12#ifndef FDL_CUSTOM_ATTR_INTERNAL_H
13#define FDL_CUSTOM_ATTR_INTERNAL_H
14
15#include <jsoncons/json.hpp>
16#include <string>
17
18#include "fdl/fdl_core.h"
19#include "fdl_constants.h"
20
21namespace fdl::detail::custom_attr {
22
24using ojson = jsoncons::ojson;
25
31std::string make_key(const char* name);
32
39bool has(const ojson* node, const char* name);
40
47fdl_custom_attr_type_t get_type(const ojson* node, const char* name);
48
56int set_string(ojson* node, const char* name, const char* value);
57
65int set_int(ojson* node, const char* name, int64_t value);
66
74int set_float(ojson* node, const char* name, double value);
75
83int set_bool(ojson* node, const char* name, int value);
84
91const char* get_string(const ojson* node, const char* name);
92
100int get_int(const ojson* node, const char* name, int64_t* out);
101
109int get_float(const ojson* node, const char* name, double* out);
110
118int get_bool(const ojson* node, const char* name, int* out);
119
128int set_point_f64(ojson* node, const char* name, double x, double y);
129
138int get_point_f64(const ojson* node, const char* name, double* x, double* y);
139
148int set_dims_f64(ojson* node, const char* name, double width, double height);
149
158int get_dims_f64(const ojson* node, const char* name, double* width, double* height);
159
168int set_dims_i64(ojson* node, const char* name, int64_t width, int64_t height);
169
178int get_dims_i64(const ojson* node, const char* name, int64_t* width, int64_t* height);
179
186int remove(ojson* node, const char* name);
187
193uint32_t count(const ojson* node);
194
205const char* name_at(const ojson* node, uint32_t index);
206
207} // namespace fdl::detail::custom_attr
208
209#endif // FDL_CUSTOM_ATTR_INTERNAL_H
Named constants replacing magic numbers throughout the FDL core library.
Public C ABI for the FDL (Framing Decision List) core library.
uint32_t fdl_custom_attr_type_t
Type identifier for custom attributes.
Definition fdl_core.h:40
int get_dims_i64(const ojson *node, const char *name, int64_t *width, int64_t *height)
Get a dims_i64 custom attribute.
Definition fdl_custom_attr.cpp:334
int remove(ojson *node, const char *name)
Remove a custom attribute.
Definition fdl_custom_attr.cpp:362
int set_dims_f64(ojson *node, const char *name, double width, double height)
Set a dims_f64 custom attribute.
Definition fdl_custom_attr.cpp:208
int set_dims_i64(ojson *node, const char *name, int64_t width, int64_t height)
Set a dims_i64 custom attribute.
Definition fdl_custom_attr.cpp:217
std::string make_key(const char *name)
Build the internal key by prepending '_' to the user-visible name.
Definition fdl_custom_attr.cpp:53
const char * get_string(const ojson *node, const char *name)
Get a string custom attribute.
Definition fdl_custom_attr.cpp:230
int set_float(ojson *node, const char *name, double value)
Set a floating-point custom attribute.
Definition fdl_custom_attr.cpp:187
int get_dims_f64(const ojson *node, const char *name, double *width, double *height)
Get a dims_f64 custom attribute.
Definition fdl_custom_attr.cpp:313
int set_string(ojson *node, const char *name, const char *value)
Set a string custom attribute.
Definition fdl_custom_attr.cpp:175
int set_int(ojson *node, const char *name, int64_t value)
Set an integer custom attribute.
Definition fdl_custom_attr.cpp:182
int get_point_f64(const ojson *node, const char *name, double *x, double *y)
Get a point_f64 custom attribute.
Definition fdl_custom_attr.cpp:296
bool has(const ojson *node, const char *name)
Check if a custom attribute exists on a node.
Definition fdl_custom_attr.cpp:64
const char * name_at(const ojson *node, uint32_t index)
Get the name of a custom attribute by index.
Definition fdl_custom_attr.cpp:391
int set_point_f64(ojson *node, const char *name, double x, double y)
Set a point_f64 custom attribute.
Definition fdl_custom_attr.cpp:199
int get_int(const ojson *node, const char *name, int64_t *out)
Get an integer custom attribute.
Definition fdl_custom_attr.cpp:244
int get_bool(const ojson *node, const char *name, int *out)
Get a boolean custom attribute.
Definition fdl_custom_attr.cpp:276
uint32_t count(const ojson *node)
Count the number of custom attributes on a node.
Definition fdl_custom_attr.cpp:378
fdl_custom_attr_type_t get_type(const ojson *node, const char *name)
Get the type of a custom attribute.
Definition fdl_custom_attr.cpp:71
int set_bool(ojson *node, const char *name, int value)
Set a boolean custom attribute.
Definition fdl_custom_attr.cpp:191
int get_float(const ojson *node, const char *name, double *out)
Get a floating-point custom attribute.
Definition fdl_custom_attr.cpp:260
jsoncons::ojson ojson
Alias for ordered JSON type.
Definition fdl_custom_attr.h:24