FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
Loading...
Searching...
No Matches
fdl_enum_map.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024-present American Society Of Cinematographers
2// SPDX-License-Identifier: Apache-2.0
10#ifndef FDL_ENUM_MAP_H
11#define FDL_ENUM_MAP_H
12
13#include "fdl/fdl_core.h"
14
15#include <string>
16#include <string_view>
17
18namespace fdl::detail {
19
25inline fdl_fit_method_t fit_method_from_string(std::string_view s) {
26 if (s == "width") {
28 }
29 if (s == "height") {
31 }
32 if (s == "fit_all") {
34 }
35 if (s == "fill") {
37 }
38 return FDL_FIT_METHOD_WIDTH; // default
39}
40
47 if (s == "canvas.dimensions") {
49 }
50 if (s == "canvas.effective_dimensions") {
52 }
53 if (s == "framing_decision.protection_dimensions") {
55 }
56 if (s == "framing_decision.dimensions") {
58 }
60}
61
67inline fdl_halign_t halign_from_string(std::string_view s) {
68 if (s == "left") {
69 return FDL_HALIGN_LEFT;
70 }
71 if (s == "center") {
72 return FDL_HALIGN_CENTER;
73 }
74 if (s == "right") {
75 return FDL_HALIGN_RIGHT;
76 }
77 return FDL_HALIGN_CENTER; // default
78}
79
85inline fdl_valign_t valign_from_string(std::string_view s) {
86 if (s == "top") {
87 return FDL_VALIGN_TOP;
88 }
89 if (s == "center") {
90 return FDL_VALIGN_CENTER;
91 }
92 if (s == "bottom") {
93 return FDL_VALIGN_BOTTOM;
94 }
95 return FDL_VALIGN_CENTER; // default
96}
97
104 if (s == "even") {
106 }
107 if (s == "whole") {
109 }
110 return FDL_ROUNDING_EVEN_WHOLE; // default
111}
112
119 if (s == "up") {
121 }
122 if (s == "down") {
124 }
125 if (s == "round") {
127 }
128 return FDL_ROUNDING_MODE_ROUND; // default
129}
130
140 switch (m) {
142 return "width";
144 return "height";
146 return "fit_all";
148 return "fill";
149 default:
150 return "width";
151 }
152}
153
160 switch (p) {
162 return "canvas.dimensions";
164 return "canvas.effective_dimensions";
166 return "framing_decision.protection_dimensions";
167 default:
168 return "framing_decision.dimensions";
169 }
170}
171
177inline const char* halign_to_string(fdl_halign_t h) {
178 switch (h) {
179 case FDL_HALIGN_LEFT:
180 return "left";
182 return "center";
183 case FDL_HALIGN_RIGHT:
184 return "right";
185 default:
186 return "center";
187 }
188}
189
195inline const char* valign_to_string(fdl_valign_t v) {
196 switch (v) {
197 case FDL_VALIGN_TOP:
198 return "top";
200 return "center";
202 return "bottom";
203 default:
204 return "center";
205 }
206}
207
214 switch (e) {
216 return "whole";
218 return "even";
219 default:
220 return "whole";
221 }
222}
223
230 switch (m) {
232 return "up";
234 return "down";
235 default:
236 return "round";
237 }
238}
239
242} // namespace fdl::detail
243
244#endif // FDL_ENUM_MAP_H
Public C ABI for the FDL (Framing Decision List) core library.
#define FDL_FIT_METHOD_FILL
Scale to fill target completely (may crop).
Definition fdl_core.h:155
#define FDL_GEOMETRY_PATH_CANVAS_EFFECTIVE_DIMENSIONS
Effective (active image) dimensions.
Definition fdl_core.h:146
#define FDL_VALIGN_BOTTOM
Align to bottom edge.
Definition fdl_core.h:167
#define FDL_HALIGN_CENTER
Center horizontally.
Definition fdl_core.h:160
#define FDL_ROUNDING_MODE_ROUND
Round to nearest (half-to-even).
Definition fdl_core.h:136
#define FDL_ROUNDING_EVEN_EVEN
Snap to nearest even integer after rounding.
Definition fdl_core.h:141
#define FDL_FIT_METHOD_FIT_ALL
Scale to fit entirely within target (letterbox/pillarbox).
Definition fdl_core.h:154
uint64_t fdl_rounding_mode_t
Rounding mode — direction to round fractional pixel values.
Definition fdl_core.h:133
#define FDL_ROUNDING_MODE_UP
Always round up (ceiling).
Definition fdl_core.h:134
#define FDL_VALIGN_TOP
Align to top edge.
Definition fdl_core.h:165
uint32_t fdl_fit_method_t
Fit method — how source content is scaled into the target canvas.
Definition fdl_core.h:151
#define FDL_ROUNDING_EVEN_WHOLE
No even constraint (round to nearest integer).
Definition fdl_core.h:140
#define FDL_ROUNDING_MODE_DOWN
Always round down (floor).
Definition fdl_core.h:135
#define FDL_HALIGN_RIGHT
Align to right edge.
Definition fdl_core.h:161
#define FDL_FIT_METHOD_WIDTH
Scale to match target width.
Definition fdl_core.h:152
#define FDL_GEOMETRY_PATH_CANVAS_DIMENSIONS
Full canvas dimensions.
Definition fdl_core.h:145
uint64_t fdl_rounding_even_t
Rounding even — whether to snap results to even numbers.
Definition fdl_core.h:139
uint32_t fdl_geometry_path_t
Geometry path — selects a dimension layer within the FDL hierarchy.
Definition fdl_core.h:144
uint32_t fdl_valign_t
Vertical alignment — how content is positioned vertically.
Definition fdl_core.h:164
#define FDL_GEOMETRY_PATH_FRAMING_PROTECTION_DIMENSIONS
Protection area dimensions.
Definition fdl_core.h:147
#define FDL_GEOMETRY_PATH_FRAMING_DIMENSIONS
Framing decision dimensions.
Definition fdl_core.h:148
#define FDL_HALIGN_LEFT
Align to left edge.
Definition fdl_core.h:159
#define FDL_VALIGN_CENTER
Center vertically.
Definition fdl_core.h:166
uint32_t fdl_halign_t
Horizontal alignment — how content is positioned horizontally.
Definition fdl_core.h:158
#define FDL_FIT_METHOD_HEIGHT
Scale to match target height.
Definition fdl_core.h:153
const char * rounding_mode_to_string(fdl_rounding_mode_t m)
Convert rounding mode enum to canonical JSON string.
Definition fdl_enum_map.h:229
const char * rounding_even_to_string(fdl_rounding_even_t e)
Convert rounding even enum to canonical JSON string.
Definition fdl_enum_map.h:213
const char * valign_to_string(fdl_valign_t v)
Convert vertical alignment enum to canonical JSON string.
Definition fdl_enum_map.h:195
fdl_rounding_even_t rounding_even_from_string(std::string_view s)
Convert rounding even string to enum.
Definition fdl_enum_map.h:103
const char * fit_method_to_string(fdl_fit_method_t m)
Convert fit method enum to canonical JSON string.
Definition fdl_enum_map.h:139
fdl_rounding_mode_t rounding_mode_from_string(std::string_view s)
Convert rounding mode string to enum.
Definition fdl_enum_map.h:118
fdl_halign_t halign_from_string(std::string_view s)
Convert horizontal alignment string to enum.
Definition fdl_enum_map.h:67
const char * halign_to_string(fdl_halign_t h)
Convert horizontal alignment enum to canonical JSON string.
Definition fdl_enum_map.h:177
const char * geometry_path_to_string(fdl_geometry_path_t p)
Convert geometry path enum to canonical JSON string.
Definition fdl_enum_map.h:159
fdl_fit_method_t fit_method_from_string(std::string_view s)
Convert fit method string to enum.
Definition fdl_enum_map.h:25
fdl_geometry_path_t geometry_path_from_string(std::string_view s)
Convert geometry path string to enum.
Definition fdl_enum_map.h:46
fdl_valign_t valign_from_string(std::string_view s)
Convert vertical alignment string to enum.
Definition fdl_enum_map.h:85