dmd.common.string
Common string functions including filename manipulation.
License
Source: common/string.d
Documentation: https://dlang.org/phobos/dmd_common_string.html
-
Declaration
structSmallBuffer(T);Defines a temporary array using a fixed-length buffer as back store. If the length of the buffer suffices, it is readily used. Otherwise,
mallocis used to allocate memory for the array andfreeis used for deallocation in the destructor.Discussion
This type is meant to use exclusively as an automatic variable. It is not default constructible or copyable.
Examples
ditto
char[230] buf = void; auto a = SmallBuffer!char(10, buf); assert(a[] is buf[0 .. 10]); auto b = SmallBuffer!char(1000, buf); assert(b[] !is buf[]); b.create(1000); assert(b.length == 1000); assert(b[] !is buf[]);
-
Declaration
pure nothrow @nogc autoasDString(C)(C*stringz);Converts a zero-terminated C string to a D slice. Takes linear time and allocates no memory.
Parameters
C*stringzthe C string to be converted
Return Value
a slice comprehending the string. The terminating 0 is not part of the slice.
Examples
const char* p = "123".ptr; assert(p.asDString == "123");