String

UTF-8 string.

struct String {}

Constructors

this
this(S str, Allocator allocator)

Constructs the string from a stringish range.

this
this(S init, Allocator allocator)
this(Allocator allocator)

Initializes this string from another one.

this
this(size_t n, C chr, Allocator allocator)

Fills the string with n consecutive copies of character chr.

Destructor

~this
~this()

Destroys the string.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

insert
alias insert = insertBack

Inserts a stringish range at the end of the string.

opDollar
alias opDollar = length

Functions

byCodePoint
ByCodePoint!char byCodePoint()
ByCodePoint!(const char) byCodePoint()
get
inout(char)[] get()

Returns an array used internally by the string. The length of the returned array may be smaller than the size of the reserved memory for the string.

insertAfter
size_t insertAfter(R r, T el)

Inserts el before or after r.

insertBack
size_t insertBack(char chr)
size_t insertBack(wchar chr)
size_t insertBack(dchar chr)

Inserts a single character at the end of the string.

insertBack
size_t insertBack(R str)

Inserts a stringish range at the end of the string.

insertBefore
size_t insertBefore(R r, T el)
opAssign
String opAssign(S that)

Assigns another string.

opAssign
String opAssign(S that)

Assigns a stringish range.

opCmp
int opCmp(S that)
int opCmp(ByCodeUnit!S that)
int opCmp(ByCodePoint!S that)
int opCmp(char[] that)

Comparison for equality.

opEquals
bool opEquals(S that)

Comparison for equality.

opEquals
bool opEquals(ByCodeUnit!S that)
bool opEquals(ByCodePoint!S that)
bool opEquals(char[] that)

Comparison for equality.

opIndex
inout(char) opIndex(size_t pos)
opIndex
ByCodeUnit!char opIndex()
ByCodeUnit!(const char) opIndex()
opIndexAssign
char opIndexAssign(char value, size_t pos)

Assigns a value to the character with the index pos.

opIndexAssign
ByCodeUnit!char opIndexAssign(ByCodeUnit!R value)
ByCodeUnit!char opIndexAssign(char value)
ByCodeUnit!char opIndexAssign(char[] value)

Slicing assignment.

opSlice
ByCodeUnit!char opSlice(size_t i, size_t j)
ByCodeUnit!(const char) opSlice(size_t i, size_t j)
opSliceAssign
ByCodeUnit!char opSliceAssign(ByCodeUnit!R value, size_t i, size_t j)
ByCodeUnit!char opSliceAssign(char[] value, size_t i, size_t j)
ByCodeUnit!char opSliceAssign(char value, size_t i, size_t j)

Slicing assignment.

remove
R remove(R r)

Remove all characters beloning to r.

reserve
void reserve(size_t size)

Reserves size bytes for the string.

shrink
void shrink(size_t size)

Requests the string to reduce its capacity to fit the size.

toHash
size_t toHash()

Calculates the hash value for the string.

toStringz
const(char)* toStringz()

Returns null-terminated string. The returned string is managed by this object and shouldn't be freed.

Mixins

__anonymous
mixin DefaultAllocator
Undocumented in source.

Properties

capacity
size_t capacity [@property getter]
empty
bool empty [@property getter]

Returns whether the string is empty.

length
size_t length [@property getter]

Mixed In Members

From mixin DefaultAllocator

allocator_
Allocator allocator_;

Allocator.

this
this(Allocator allocator)
allocator
shared(Allocator) allocator [@property getter]

This property checks if the allocator was set in the constructor and sets it to the default one, if not.

Meta