String
VString is a storage and manipulation class for text strings.
The string object always ensures that a contained string is null terminated.
The basic principle of operation, is that two pointers mark out a selection in the string. The "Anti" pointer is indexed from the beginning of the string. The "Post" pointer is indexed from the end of the string. If (Anti==0 && Post==0) then the entire string is selected, no matter how long it is. The pointer indices may be manipulated directly, by position and size or by search. Ranges from the Math group may be used to control the pointers.
Strings may be loaded from and saved to disk, in a single function call. This operates in addition to the standard serialisation capability.
String supports a huge variety of manipulation functions many of which operate on each range, i.e. before selection, selection, after selection. An exhaustive list is beyond the scope of this description. Notably conversions to and from numeric types are provided. All of the following output types may be generated;
- Signed Integer
- Hexdecimal
- Octal
- Floating point
When reading from text the programmer must be expecting a particular type. The functions report an error if an incorrect type is used.
Within the floating point type, the following combinations of output options are available;
Format:
- Real (basic calculator)
- Minimal (smallest number of digits)
- Scientific (mantissa and exponent)
- Engineering (resistor style numbering - i.e. 2K4 = 2400)
Precision:
- All digits
- Significant figures
- Decimal places
When performing text reads of floating point numbers, all of the available output types (within the floating point group) are acceptable. The read function may still report an error if, for example, a hexdecimal value is presented.
String supports direct comparison operators, and concatenation operators. It also provides an advanced search (non-regex).
|