simple_string.h#
-
template<>
struct hash<onnx_light::utils::OptionalString># - #include <simple_string.h>
Specializes std::hash for OptionalString and String so they can be used as keys in unordered containers (and with absl hashing).
Public Functions
-
inline size_t operator()(const onnx_light::utils::OptionalString &s) const noexcept#
-
inline size_t operator()(const onnx_light::utils::OptionalString &s) const noexcept#
-
template<>
struct hash<onnx_light::utils::String># - #include <simple_string.h>
Public Functions
-
inline size_t operator()(const onnx_light::utils::String &s) const noexcept#
-
inline size_t operator()(const onnx_light::utils::String &s) const noexcept#
-
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.
Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when
lib_onnx_protouses hidden visibility by default.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 std::string operator+(const OptionalString &lhs, const char *rhs)#
String concatenation with standard strings and C strings.
-
inline std::string operator+(const char *lhs, const OptionalString &rhs)#
-
inline std::string operator+(const OptionalString &lhs, const std::string &rhs)#
-
inline std::string operator+(const std::string &lhs, const OptionalString &rhs)#
-
inline std::string operator+(const OptionalString &lhs, const OptionalString &rhs)#
- ONNX_LIGHT_PROTO_API std::string join_string (const std::vector< std::string > &rows, const char *delimiter="\n")
Concatenates rows with a delimiter.
-
inline std::string quote_string(std::string_view text, bool quote = true)#
Returns a copy of the text, optionally wrapped in double quotes (used by printers).
-
inline std::ostream &operator<<(std::ostream &os, const RefString &s)#
Streams a RefString to an output stream.
-
inline std::ostream &operator<<(std::ostream &os, const OptionalString &s)#
Streams an OptionalString to an output stream (empty when unset).
-
class OptionalString : public std::optional<std::string>#
- #include <simple_string.h>
Owning optional string type used for singular ONNX-light protobuf string fields, mirroring proto2
optional stringpresence semantics. It is a thin std::optional<std::string> subclass with protobuf-friendly read helpers so it behaves like a string when set.Public Functions
-
OptionalString() = default#
Initializes an unset (absent) value.
-
OptionalString(const OptionalString&) = default#
-
OptionalString(OptionalString&&) = default#
-
OptionalString &operator=(const OptionalString&) = default#
-
OptionalString &operator=(OptionalString&&) = default#
-
inline OptionalString(const char *s)#
Initializes to a present value from a null-terminated string (nullptr is absent).
-
inline OptionalString(const String &s)#
Initializes to a present value from an owning repeated string.
-
inline OptionalString(const RefString &s)#
Initializes to a present value from a non-owning string view.
-
inline OptionalString &operator=(const char *s)#
Assigns a present value from a null-terminated string (nullptr clears the value).
-
inline OptionalString &operator=(const std::string &s)#
Assigns a present value from a standard string.
-
inline OptionalString &operator=(std::string &&s)#
-
inline OptionalString &operator=(const RefString &s)#
Assigns a present value from a non-owning string view.
-
inline OptionalString &operator=(const String &s)#
Assigns a present value from an owning repeated string.
-
inline bool null() const#
Indicates whether the field is unset (absent).
-
inline size_t size() const#
Returns the number of characters (0 when unset).
-
inline size_t length() const#
Returns the number of characters (0 when unset).
-
inline bool empty() const#
Indicates whether the value is unset or empty.
-
inline const char *data() const#
Returns the underlying pointer (nullptr when unset).
-
inline const char *c_str() const#
Returns a null-terminated C string (never nullptr; empty when unset).
-
inline const std::string &value() const#
Returns the stored string, or a shared empty string when unset (never throws).
-
inline char operator[](size_t i) const#
Returns the character at the specified index (requires a value).
-
inline int64_t toint64() const#
Parses the content as a signed 64-bit integer.
-
inline operator const std::string&() const#
Implicit conversion to const std::string& (shared empty when unset). Allows binding to const std::string& in call sites that expect protobuf semantics.
-
inline void assign(const char *s, size_t len)#
Assigns content from a character range, matching protobuf’s assign(ptr, len) API.
-
inline std::string &mutable_ref()#
Returns a mutable reference to the underlying string, creating it if absent.
-
inline std::string *mutable_ptr()#
Returns a mutable pointer to the underlying string, creating it if absent.
-
inline size_t find(const char *s, size_t pos = 0) const#
Delegates std::string::find to the underlying value (npos if absent).
-
inline size_t find(char c, size_t pos = 0) const#
-
inline int compare(const char *other) const#
-
inline std::string substr(size_t pos = 0, size_t len = std::string::npos) const#
Delegates std::string::substr. Returns empty string if absent.
-
inline bool operator==(const OptionalString &other) const#
Compares two OptionalString values for equality (disambiguation for C++20 heterogeneous optional overloads).
-
inline bool operator!=(const OptionalString &other) const#
-
inline bool operator==(const char *other) const#
Compares against a null-terminated string (nullptr matches absent).
-
inline bool operator!=(const char *other) const#
-
inline bool operator==(const std::string &other) const#
Compares against a standard string (unset never equals any std::string).
-
inline bool operator<(const OptionalString &rhs) const#
Orders two OptionalString values (absent sorts before any present value; disambiguation for C++20 heterogeneous optional overloads).
-
inline bool operator<=(const OptionalString &rhs) const#
-
inline bool operator>(const OptionalString &rhs) const#
-
inline bool operator>=(const OptionalString &rhs) const#
-
inline bool operator<(const std::string &rhs) const#
Orders against a standard string (unset sorts before any std::string).
-
inline bool operator<(const char *rhs) const#
Orders against a null-terminated string (nullptr and unset sort before present values).
-
inline bool operator<=(const char *rhs) const#
-
inline bool operator>(const char *rhs) const#
-
inline bool operator>=(const char *rhs) const#
Public Static Functions
-
static inline const std::string &empty_value()#
Returns a shared empty string, usable to bind a reference to a default value.
-
static inline int compare_opt(const OptionalString &lhs, const OptionalString &rhs)#
Three-way comparison of two OptionalString values (absent sorts before any present value). Implemented as a named helper so the relational operators never invoke
operator<between two OptionalString values, which would drag std::optional’s heterogeneousoperator<=>templates into overload resolution and recurse for this optional-derived type.
-
OptionalString() = default#
-
class RefString#
- #include <simple_string.h>
String view used by binary readers. It references existing memory and does not own it.
Public Functions
-
inline explicit RefString(const RefString ©)#
Initializes a view by copying pointer and size from another view.
-
inline explicit RefString(const char *ptr, size_t size)#
Initializes a view from a pointer and an explicit size.
-
inline RefString &operator=(const String &v)#
Assigns the pointer and size from an owning string (non-owning view).
Assigns a non-owning view from an owning string.
-
inline size_t size() const#
Returns the number of characters in the view.
-
inline const char *c_str() const#
Returns the underlying pointer.
-
inline const char *data() const#
Returns the underlying pointer without ownership.
-
inline bool empty() const#
Indicates whether the view is empty.
-
inline char operator[](size_t i) const#
Returns the character at the specified index.
-
bool operator==(const char *other) const#
Compares this view with a null-terminated string.
-
int64_t toint64() const#
Parses the content as a signed 64-bit integer.
-
inline explicit RefString(const RefString ©)#
-
class String : public std::string#
- #include <simple_string.h>
Owning string type used for repeated ONNX-light protobuf string fields (for example NodeProto inputs/outputs). It is a thin std::string subclass so it is a drop-in std::string with a few protobuf-friendly helpers.
Public Functions
-
String() = default#
Initializes an empty string.
-
inline explicit String(const RefString &s)#
Initializes by copying content from a non-owning string view.
-
inline const std::string &value() const#
Returns a const reference to the underlying std::string (protobuf compatibility).
-
inline std::string *mutable_ptr()#
Returns a mutable pointer to the underlying std::string (protobuf compatibility).
-
inline int64_t toint64() const#
Parses the content as a signed 64-bit integer.
-
String() = default#
-
inline std::string operator+(const OptionalString &lhs, const char *rhs)#
-
namespace utils