asmjit::String Class Reference
Inheritance diagram for asmjit::String:
asmjit::StringTmp< N >

A simple non-reference counted string that uses small string optimization (SSO).

This string has 3 allocation possibilities:

  1. Small - embedded buffer is used for up to kSSOCapacity characters. This should handle most small strings and thus avoid dynamic memory allocation for most use-cases.
  2. Large - string that doesn't fit into an embedded buffer (or string that was truncated from a larger buffer) and is owned by AsmJit. When you destroy the string AsmJit would automatically release the large buffer.
  3. External - like Large (2), however, the large buffer is not owned by AsmJit and won't be released when the string is destroyed or reallocated. This is mostly useful for working with larger temporary strings allocated on stack or with immutable strings.

Public Types

Member Functions

Construction & Destruction
Overloaded Operators
Accessors
String Operations
Internal Functions

Member Enumeration Documentation

class String::ModifyOp : uint32_tenumstrong◆ 

String operation.

ConstantDescription
kAssign 

Assignment - a new content replaces the current one.

kAppend 

Append - a new content is appended to the string.

Constructor & Destructor Documentation

String::String()noexcept[1/2]◆ 

Creates a default-initialized string if zero length.

String::String(String&& other)noexcept[2/2]◆ 

Creates a string that takes ownership of the content of the other string.

Member Function Documentation

Error String::reset()noexcept◆ 

Reset the string into a construction state.

bool String::empty() constnoexcept◆ 

Tests whether the string is empty.

size_t String::size() constnoexcept◆ 

Returns the size of the string.

size_t String::capacity() constnoexcept◆ 

Returns the capacity of the string.

char* String::data()noexcept[1/2]◆ 

Returns the data of the string.

const char* String::data() constnoexcept[2/2]◆ 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void String::swap(String& other)noexcept◆ 

Swaps the content of this string with other.

Error String::clear()noexcept◆ 

Clears the content of the string.

Error String::assign(const char* data, size_t size = SIZE_MAX)noexcept[1/3]◆ 

Replaces the current of the string with data of the given size.

Null terminated strings can set size to SIZE_MAX.

Error String::assign(const String& other)noexcept[2/3]◆ 

Replaces the current of the string with other string.

Error String::assign(char c)noexcept[3/3]◆ 

Replaces the current of the string by a single c character.

Error String::assignChars(char c, size_t n)noexcept◆ 

Replaces the current of the string by a c character, repeated n times.

Error String::assignInt(int64_t i, uint32_t base = 0, size_t width = 0, StringFormatFlags flags = StringFormatFlags::kNone)noexcept◆ 

Replaces the current of the string by a formatted integer i (signed).

Error String::assignUInt(uint64_t i, uint32_t base = 0, size_t width = 0, StringFormatFlags flags = StringFormatFlags::kNone)noexcept◆ 

Replaces the current of the string by a formatted integer i (unsigned).

Error String::assignHex(const void* data, size_t size, char separator = '\0')noexcept◆ 

Replaces the current of the string by the given data converted to a HEX string.

template<typename... Args>
Error String::assignFormat(const char* fmt, Args&&... args)noexcept◆ 

Replaces the current of the string by a formatted string fmt.

Error String::assignVFormat(const char* fmt, va_list ap)noexcept◆ 

Replaces the current of the string by a formatted string fmt (va_list version).

Error String::append(const char* str, size_t size = SIZE_MAX)noexcept[1/3]◆ 

Appends str having the given size size to the string.

Null terminated strings can set size to SIZE_MAX.

Error String::append(const String& other)noexcept[2/3]◆ 

Appends other string to this string.

Error String::append(char c)noexcept[3/3]◆ 

Appends a single c character.

Error String::appendChars(char c, size_t n)noexcept◆ 

Appends c character repeated n times.

Error String::appendInt(int64_t i, uint32_t base = 0, size_t width = 0, StringFormatFlags flags = StringFormatFlags::kNone)noexcept◆ 

Appends a formatted integer i (signed).

Error String::appendUInt(uint64_t i, uint32_t base = 0, size_t width = 0, StringFormatFlags flags = StringFormatFlags::kNone)noexcept◆ 

Appends a formatted integer i (unsigned).

Error String::appendHex(const void* data, size_t size, char separator = '\0')noexcept◆ 

Appends the given data converted to a HEX string.

template<typename... Args>
Error String::appendFormat(const char* fmt, Args&&... args)noexcept◆ 

Appends a formatted string fmt with args.

Error String::appendVFormat(const char* fmt, va_list ap)noexcept◆ 

Appends a formatted string fmt (va_list version).

Error String::truncate(size_t newSize)noexcept◆ 

Truncate the string length into newSize.

void String::_resetInternal()noexcept◆ 

Resets string to embedded and makes it empty (zero length, zero first char)

Note
This is always called internally after an external buffer was released as it zeroes all bytes used by String's embedded storage.