template <size_t N>

class StringBuffer

Defined at line 31 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

A fixed-size buffer for assembling a string.

fbl::StringBuffer is designed to resemble std::string except that it

does not allocate heap storage.

The buffer is sized to hold up to N characters plus a null-terminator.

Public Methods

void StringBuffer<N> ()

Creates an empty string buffer.

Defined at line 34 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void StringBuffer<N> (char c)

Creates a string buffer containing exactly one character and a null

terminator. This constructor is constinit in practice so that it can be

used to initialize fdio's "cwd" path element without generating a dynamic

initializer.

Defined at line 40 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void ~StringBuffer<N> ()

Releases the string buffer.

Defined at line 43 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

char * data ()

Returns a pointer to the null-terminated contents of the string.

Defined at line 46 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char * data ()

Defined at line 47 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char * c_str ()

Defined at line 48 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

size_t length ()

Returns the length of the string, excluding its null terminator.

Defined at line 51 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

size_t size ()

Defined at line 52 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

bool empty ()

Returns the length of the string, excluding its null terminator.

Defined at line 55 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

size_t capacity ()

Returns the capacity of the buffer.

Defined at line 58 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

char * begin ()

Character iterators, excluding the null terminator.

Defined at line 61 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char * begin ()

Defined at line 62 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char * cbegin ()

Defined at line 63 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

char * end ()

Defined at line 64 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char * end ()

Defined at line 65 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char * cend ()

Defined at line 66 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

char & operator[] (size_t pos)

Gets a reference to the character at the specified index.

Position must be in the range [0, length()].

Defined at line 70 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

const char & operator[] (size_t pos)

Defined at line 71 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void Clear ()

Clears the string buffer.

Defined at line 74 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void Set (std::string_view data)

Clears existing data from the buffer and sets the buffer to the new value, plus a null

terminator.

Defined at line 81 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void Set (std::string_view data)

Clears existing data from the buffer and sets the buffer to the new value, plus a null

terminator.

Defined at line 81 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void Resize (size_t count, char ch)

Resizes the string buffer.

If the current length is less than |count|, additional characters are appended

with the value |ch|.

If the current length is greater than |count|, the string is truncated.

|length| must be less than or equal to |N|.

Defined at line 93 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

void RemovePrefix (size_t count)

Remove the first |count| characters from the string buffer.

Defined at line 102 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & Append (char ch)

Appends a single character.

The result is truncated if the appended content does not fit completely.

Defined at line 111 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & Append (const char * data)

Appends content to the string buffer from a null-terminated C string.

The result is truncated if the appended content does not fit completely.

|data| must not be null.

Defined at line 122 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & Append (const char * data, size_t length)

Appends content to the string buffer from a character array of given length.

The result is truncated if the appended content does not fit completely.

|data| must not be null.

Defined at line 130 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & Append (std::string_view view)

Appends content to the string buffer from a string view.

The result is truncated if the appended content does not fit completely.

Defined at line 137 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & Append (std::string_view view)

Appends content to the string buffer from a string view.

The result is truncated if the appended content does not fit completely.

Defined at line 137 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & Append (const fbl::String & other)

Appends content to the string buffer from another string.

The result is truncated if the appended content does not fit completely.

Defined at line 144 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & AppendPrintf (const char * format)

Appends |printf()|-like input.

The result is truncated if the appended content does not fit completely.

Defined at line 151 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

StringBuffer<N> & AppendVPrintf (const char * format, va_list ap)

Appends |vprintf()|-like input using a |va_list|.

The result is truncated if the appended content does not fit completely.

Defined at line 161 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

fbl::String ToString ()

Gets the buffer's contents as a string.

Defined at line 167 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h

std::string_view operator basic_string_view ()

Creates a string view backed by the string.

The string view does not take ownership of the data so the string

must outlast the string view.

NOLINTNEXTLINE(google-explicit-constructor)

Defined at line 174 of file ../../zircon/system/ulib/fbl/include/fbl/string_buffer.h