24 #include <type_traits> 116 template <
typename T>
119 using BaseType =
typename std::remove_cv_t<
120 typename std::remove_pointer_t<typename std::remove_reference_t<T>>>;
121 using RequiredType =
typename std::conditional_t<is_string_v<BaseType>, T, BaseType>;
123 if (getExpectedUnirecType<RequiredType>() !=
ur_get_type(fieldID)) {
124 throw std::runtime_error(
125 "UnirecRecord data type format mismatch: " + std::string(
typeid(T).name()));
128 if constexpr (is_string_v<T>) {
133 }
else if constexpr (std::is_pointer_v<T>) {
135 }
else if constexpr (std::is_reference_v<T>) {
136 return *
reinterpret_cast<BaseType*
>(
158 template <
typename T>
168 template <
typename T>
#define ur_get_type(field_id)
Get type of UniRec field Get type of any UniRec defined field.
uint64_t m_sequenceNumber
add_const_t< T > getFieldAsType(ur_field_id_t fieldID) const
Gets the value of a field as a type T.
#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...
A wrapper class for a contiguous array of values with the same unirec fieldID.
ur_template_t * m_unirecTemplate
#define ur_rec_size(tmplt, rec)
Get size of UniRec record (static and variable length) Get total size of whole UniRec record...
add_const_t< T > getFieldAsStringType(ur_field_id_t fieldID) const
A class for working with UniRec records and their fields.
typename add_const< T >::type add_const_t
Provides a set of type traits and aliases for working with unirec++.
const void * m_recordData
#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...
int16_t ur_field_id_t
Type of UniRec field identifiers.
UnirecRecordView(const void *unirecRecordData, ur_template_t *unirecTemplate, uint64_t sequenceNumber=0)
Constructs a UnirecRecordView object.
Definition of UniRec structures and functions.
#define ur_array_get_elem_cnt(tmplt, rec, field_id)
Get number of elements stored in an UniRec array.
size_t size() const noexcept
Returns the size of the UniRec record.
const void * data() const noexcept
Returns a const pointer to the data of the UniRec record.
This file contains functions for determining the expected UniRec type for various C++ types...
uint64_t getSequenceNumber() const noexcept
Gets the sequence number of the record.
Provides a view into a UniRec record.
UniRec template. It contains a table mapping a field to its position in an UniRec record...
Header file containing the definition of the UnirecArray class and its Iterator subclass.
add_const_t< UnirecArray< T > > getFieldAsUnirecArray(ur_field_id_t fieldID) const
Gets the value of a field as a UnirecArray.