Go to the source code of this file.
Functions | |
C void | memmove (void *dst, void *src, uint bytes) |
class | MutableStringTemplate (T) |
class | StringTemplate (T) |
typedef | StringTemplate (char) Utf8String |
typedef | MutableStringTemplate (char) Utf8MutableString |
Variables | |
module mango text | String |
import mango text | Text |
import mango text mango text | Token |
import mango convert | Type |
import mango convert mango convert | Format |
import mango convert mango convert mango convert | Unicode |
|
|
|
MutableString is a string class that stores Unicode characters and provides functionality similar to the Java String class. Indexes and offsets into and lengths of strings always count code units, not code points. This is the same as with multi-byte char* strings in traditional string handling. Operations on strings typically do not test for code point boundaries. If necessary, the user needs to take care of such boundaries by testing for the code unit values MutableString methods are lenient with regard to input parameter values. In particular, if any provided indexes are out of bounds (< 0 or > length) then they are "pinned" to the nearest boundary. Create an empty MutableString with the specified available space Create a MutableString upon the provided content. If said content is immutable (read-only) then you might consider setting the 'mutable' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified. Create a MutableString via the content of a MutableString. If said content is immutable (read-only) then you might consider setting the 'mutable' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified via MutableString methods. Create a MutableString via the content of a String. Note that the default is to assume the content is immutable Return an alias to the content of this MutableString Remove leading and trailing whitespace from this String. Note that we slice the content to remove leading space. Append an integer to this MutableString, using standard printf() notation Append a long to this MutableString, using standard printf() notation Append a double to this MutableString, using standard printf() notation Append text to this MutableString Append text to this MutableString Append text to this MutableString Append a count of characters to this MutableString Append partial text to this MutableString Format a set of arguments using the standard printf() formatting notation Set a section of this MutableString to the specified character Set the content to the provided array. Parameter 'mutable' specifies whether the given array is likely to change. If not, the array is aliased until such time it is altered. Replace the content of this MutableString. If the new content is immutable (read-only) then you might consider setting the 'mutable' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified via one of these methods. Replace the content of this MutableString. If the new content is immutable (read-only) then you might consider setting the 'mutable' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified via one of these methods. Insert characters into this MutableString Insert text into this MutableString Insert another String into this MutableString Remove a piece of this MutableString. Truncate the length of this MutableString. Arranges text strings in order, using indices to specify where each particular argument should be positioned within the text. This is handy for collating I18N components.
auto string = new MutableString; string.layout ("%2 %1", "one", "two"); The index numbers range from one through nine Check for available space within the buffer, and expand as necessary. make room available to insert something Allocate memory due to a change in the content. We handle the distinction between mutable and immutable here. Internal method to support MutableString appending Initialize this MutableString. Allocate conversion buffers and prime the formatter Support for the formatter, to convert from one encoding to another Definition at line 127 of file StringIndex.d. References convert(), Format, FormatStructTemplate(), into(), Into(), memmove(), MutableString(), MutableStringTemplate(), String, StringTemplate(), and type(). |
|
Immutable string. Note that there's a DMD 141 bug whereby the implementation of ConvertingString somehow gets hidden if you move the copy() method above the utf() methods! Shoving copy() right at the end seems to resolve it for now :-( Hidden constructor Construct read-only wrapper around the given content Return the character at the specified position. Hash this String Return the length of the valid content Is this String equal to another? Is this String equal to the provided text? Does this String end with specified string? Does this String end with specified string? Does this String start with specified string? Does this String start with specified string? Find the first occurrence of a BMP code point in a string. A surrogate code point is found only if its match in the text is not part of a surrogate pair. Find the first occurrence of a substring in a string. The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. Otherwise, the substring edge units would be matched against halves of surrogate pairs. Find the first occurrence of a substring in a string. The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. Otherwise, the substring edge units would be matched against halves of surrogate pairs. Find the last occurrence of a BMP code point in a string. A surrogate code point is found only if its match in the text is not part of a surrogate pair. Find the last occurrence of a BMP code point in a string. A surrogate code point is found only if its match in the text is not part of a surrogate pair. Find the last occurrence of a substring in a string. The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. Otherwise, the substring edge units would be matched against halves of surrogate pairs. Return content from this String A slice of dst is returned, representing a copy of the content. The slice is clipped to the minimum of either the length of the provided array, or the length of the content minus the stipulated start point Bind this string to a token Convert to the AbstractString types. The optional argument dst with be resized as required to house the conversion. To minimize heap allocation, use the following pattern: String string; wchar[] buffer; wchar[] result = string.toUtf16 (buffer); if (result.length > buffer.length) buffer = result; You can also provide a buffer from the stack, but the output will be moved to the heap if said buffer is not large enough Iterate over the characters in this string. Note that this is a read-only freachable ~ the worst a user can do is alter the temporary 'c' Compare this String to another Is this String equal to another? hash() -- hash a variable-length key into a 32-bit value k : the key (the unaligned variable-length array of bytes) len : the length of the key, counting by bytes level : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. About 4.3*len + 80 X86 instructions, with excellent pipelining The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do h = (h & hashmask(10)); In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (ub1 **)k, do it like this: for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h); By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this code any way you wish, private, educational, or commercial. It's free. See http://burlteburtle.net/bob/hash/evahash.html Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. Throw an exception Return the valid content from this String Pin the given index to a valid position. Pin the given index and length to a valid position. Definition at line 691 of file StringIndex.d. References from(), MutableStringTemplate(), String, StringTemplate(), TextTemplate(), and TokenTemplate(). |
|
|
|
|
|
Definition at line 94 of file StringIndex.d. |
|
Definition at line 96 of file StringIndex.d. |
|
Definition at line 96 of file StringIndex.d. |
|
Definition at line 99 of file StringIndex.d. |
|
Definition at line 99 of file StringIndex.d. |
|
Definition at line 99 of file StringIndex.d. |