fields.h#

namespace ONNX_LIGHT_NAMESPACE
namespace utils#
template<typename T>
class _OptionalField#
#include <fields.h>

Optional field wrapper for scalar values.

Subclassed by ONNX_LIGHT_NAMESPACE::utils::OptionalField< float >, ONNX_LIGHT_NAMESPACE::utils::OptionalField< int32_t >, ONNX_LIGHT_NAMESPACE::utils::OptionalField< int64_t >

Public Functions

inline explicit _OptionalField()#

Constructs an empty optional field.

inline bool has_value() const#

Returns true if the field holds a value.

inline void reset()#

Releases the held value, leaving the field empty.

inline const T &operator*() const#

Dereferences to the held value (const).

inline T &operator*()#

Dereferences to the held value.

inline bool operator==(const _OptionalField<T> &v) const#

Returns true if the held value equals another optional field’s value.

inline bool operator==(const T &v) const#

Returns true if the held value equals v.

inline _OptionalField<T> &operator=(const T &other)#

Assigns a scalar value to the field.

inline void set_empty_value()#

Initializes the field with zero-cast value.

Protected Attributes

std::optional<T> value_#
template<typename T>
class OptionalEnumField#
#include <fields.h>

Optional field wrapper for enum values.

Public Functions

inline explicit OptionalEnumField()#

Constructs an empty optional enum field.

inline bool has_value() const#

Returns true if the field holds a value.

inline void reset()#

Releases the held value, leaving the field empty.

inline const T &operator*() const#

Dereferences to the held value (const).

inline T &operator*()#

Dereferences to the held value.

inline bool operator==(const OptionalEnumField<T> &v) const#

Returns true if the held value equals another optional enum field’s value.

inline bool operator==(const T &v) const#

Returns true if the held value equals v.

inline OptionalEnumField<T> &operator=(const T &other)#

Assigns an enum value to the field.

inline void set_empty_value()#

Initializes the field with zero-cast enum value.

Protected Attributes

std::optional<T> value_#
template<typename T>
class OptionalField#
#include <fields.h>

Optional field wrapper for message-like values.

Public Functions

inline explicit OptionalField()#

Constructs an empty optional field.

inline explicit OptionalField(const OptionalField<T> &copy)#

Constructs by copying another optional field.

inline OptionalField(OptionalField<T> &&move) noexcept#

Constructs by moving from another optional field.

inline bool has_value() const#

Returns true if the field holds a value.

inline void reset()#

Releases the held value, leaving the field empty.

T &operator*()#

Dereferences to the held value.

const T &operator*() const#

Dereferences to the held value (const).

OptionalField<T> &operator=(const T &other)#

Assigns a copy of the given value.

OptionalField<T> &operator=(const OptionalField<T> &other)#

Assigns from another optional field.

inline OptionalField<T> &operator=(OptionalField<T> &&other) noexcept#

Moves from another optional field.

void set_empty_value()#

Initializes the field with a default-constructed value.

Private Members

simple_unique_ptr<T> value_#
template<>
class OptionalField<float> : public ONNX_LIGHT_NAMESPACE::utils::_OptionalField<float>#
#include <fields.h>

Optional field specialization for float.

Public Functions

inline explicit OptionalField()#

Constructs an empty optional float field.

inline OptionalField<float> &operator=(const float &other)#

Assigns a float value to the field.

template<>
class OptionalField<int32_t> : public ONNX_LIGHT_NAMESPACE::utils::_OptionalField<int32_t>#
#include <fields.h>

Optional field specialization for int32_t.

Public Functions

inline explicit OptionalField()#

Constructs an empty optional int32_t field.

inline OptionalField<int32_t> &operator=(const int32_t &other)#

Assigns an int32_t value to the field.

template<>
class OptionalField<int64_t> : public ONNX_LIGHT_NAMESPACE::utils::_OptionalField<int64_t>#
#include <fields.h>

Optional field specialization for int64_t.

Public Functions

inline explicit OptionalField()#

Constructs an empty optional int64_t field.

inline OptionalField<int64_t> &operator=(const int64_t &other)#

Assigns an int64_t value to the field.

struct PrintOptions#
#include <fields.h>

Options that control how a proto message is printed.

Public Members

bool skip_raw_data = false#

If true, raw data will not be printed but skipped; tensors are not valid in that case but the model structure is still available.

int64_t raw_data_threshold = 1024#

If skip_raw_data is true, raw data will be printed only if it is larger than the threshold.

template<typename T>
class RepeatedField#
#include <fields.h>

Repeated primitive field storage.

Public Functions

inline explicit RepeatedField()#

Constructs an empty field.

inline void reserve(size_t n)#

Reserves storage for at least n elements.

inline void clear()#

Removes all elements.

inline void Clear()#

Removes all elements.

inline bool empty() const#

Returns true if the field contains no elements.

inline size_t size() const#

Returns the number of elements.

inline T &operator[](size_t index)#

Returns a mutable reference to the element at the given index.

inline const T &Get(size_t index) const#

Returns a const reference to the element at the given index.

inline T *Mutable(size_t index)#

Returns a mutable reference to the owning pointer at the given index.

inline const std::vector<T> &values() const#

Returns a const reference to the underlying vector.

inline std::vector<T> &mutable_values()#

Returns a mutable reference to the underlying vector.

inline const T &operator[](size_t index) const#

Returns a const reference to the element at the given index.

inline void remove_range(size_t start, size_t stop, size_t step)#

Removes a contiguous range; currently only start=0, step=1, and stop=size() are supported.

inline void push_back(const T &v)#

Appends a copy of v at the end.

inline void extend(const std::vector<T> &v)#

Appends all elements from a vector.

inline void extend(const RepeatedField<T> &v)#

Appends all elements from another RepeatedField.

inline T &add()#
inline T *Add()#
inline T &back()#

Returns a reference to the last element.

inline std::vector<T>::iterator begin()#

Returns a mutable iterator to the first element.

inline std::vector<T>::iterator end()#

Returns a mutable iterator past the last element.

inline std::vector<T>::const_iterator begin() const#

Returns a const iterator to the first element.

inline std::vector<T>::const_iterator end() const#

Returns a const iterator past the last element.

template<class ...Args>
inline void emplace_back(Args&&... args)#

Constructs a new element in-place at the end.

std::vector<std::string> PrintToVectorString(PrintOptions &options) const#

Returns a vector of string representations of the contained values.

Private Members

std::vector<T> values_#
template<typename T>
class RepeatedProtoField#
#include <fields.h>

Repeated message field storage with owning pointers.

Public Functions

inline explicit RepeatedProtoField()#

Constructs an empty field.

inline void reserve(size_t n)#

Reserves storage for at least n elements.

inline bool empty() const#

Returns true if the field contains no elements.

inline size_t size() const#

Returns the number of elements.

inline T &operator[](size_t index)#

Returns a mutable reference to the element at the given index.

inline const T &operator[](size_t index) const#

Returns a const reference to the element at the given index.

inline simple_unique_ptr<T> &get(size_t index)#

Returns a mutable reference to the owning pointer at the given index.

inline const T &Get(size_t index)#

Returns a mutable reference to the owning pointer at the given index.

inline T *Mutable(size_t index)#

Returns a mutable reference to the owning pointer at the given index.

inline void remove_range(size_t start, size_t stop, size_t step)#

Removes a contiguous range; currently only start=0, step=1, and stop=size() are supported.

void clear()#

Removes all elements.

inline void Clear()#

Removes all elements.

void push_back(const T &v)#

Appends a copy of v at the end.

void extend(const std::vector<T> &v)#

Appends all elements from a vector.

void extend(const RepeatedProtoField<T> &v)#

Appends all elements from another RepeatedProtoField by copy.

void extend(RepeatedProtoField<T> &&v)#

Appends all elements from another RepeatedProtoField by move (steals ownership).

T &add()#

Appends a default-constructed element and returns a reference to it.

inline T *Add()#

Appends a default-constructed element and returns a pointer to it.

template<class ...Args>
inline void emplace_back(Args&&... args)#

Constructs a new element in-place at the end.

T &back()#

Returns a reference to the last element.

std::vector<std::string> PrintToVectorString(PrintOptions &options) const#

Returns a vector of string representations of the contained values.

inline iterator begin()#

Returns a mutable iterator to the first element.

inline iterator end()#

Returns a mutable iterator past the last element.

inline iterator erase(iterator it)#

Removes the element at the given iterator position and returns an iterator to the next element.

inline const_iterator begin() const#

Returns a const iterator to the first element.

inline const_iterator end() const#

Returns a const iterator past the last element.

Private Members

std::vector<simple_unique_ptr<T>> values_#
class const_iterator#
#include <fields.h>

Const iterator for repeated proto fields.

Public Functions

inline explicit const_iterator(const RepeatedProtoField<T> *parent, size_t pos = 0)#

Constructs a const iterator for parent starting at pos.

inline const_iterator &operator++()#

Advances the iterator to the next element.

inline bool operator==(const const_iterator &other) const#

Returns true if both iterators point to the same position in the same field.

inline bool operator!=(const const_iterator &other) const#

Returns true if the iterators differ.

inline const T &operator*() const#

Dereferences to the current element.

inline const T *operator->() const#

Private Members

const RepeatedProtoField<T> *parent_#
size_t pos_#
class iterator#
#include <fields.h>

Mutable iterator for repeated proto fields.

Public Functions

inline iterator(RepeatedProtoField<T> *parent, size_t pos = 0)#

Constructs an iterator for parent starting at pos.

inline iterator &operator++()#

Advances the iterator to the next element.

inline bool operator==(const iterator &other) const#

Returns true if both iterators point to the same position in the same field.

inline bool operator!=(const iterator &other) const#

Returns true if the iterators differ.

inline T &operator*() const#

Dereferences to the current element.

inline T *operator->() const#
inline size_t pos() const#

Returns the current position index.

Private Members

RepeatedProtoField<T> *parent_#
size_t pos_#
template<typename T>
class simple_unique_ptr#
#include <fields.h>

Minimal unique_ptr-like holder used by generated proto containers.

Public Functions

inline explicit simple_unique_ptr(T *ptr = nullptr)#

Constructs from a raw pointer (defaults to null); takes ownership if non-null.

inline ~simple_unique_ptr()#

Releases owned memory.

inline simple_unique_ptr(simple_unique_ptr &&other) noexcept#

Constructs by taking ownership from another instance.

inline simple_unique_ptr &operator=(simple_unique_ptr &&other) noexcept#

Transfers ownership from another instance.

inline bool isnull() const#

Returns true if the held pointer is null.

inline bool operator==(const simple_unique_ptr &other) const#

Returns true if both instances hold the same pointer.

inline bool operator!=(const simple_unique_ptr &other) const#

Returns true if the instances hold different pointers.

inline simple_unique_ptr(const simple_unique_ptr&)#

Deleted copy constructor; use move semantics instead.

inline simple_unique_ptr &operator=(const simple_unique_ptr&)#

Deleted copy assignment; use move semantics instead.

inline T *get() const#

Returns the raw pointer without releasing ownership.

inline T &operator*() const#

Dereferences the held pointer.

inline T *operator->() const#

Provides member access through the held pointer.

inline T &reset_and(T *new_ptr)#

Replaces the held pointer and returns a reference to the new object.

inline void reset(T *new_ptr = nullptr)#

Deletes the held object and optionally takes a new pointer.

Private Members

T *ptr_#