Dev Essential  1.6.3
Loading...
Searching...
No Matches
access_element_legacy.h
Go to the documentation of this file.
1
14#ifndef DDL_STRUCT_ELEMENT_ACCESS_LEGACY_CLASS_HEADER
15#define DDL_STRUCT_ELEMENT_ACCESS_LEGACY_CLASS_HEADER
16
17#include <a_util/result.h>
19
20namespace ddl {
21namespace access_element {
22
26_MAKE_RESULT(-20, ERR_STRUCT_ELEMENT_NOT_FOUND);
27
34template <typename AccessType>
36public:
43 {
44 return &_legacy_struct_element;
45 }
46
53 const ddl::StructElement* getStructElement(const AccessType& access, size_t leaf_index) const
54 {
55 auto codec_index = access.resolve(leaf_index, _legacy_struct_element.name);
56 const auto& layout = codec_index.getLayout();
57 const auto& type_info = *(layout.type_info);
58 _legacy_struct_element.p_enum = type_info.getLegacyAccessEnumType();
59 _legacy_struct_element.type =
60 static_cast<const a_util::variant::VariantType>(type_info.getType());
61 return getStructElement();
62 }
63
72 a_util::result::Result getStructElement(const AccessType& access,
73 size_t leaf_index,
74 const ddl::StructElement*& struct_element) const
75 {
76 try {
77 struct_element = getStructElement(access, leaf_index);
78 return {};
79 }
80 catch (...) {
81 RETURN_ERROR_DESCRIPTION(ERR_STRUCT_ELEMENT_NOT_FOUND, "the struct element was not found");
82 }
83 }
84
85private:
86 mutable ddl::StructElement _legacy_struct_element = {};
87};
88
89} // namespace access_element
90} // namespace ddl
91
92#endif // DDL_STRUCT_ELEMENT_ACCESS_LEGACY_CLASS_HEADER
Definition result_type_decl.h:34
Legacy helper for the ddl::StructElement.
Definition access_element_legacy.h:35
a_util::result::Result getStructElement(const AccessType &access, size_t leaf_index, const ddl::StructElement *&struct_element) const
Fill the local Struct Element and retrieves the Struct Element pointer for legacy in struct_element.
Definition access_element_legacy.h:72
const ddl::StructElement * getStructElement() const
Get the converted StructElement pointer.
Definition access_element_legacy.h:42
const ddl::StructElement * getStructElement(const AccessType &access, size_t leaf_index) const
Fill the local Struct Element and retrieves the Struct Element pointer for legacy.
Definition access_element_legacy.h:53
#define RETURN_ERROR_DESCRIPTION(_errcode,...)
Definition error_def.h:39
VariantType
Enumeration of supported Variant types.
Definition variant.h:25
definition of the access_element namespace (codecs)
Definition access_element.h:25
definition of the ddl namespace
Definition codec.h:21
#define _MAKE_RESULT(_no, _label)
Definition result_info_decl.h:36
Definition struct_element.h:32