MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ decode_text_field()

template<typename T>
bool MayaFlux::Reflect::decode_text_field ( std::string_view name,
std::string_view source,
T & value,
std::string_view label,
std::string & error )

Decode one authored text value into a described member.

Parameters
labelNames the owner in the diagnostic.

Definition at line 13 of file TextBinding.hpp.

15{
16 if constexpr (TextDecodable<T>) {
18 if (TextCodec<T>::decode(source, value, reason))
19 return true;
20 if (reason == TextError::Cardinality) {
21 const char* shape = " numbers in ";
22 if constexpr (requires { TextCodec<T>::sequence; })
23 shape = " numbers per group in ";
24 error = "<" + std::string(label) + "> needs "
25 + std::to_string(TextCodec<T>::extent) + shape
26 + std::string(name);
27 } else if (reason == TextError::Unsupported) {
28 error = "<" + std::string(label) + "> has an unsupported "
29 + std::string(name) + " " + std::string(source);
30 } else {
31 error = "<" + std::string(label) + "> has an invalid "
32 + std::string(name) + " attribute";
33 }
34 } else {
35 error = "<" + std::string(label) + "> has an unsupported attribute "
36 + std::string(name);
37 }
38 return false;
39}
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.
Conversion of authored text to one value type.
Definition TextCodec.hpp:81

References Cardinality, Invalid, and Unsupported.

Referenced by overlay_text_fields(), and MayaFlux::IO::overlay_xml_element().

Here is the caller graph for this function: