fields.h#
-
namespace onnx_light
Alias that makes onnx-light headers compatible with code that references
ONNX_LIGHT_NAMESPACE(the macro used in the standard onnx package).Set to
ONNX_LIGHT_NAMESPACEso both names resolve to the same namespace.Symbol-visibility attribute for the public onnx-light C++ API.
Defined as empty because onnx-light does not require explicit
__declspec(dllexport)or__attribute__((visibility("default")))annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations withONNX_APIcompile without modification.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_light(via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs fromonnx.-
namespace utils#
Functions
-
inline bool is_inline_size(const PrintOptions &options, size_t size)#
Returns true if a repeated field of the given size should be printed inline on a single row.
-
template<typename T>
RepeatedFieldBackInsertIterator<T> RepeatedFieldBackInserter(RepeatedField<T> *field)# Creates a back-insert iterator for a RepeatedField.
-
template<typename T>
class _OptionalField# - #include <fields.h>
Optional field wrapper for scalar values.
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 bool operator==(const _OptionalField<T> &v) const#
Returns true if the held value equals another optional field’s value.
-
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.
-
inline explicit _OptionalField()#
-
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 bool operator==(const OptionalEnumField<T> &v) const#
Returns true if the held value equals another optional enum field’s value.
-
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.
-
inline explicit OptionalEnumField()#
-
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> ©)#
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.
-
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_#
-
inline explicit OptionalField()#
-
template<>
class OptionalField<float> : public onnx_light::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.
-
inline explicit OptionalField()#
-
template<>
class OptionalField<int32_t> : public onnx_light::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.
-
inline explicit OptionalField()#
-
template<>
class OptionalField<int64_t> : public onnx_light::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.
-
inline explicit OptionalField()#
-
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.
-
int64_t inline_threshold = 9#
Repeated fields with at most this many elements are printed as a bracketed list; all output is always flat (no newlines).
-
bool skip_raw_data = false#
-
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 Reserve(size_t n)#
Reserves storage for at least n elements (protobuf compat).
-
inline void clear()#
Removes all elements.
-
inline void Clear()#
Removes all elements.
-
inline std::vector<T>::const_iterator cbegin() const#
Returns a const iterator to the first element (protobuf compat).
-
inline std::vector<T>::const_iterator cend() const#
Returns a const iterator past the last element (protobuf compat).
-
inline bool empty() const#
Returns true if the field contains no elements.
-
inline size_t size() const#
Returns the number of elements.
-
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 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 extend(const RepeatedField<T> &v)#
Appends all elements from another RepeatedField.
-
template<class U>
inline void Add(U &&v)# Appends a single value (protobuf compat). Accepts anything convertible to T, including types with an explicit conversion (e.g. std::string -> utils::String).
-
template<class InputIt>
inline void Add(InputIt first, InputIt last)# Appends all elements in [first, last) (protobuf RepeatedField::Add range compat).
-
template<class ...Args>
inline void emplace_back(Args&&... args)# Constructs a new element in-place at the end.
-
inline void Resize(size_t n, const T &value)#
Resizes the field to n elements, filling new slots with value.
-
inline void resize(size_t n)#
Resizes the field to n elements, default-constructing new slots.
-
template<typename InputIt>
inline void Assign(InputIt first, InputIt last)# Assigns the contents from an iterator range.
-
inline void CopyFrom(const RepeatedField<T> &other)#
Copies all elements from another RepeatedField.
-
inline int size_int() const#
Returns the number of elements as int (protobuf compat).
-
void PrintToStringStream(std::stringstream &ss, PrintOptions &options) const#
Writes string representations of the contained values to ss.
-
inline explicit RepeatedField()#
-
template<typename T>
class RepeatedFieldBackInsertIterator# - #include <fields.h>
Output iterator that appends to a RepeatedField via push_back. Mirrors std::back_insert_iterator so it can back google::protobuf::RepeatedFieldBackInsertIterator as a pure alias.
Public Functions
-
inline explicit RepeatedFieldBackInsertIterator(RepeatedField<T> *field)#
Wraps field; appended values go to its end.
-
inline RepeatedFieldBackInsertIterator &operator=(const T &value)#
Appends a copy of value.
-
inline RepeatedFieldBackInsertIterator &operator=(T &&value)#
Appends value (moved).
-
inline RepeatedFieldBackInsertIterator &operator*()#
-
inline RepeatedFieldBackInsertIterator &operator++()#
-
inline RepeatedFieldBackInsertIterator operator++(int)#
Private Members
-
RepeatedField<T> *field_#
-
inline explicit RepeatedFieldBackInsertIterator(RepeatedField<T> *field)#
-
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 RepeatedProtoField(const RepeatedField<T> &src)#
Constructs by copying elements from a value-storage RepeatedField<T>. This makes onnx-light’s value-based repeated fields (used for message entries such as StringStringEntryProto) usable wherever a protobuf RepeatedPtrField (== RepeatedProtoField) is expected by drop-in consumers such as onnxruntime, without changing the field’s own storage.
-
inline void reserve(size_t n)#
Reserves storage for at least n elements.
-
inline void Reserve(size_t n)#
Reserves storage for at least n elements (protobuf compat).
-
inline bool empty() const#
Returns true if the field contains no elements.
-
inline size_t size() const#
Returns the number of elements.
-
inline const T &operator[](size_t index) const#
Returns a const reference to the element at the given index.
-
inline std::shared_ptr<T> &get(size_t index)#
Returns a mutable reference to the owning pointer at the given index.
Returns the shared pointer at the given index (shared ownership copy).
-
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 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).
-
inline void SwapElements(int i, int j)#
Swaps the elements at positions i and j (protobuf RepeatedPtrField::SwapElements compat).
-
template<class ...Args>
inline void emplace_back(Args&&... args)# Constructs a new element in-place at the end.
-
void PrintToStringStream(std::stringstream &ss, PrintOptions &options) const#
Writes string representations of the contained values to ss.
-
inline pointer_iterator pointer_begin()#
Returns a pointer iterator to the first element.
-
inline pointer_iterator pointer_end()#
Returns a pointer 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 iterator erase(iterator first, iterator last)#
Removes the elements in [first, last) and returns an iterator to the element that followed the last removed element (protobuf RepeatedPtrField::erase compat).
-
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.
-
inline const_iterator cbegin() const#
Returns a const iterator to the first element (protobuf compat).
-
inline const_iterator cend() const#
Returns a const iterator past the last element (protobuf compat).
-
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 explicit const_iterator(const RepeatedProtoField<T> *parent, size_t pos = 0)#
-
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 bool operator==(const iterator &other) const#
Returns true if both iterators point to the same position in the same field.
-
inline std::ptrdiff_t operator-(const iterator &other) const#
Returns the distance between two iterators (random-access compat).
-
inline iterator operator-(std::ptrdiff_t n) const#
Returns an iterator advanced backwards by n positions (random-access compat).
-
inline iterator operator+(std::ptrdiff_t n) const#
Returns an iterator advanced forwards by n positions (random-access compat).
-
inline size_t pos() const#
Returns the current position index.
-
inline iterator(RepeatedProtoField<T> *parent, size_t pos = 0)#
-
class pointer_iterator#
- #include <fields.h>
Iterator over raw element pointers (protobuf pointer_begin/pointer_end compat).
Public Types
Public Functions
-
inline pointer_iterator(RepeatedProtoField<T> *parent, size_t pos = 0)#
Constructs a pointer iterator for parent starting at pos.
-
inline pointer_iterator &operator++()#
Advances the iterator to the next element.
-
inline pointer_iterator operator++(int)#
Advances the iterator to the next element (post-increment).
-
inline bool operator==(const pointer_iterator &other) const#
Returns true if both iterators point to the same position in the same field.
-
inline bool operator!=(const pointer_iterator &other) const#
Returns true if the iterators differ.
-
inline size_t pos() const#
Returns the current position index.
-
inline pointer_iterator(RepeatedProtoField<T> *parent, size_t pos = 0)#
-
inline explicit RepeatedProtoField()#
-
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 explicit simple_unique_ptr(T *ptr = nullptr)#
-
inline bool is_inline_size(const PrintOptions &options, size_t size)#
-
namespace utils#