simple_string.h#

namespace ONNX_LIGHT_NAMESPACE
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.

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 &copy)#

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 RefString &v)#

Assigns the pointer and size from another view.

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 const std::string_view sv() const#

Returns a string_view.

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 RefString &other) const#

Compares this view with another view.

bool operator==(const String &other) const#

Compares this view with an owning string.

bool operator==(const std::string &other) const#

Compares this view with a standard string.

bool operator==(const char *other) const#

Compares this view with a null-terminated string.

bool operator!=(const RefString &other) const#

Returns whether this view differs from another view.

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.

std::string as_string(bool quote = false) const#

Converts the view into a standard 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#
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(const std::string &s)#

Initializes by copying a standard string.

inline explicit String(const String &s)#

Initializes by copying another owning string.

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 bool empty() const#

Indicates whether the string is empty.

inline const std::string_view sv() const#

Returns a string_view.

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.

String &operator=(const char *s)#

Assigns from a null-terminated string.

String &operator=(String &&other) noexcept#

Assigns by taking ownership from another instance.

String &operator=(const RefString &s)#

Assigns from a non-owning string view.

String &operator=(const String &s)#

Assigns from another owning string.

String &operator=(const std::string &s)#

Assigns from a standard string.

bool operator==(const std::string &other) const#

Compares with a standard string.

bool operator==(const String &other) const#

Compares with another owning string.

bool operator==(const RefString &other) const#

Compares with a non-owning string view.

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.

std::string as_string(bool quote = false) const#

Converts the value into a standard string.

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 Members

char *ptr_#
size_t size_#
bool is_inline_#
char inline_data_[kInlineCapacity]#

Private Static Attributes

static constexpr size_t kInlineCapacity = 23#