62 throw std::runtime_error(
"Allocation of UniRec record failed");
69 throw std::runtime_error(
70 "UnirecRecord::copyFieldsFrom() has failed. Record has no template or allocated "
88 throw std::runtime_error(
89 "UnirecRecord::copyFieldsFrom() has failed. Record has no template or allocated "
157 using BaseType =
typename std::remove_cv_t<
158 typename std::remove_pointer_t<typename std::remove_reference_t<T>>>;
164 }
else if constexpr (std::is_pointer_v<T>) {
166 }
else if constexpr (std::is_reference_v<T>) {
227 throw std::runtime_error(
"Unable to allocate memory for UnirecArray");
289 if (&
other ==
this) {
320 throw std::runtime_error(
"Cannot set vector to non-array unirec field");
334 using BaseType =
typename std::remove_cv_t<
335 typename std::remove_pointer_t<typename std::remove_reference_t<T>>>;
346 throw std::runtime_error(
347 "UnirecRecord data type format mismatch: " + std::string(
typeid(
T).name()));
381 if (
other.m_recordData !=
nullptr) {
385 throw std::runtime_error(
"Allocation of UniRec record failed");
A wrapper class for a contiguous array of values with the same unirec fieldID.
Provides a view into a UniRec record.
A class for working with UniRec records and their fields.
UnirecArray< T > getFieldAsUnirecArray(ur_field_id_t fieldID)
Gets a UniRecArray representing a UniRec field.
T getFieldAsType(ur_field_id_t fieldID) const
Gets the value of a UniRec field and converts it to the specified type.
T getFieldAsPointer(ur_field_id_t fieldID) const
~UnirecRecord()
Destructor.
void checkDataTypeCompatibility(ur_field_id_t fieldID) const
UnirecArray< T > reserveUnirecArray(size_t elementsCount, ur_field_id_t fieldID)
Reserves memory for a UniRecArray within a UniRec field.
void setFieldFromUnirecArray(const UnirecArray< T > &unirecArray, ur_field_id_t fieldID)
Sets the value of a UniRec field using a UnirecArray.
void copyFieldsFrom(const UnirecRecord &otherRecord)
T getFieldAsReference(ur_field_id_t fieldID) const
void setFieldFromType(const T &fieldData, ur_field_id_t fieldID)
Sets the value of a UniRec field using data of a specified type.
ur_template_t * m_unirecTemplate
UnirecRecord(ur_template_t *unirecTemplate, size_t maxVariableFieldsSize=UR_MAX_SIZE)
Constructor with template and maximum variable fields size.
const void * data() const noexcept
Returns a pointer to the data of the UniRec record.
void copyFrom(const UnirecRecord &other)
UnirecRecord()
Default constructor.
T getFieldAsValue(ur_field_id_t fieldID) const
UnirecRecord(const UnirecRecord &other)
UnirecRecord & operator=(const UnirecRecord &other)
size_t size() const noexcept
Returns the size of the UniRec record.
T getFieldAsStringType(ur_field_id_t fieldID) const
void setFieldFromVector(const std::vector< T > &sourceVector, ur_field_id_t fieldID)
Sets the value of a UniRec array field using a vector of values.
void copyFieldsFrom(const UnirecRecordView &otherRecordView)
#define ur_set_string(tmplt, rec, field_id, str)
Set variable-length field to given string. Set contents of a variable-length field in the record....
#define ur_array_allocate(tmplt, rec, field_id, elem_cnt)
Preallocates UniRec array field to have requested number of elements.
#define ur_is_array(field_id)
#define ur_rec_size(tmplt, rec)
Get size of UniRec record (static and variable length) Get total size of whole UniRec record.
void * ur_create_record(const ur_template_t *tmplt, uint16_t max_var_size)
#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.
void ur_copy_fields(const ur_template_t *dst_tmplt, void *dst, const ur_template_t *src_tmplt, const void *src)
Copy data from one UniRec record to another. Copies all fields present in both templates from src to ...
#define ur_get_type(field_id)
Get type of UniRec field Get type of any UniRec defined field.
void ur_free_record(void *record)
#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...
constexpr ur_field_type_t getExpectedUnirecType()
Determines the expected UniRec field type for a given C++ type T.
Header file containing the definition of the UnirecArray class and its Iterator subclass.
Provides a view into a UniRec record.
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.