|
Evo C++ Library v0.5.1
|
#include <evo/string.h>

String fixed-size buffer for formatting a floating point number.
| T | Floating point type |
| PADDING | Additional padding for buffer, defaults to 1 for terminator |
This example uses printf() as a function that requires a terminated string.
Output:
Classes | |
| struct | NumInfo |
| Advanced: Special structure used to avoid automatically allocating memory when a bigger buffer is needed. More... | |
Public Types | |
| typedef ListBase< char, StrSizeT > | ListBaseType |
| List base type (this) More... | |
| typedef StrSizeT | Size |
| Size type. More... | |
| typedef StringFlt< T, PADDING > | ThisType |
| This type. More... | |
Public Member Functions | |
| StringFlt () | |
| Constructor intializes to null. More... | |
| StringFlt (T num, int precision=fPREC_AUTO, bool terminated=true) | |
| Constructor intializes with set(). More... | |
| ~StringFlt () | |
| Destructor. More... | |
| char * | data () |
| Get formatted string pointer. More... | |
| ThisType & | set () |
| Set as null. More... | |
| char * | set (T num, int precision=fPREC_AUTO, bool terminated=true, NumInfo *info=NULL) |
| Set floating point number and format to string. More... | |
| Size | size () const |
| Get formatting string size. More... | |
Public Attributes | |
| char | buffer [BUF_SIZE] |
| String buffer More... | |
| char * | data_ |
| Data pointer, NULL if null. More... | |
| StrSizeT | size_ |
| Data size as item count, 0 if empty or null. More... | |
Static Public Attributes | |
| static const int | BUF_SIZE = FloatT<T>::MAXDIGITS_AUTO + PADDING |
| Buffer size. More... | |
|
inherited |
List base type (this)
|
inline |
Constructor intializes to null.
|
inline |
Constructor intializes with set().
| num | Number to set/format |
| precision | Formatting precision (number of fractional digits), 0 for none, fPREC_AUTO for automatic |
| terminated | Whether to add terminator after number |
|
inline |
Destructor.
|
inline |
Get formatted string pointer.
|
inline |
Set as null.
|
inline |
Set floating point number and format to string.
info=NULL (the default): this allocates the needed memory internally (which is freed by destructor) and formatting always succeedsinfo: this populates the info object and returns NULL, call info->format() to finish formatting with your own bufferprecision=fPREC_AUTO as the stack buffer is always big enough for automatic precision formatting (which uses scientific notation if needed)| num | Number to set/format |
| precision | Formatting precision (number of fractional digits), 0 for none, fPREC_AUTO for automatic |
| info | Used when more memory is needed: NULL to alloc internally and free in destructor, otherwise this is populated and NULL is returned |
| terminated | Whether to add terminator after number |
| info | NULL by default, otherwise a non-NULL value enables optimization for a special case (see above) |
info != NULL and a buffer alloc is needed (see above)
|
inline |
Get formatting string size.
|
static |
Buffer size.
| char buffer[BUF_SIZE] |
String buffer
|
inherited |
Data pointer, NULL if null.
|
inherited |
Data size as item count, 0 if empty or null.
1.8.13