simple_string.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
-
std::string join_string(const std::vector<std::string> &rows, const char *delimiter = "\n")#
Concatenates rows with a delimiter.
-
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 String &s)#
Streams a String to an output stream.
-
inline std::string operator+(const String &a, const std::string &b)#
Concatenates an owning string followed by a standard string.
-
inline std::string operator+(const std::string &a, const String &b)#
Concatenates a standard string followed by an owning string.
-
inline std::string operator+(const String &a, const char *b)#
Concatenates an owning string followed by a null-terminated string.
-
class RefString#
- #include <simple_string.h>
String view used by binary readers. It references existing memory and may keep short values in an internal buffer.
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.
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.
-
bool operator!=(const String &other) const#
Returns whether this view differs from an owning string.
-
bool operator!=(const std::string &other) const#
Returns whether this view differs from a standard string.
-
bool operator!=(const char *other) const#
Returns whether this view differs from a null-terminated string.
-
int64_t toint64() const#
Parses the content as a signed 64-bit integer.
Private Members
-
const char *ptr_#
-
size_t size_#
-
bool has_inline_#
-
char inline_data_[kInlineCapacity]#
Private Static Attributes
-
static constexpr size_t kInlineCapacity = 15#
-
inline explicit RefString(const RefString ©)#
-
class String#
- #include <simple_string.h>
Owning string type used by ONNX-light protobuf fields. It keeps short values in an internal buffer and uses heap storage for larger values.
Public Functions
-
inline ~String()#
Releases owned memory.
-
inline void clear()#
Resets the instance to an empty state and frees owned memory.
-
inline explicit String()#
Initializes an empty string.
-
inline explicit String(const RefString &s)#
Initializes by copying content from a non-owning string view.
-
inline explicit String(const char *ptr, size_t size)#
Initializes by copying a pointer and explicit size.
-
inline explicit String(String &&other) noexcept#
Initializes by taking ownership from another instance.
-
inline size_t size() const#
Returns the number of characters.
-
inline size_t length() const#
Returns the number of characters.
-
inline const char *data() const#
Returns the underlying pointer.
-
inline const char *c_str() const#
Returns a null-terminated C string (never nullptr).
-
inline bool empty() const#
Indicates whether the string is empty.
-
inline bool null() const#
Indicates whether the string is empty and has no allocated buffer.
-
inline char operator[](size_t i) const#
Returns the character at the specified index.
-
bool operator==(const char *other) const#
Compares with a null-terminated string.
-
bool operator!=(const std::string &other) const#
Returns whether this string differs from a standard string.
-
bool operator!=(const String &other) const#
Returns whether this string differs from another owning string.
-
bool operator!=(const RefString &other) const#
Returns whether this string differs from a non-owning string view.
-
bool operator!=(const char *other) const#
Returns whether this string differs from a null-terminated string.
-
bool operator<(const std::string &other) const#
Returns whether this string is lexicographically less than a standard string.
-
bool operator<(const String &other) const#
Returns whether this string is lexicographically less than another owning string.
-
bool operator<(const RefString &other) const#
Returns whether this string is lexicographically less than a non-owning string view.
-
bool operator<(const char *other) const#
Returns whether this string is lexicographically less than a null-terminated string.
-
bool operator>(const std::string &other) const#
Returns whether this string is lexicographically greater than a standard string.
-
bool operator>(const String &other) const#
Returns whether this string is lexicographically greater than another owning string.
-
bool operator>(const RefString &other) const#
Returns whether this string is lexicographically greater than a non-owning string view.
-
bool operator>(const char *other) const#
Returns whether this string is lexicographically greater than a null-terminated string.
-
inline operator std::string() const#
Implicit conversion to a standard string so the type is a drop-in for protobuf string fields (which are std::string) in consuming code.
-
inline operator std::string_view() const#
Implicit conversion to a string view (drop-in for protobuf string fields).
-
inline int64_t toint64() const#
Parses the content as a signed 64-bit integer.
Private Functions
-
void set(const char *ptr, size_t size)#
Replaces the content with a copy of the provided buffer.
Private Static Attributes
-
static constexpr size_t kInlineCapacity = 23#
-
inline ~String()#
-
std::string join_string(const std::vector<std::string> &rows, const char *delimiter = "\n")#
-
namespace utils