Open Lighting Architecture
Latest Git
|
String helper and formatting functions.
Classes | |
struct | _ToHex |
Enumerations | |
enum | { HEX_BIT_WIDTH = 4 } |
Functions | |
string | IntToString (int i) |
Convert an int to a string. More... | |
string | IntToString (unsigned int i) |
Convert an unsigned int to a string. More... | |
void | FormatData (std::ostream *out, const uint8_t *data, unsigned int length, unsigned int indent=0, unsigned int byte_per_line=8) |
Write binary data to an ostream in a human readable form. More... | |
void | CopyToFixedLengthBuffer (const std::string &input, char *buffer, unsigned int size) |
Copy a string to a fixed length buffer without NULL terminating. More... | |
template<typename T > | |
_ToHex< T > | ToHex (T v, bool prefix=true) |
Convert a value to a hex string. More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const ola::strings::_ToHex< T > &i) |
Output the _ToHex type to an ostream. | |
uint32_t | _HexCast (uint8_t v) |
uint32_t | _HexCast (int8_t v) |
uint16_t | _HexCast (uint16_t v) |
uint16_t | _HexCast (int16_t v) |
uint32_t | _HexCast (uint32_t v) |
uint32_t | _HexCast (int32_t v) |
template<size_t size> | |
void | StrNCopy (char(&output)[size], const char *input) |
A safe version of strncpy that null-terminates the output string. More... | |
void ola::strings::CopyToFixedLengthBuffer | ( | const std::string & | input, |
char * | buffer, | ||
unsigned int | size | ||
) |
Copy a string to a fixed length buffer without NULL terminating.
input | The string to copy to the buffer. |
buffer | The memory location to copy the contents of the string to. |
size | The size of the memory buffer. |
void ola::strings::FormatData | ( | std::ostream * | out, |
const uint8_t * | data, | ||
unsigned int | length, | ||
unsigned int | indent = 0 , |
||
unsigned int | byte_per_line = 8 |
||
) |
Write binary data to an ostream in a human readable form.
out | the ostream to write to |
data | pointer to the data |
length | length of the data |
indent | the number of spaces to prefix each line with |
byte_per_line | the number of bytes to display per line |
std::string ola::strings::IntToString | ( | int | i | ) |
Convert an int to a string.
i | the int to convert |
std::string ola::strings::IntToString | ( | unsigned int | i | ) |
Convert an unsigned int to a string.
i | the unsigned int to convert |
|
inline |
A safe version of strncpy that null-terminates the output string.
[out] | output | The output array |
[in] | input | The input string. |
_ToHex<T> ola::strings::ToHex | ( | T | v, |
bool | prefix = true |
||
) |
Convert a value to a hex string.
Automatic constructor for _ToHex that deals with widths
T | the type of value to convert |
v | the value to convert |
prefix | show the 0x prefix |