24 #include <type_traits>
98 using BaseType =
typename std::remove_cv_t<
99 typename std::remove_pointer_t<typename std::remove_reference_t<T>>>;
100 using RequiredType =
typename std::conditional_t<is_string_v<BaseType>, T, BaseType>;
102 if (getExpectedUnirecType<RequiredType>() !=
ur_get_type(fieldID)) {
103 throw std::runtime_error(
104 "UnirecRecord data type format mismatch: " + std::string(
typeid(T).name()));
107 if constexpr (is_string_v<T>) {
111 }
else if constexpr (std::is_pointer_v<T>) {
113 }
else if constexpr (std::is_reference_v<T>) {
114 return *
reinterpret_cast<BaseType*
>(
A wrapper class for a contiguous array of values with the same unirec fieldID.
Provides a view into a UniRec record.
add_const_t< T > getFieldAsStringType(ur_field_id_t fieldID) const
size_t size() const noexcept
Returns the size of the UniRec record.
add_const_t< UnirecArray< T > > getFieldAsUnirecArray(ur_field_id_t fieldID) const
Gets the value of a field as a UnirecArray.
const void * m_recordData
ur_template_t * m_unirecTemplate
const void * data() const noexcept
Returns a const pointer to the data of the UniRec record.
UnirecRecordView(const void *unirecRecordData, ur_template_t *unirecTemplate)
Constructs a UnirecRecordView object.
add_const_t< T > getFieldAsType(ur_field_id_t fieldID) const
Gets the value of a field as a type T.
A class for working with UniRec records and their fields.
#define ur_rec_size(tmplt, rec)
Get size of UniRec record (static and variable length) Get total size of whole UniRec record.
#define ur_get_var_len(tmplt, rec, field_id)
Get size of a variable sized field in the record. Get size of a variable-length field in the record....
#define ur_array_get_elem_cnt(tmplt, rec, field_id)
Get number of elements stored in an UniRec array.
#define ur_get_type(field_id)
Get type of UniRec field Get type of any UniRec defined field.
#define ur_get_ptr_by_id(tmplt, data, field_id)
Get pointer to UniRec field Get pointer to fixed or varible length UniRec field. In contrast to ur_ge...
typename add_const< T >::type add_const_t
Header file containing the definition of the UnirecArray class and its Iterator subclass.
Provides a set of type traits and aliases for working with unirec++.
This file contains functions for determining the expected UniRec type for various C++ types.
Definition of UniRec structures and functions.
int16_t ur_field_id_t
Type of UniRec field identifiers.
UniRec template. It contains a table mapping a field to its position in an UniRec record.