Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
Format.h File Reference

Detailed Description

Formatting functions for basic types.

Go to the source code of this file.

Namespaces

namespace  ola
 The namespace containing all OLA symbols.
 

Functions

string ola::strings::IntToString (int i)
 Convert an int to a string.
 
string ola::strings::IntToString (unsigned int i)
 Convert an unsigned int to a string.
 
template<typename T >
_ToHex< T > ola::strings::ToHex (T v, bool prefix=true)
 Convert a value to a hex string.
 
template<typename T >
std::ostream & ola::strings::operator<< (std::ostream &out, const ola::strings::_ToHex< T > &i)
 Output the _ToHex type to an ostream.
 
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.
 

Function Documentation

◆ FormatData()

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.

Parameters
outthe ostream to write to
datapointer to the data
lengthlength of the data
indentthe number of spaces to prefix each line with
byte_per_linethe number of bytes to display per line
Note
The data is printed in two columns, hex on the left, ascii on the right. Non ascii values are printed as ‘.’

◆ IntToString() [1/2]

std::string ola::strings::IntToString ( int i)

Convert an int to a string.

Parameters
ithe int to convert
Returns
the string representation of the int

◆ IntToString() [2/2]

std::string ola::strings::IntToString ( unsigned int i)

Convert an unsigned int to a string.

Parameters
ithe unsigned int to convert
Returns
The string representation of the unsigned int

◆ ToHex()

template<typename T >
_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

Template Parameters
Tthe type of value to convert
Parameters
vthe value to convert
prefixshow the 0x prefix
Returns
A _ToHex struct representing the value, output it to an ostream to use it.
Note
We only currently support unsigned ints due to a lack of requirement for anything else