StringT

A string implementation that uses two pointers, as opposed to one pointer and a size variable.

struct StringT (
C
) {}

Constructors

this
this(inout C* p, inout C* e)

Constructs from start and end pointers.

this
this(inout C* p, const size_t length)

Constructs from a start pointer and a length value. NB: use 'u' suffix on int literals, e.g.: this(str.ptr, 13u)

this
this(inout C[] str)

Constructs from a character array.

this
this(inout C* p, const C terminator)

Constructs from a character-terminated string.

this
this(const S[] strs, const S joinStr)
this(const C[][] strs, const C[] joinStr)

Constructs from Strings by joining them with joinStr.

this
this(const C c)

Constructs from a single character.

Members

Aliases

CS
alias CS = S

Explicit constness for construction.

IS
alias IS = S

Explicit constness for construction.

find
alias find = findC!(size_t)

Searches for character c.

find
alias find = findS!(size_t)

Searches for s.

findp
alias findp = findC!(inout(C)*)

Searches for character c.

findp
alias findp = findS!(inout(C)*)

Searches for s.

findr
alias findr = findrC!(size_t)

Searches for character c starting from the end.

findr
alias findr = findrS!(size_t)

Searches for s starting from the end, returning the index.

findrp
alias findrp = findrC!(inout(C)*)

Searches for character c, returning a pointer.

findrp
alias findrp = findrS!(inout(C)*)

Searches for s starting from the end, returning a pointer.

Functions

divide
inout(S)[] divide(uint_t num)

Divides the String into num parts. The remainder is appended to the last piece.

dup
S dup()

Returns a copy.

endsWith
bool endsWith(const S suffix)
bool endsWith(const C[] suffix)

Returns true if this String ends with suffix.

endsWith
bool endsWith(const S[] suffixes)
bool endsWith(const C[][] suffixes)

Returns true if this String ends with one of the specified suffixes.

findC
RT findC(const C c)

Searches for character c.

findS
RT findS(const S s)

Searches for s.

findrC
RT findrC(const C c)

Searches for character c starting from the end.

findrS
RT findrS(const S s)

Searches for s starting from the end.

hashOf
hash_t hashOf()

Calculates a hash value. Note: The value will differ between 32bit and 64bit systems, and also between little and big endian systems.

icmp
int_t icmp(T x)

Compares two Strings ignoring case (only ASCII.)

ieql
bool ieql(T x)

Compares two Strings ignoring case for equality (only ASCII.)

indexPtr
inout(C)* indexPtr(T x)

Returns a pointer from an index number. When x is negative it is subtracted from the end pointer.

isEmpty
bool isEmpty()

Returns true if the string is empty.

isNull
bool isNull()

Returns true if pointers are null.

join
S join(const S[] strs)
S join(const C[][] strs)

Concatenates strs using this String as a separator.

len
size_t len()

Returns the byte length.

ljoin
S ljoin(const C[][] strs)

Like join, but also prepends the separator.

ljoin
S ljoin(const S[] strs)

Like join, but also prepends the separator.

opBinary
S opBinary(uint_t rhs)

Concatenates x copies of this string.

opBinary
inout(S)[] opBinary(uint_t rhs)

Divides the String into num parts. The remainder is appended to the last piece.

opBinary
S opBinary(T rhs)

Appends another string or character. Returns a new object.

opBinary
inout(C)* opBinary(inout C[] rhs)

Returns a pointer to the first character, if this String is in rhs.

opBinaryRight
S opBinaryRight(uint_t lhs)

Concatenates x copies of this string.

opBinaryRight
inout(C)* opBinaryRight(T lhs)

Returns a pointer to the first character, if lhs is in this String.

opCast
bool opCast()

Converts to bool.

opCast
inout(C)[] opCast()

Converts to an array string.

opCmp
int_t opCmp(const S s)

Compares the chars of two Strings.

opEquals
bool opEquals(T x)

Compares the bytes of two Strings for exact equality.

opEquals
bool opEquals(bool b)

Compares to a boolean value.

opIndex
inout(C) opIndex(T x)

Returns the character at position x.

opIndexAssign
S opIndexAssign(C c, T x)

Assigns c at position x.

opOpAssign
S opOpAssign(T rhs)

Appends another string or character. Returns itself.

opSlice
inout(C)[] opSlice()

Returns a character array.

opSlice
inout(S) opSlice(T1 x, T2 y)

Returns a slice.

partition
inout(S)[2] partition(T sep)

Searches for sep and returns the part before and after that.

pieces
inout(S)[] pieces(uint_t n)

Returns a list of Strings where each piece is of length n. The last piece may be shorter.

reverse
S reverse()

Returns itself reversed.

reverse
S reverse()

Returns a reversed String.

rjoin
S rjoin(const S[] strs)
S rjoin(const C[][] strs)

Like join, but also appends the separator.

rpartition
inout(S)[2] rpartition(T sep)

Searches for sep and returns the part before and after that.

slices
bool slices(const S s)
bool slices(const C[] s)

Returns true if this string is a slice of s.

split
inout(S)[] split(T x)
inout(S)[] split(T c)

Splits by String s and returns a list of slices.

startsWith
bool startsWith(const S prefix)
bool startsWith(const C[] prefix)

Returns true if this String starts with prefix.

startsWith
bool startsWith(const S[] prefixes)
bool startsWith(const C[][] prefixes)

Returns true if this String starts with one of the specified prefixes.

sub
S sub(A a, B b)
S sub(A a, B b)

Substitutes a with b.

sub_
S sub_(const C a, const C b)
S sub_(const S a, const S b)

Substitutes a with b.

times
S times(uint_t x)

Concatenates x copies of this string.

toHex
S toHex()

Encodes the byte characters with hexadecimal digits.

toString
immutable(C)[] toString()

Returns true if the string is empty.

tolower
S tolower()
S tolower()

Converts to lower-case (only ASCII.)

toupper
S toupper()
S toupper()

Converts to upper-case (only ASCII.)

Static functions

choice
auto choice(A a, B b)

Returns 'a' if RT is of type size_t, otherwise 'b'.

islower
bool islower(const C c)

Return true if lower-case.

isupper
bool isupper(const C c)

Return true if upper-case.

itoa
S itoa(ulong x)

Constructs from an unsigned long. NB: Not a regular constructor because "char" converts implicitly to ulong.

toS
auto toS(T t)

Converts t to S in case it's a different type than S.

tolower
inout(C) tolower(inout C c)

Returns the lower-case version of c.

toupper
inout(C) toupper(inout C c)

Returns the upper-case version of c.

Structs

S2
struct S2

A dummy struct to simulate "tail const".

Variables

end
C* end;

Points one past the end of the string.

ptr
C* ptr;

Points to the beginning of the string.

Meta