OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
util.hpp
1#ifndef QOS_CPP_UTIL
2#define QOS_CPP_UTIL
3
4#include "include/types.hpp"
5
6
7namespace qOS {
8
12 namespace util {
13
33 using putChar_t = void (*)( void* , const char );
34
59 using ioFcn_t = char (*)( void *, const char );
60
74 char* strchr( const char *s, int c, size_t maxlen ) noexcept;
88 size_t strlen( const char* s, size_t maxlen ) noexcept;
98 size_t strcpy( char * dst, const char * src, size_t maxlen ) noexcept;
115 size_t strcat( char *dst, const char *src, size_t maxlen ) noexcept;
122 bool swapBytes( void *pData, const size_t n ) noexcept;
127 bool checkEndianness( void ) noexcept;
136 bool outputString( util::putChar_t fcn, const char *s, void* pStorage = nullptr, bool aip = false ) noexcept;
146 bool printXData( util::putChar_t fcn, void *pData, size_t n, bool eol = true, void* pStorage = nullptr ) noexcept;
156 bool outputRAW( const ioFcn_t fcn, void *pData, const size_t n, void* pStorage = nullptr, bool aip = false ) noexcept;
166 bool inputRAW( const ioFcn_t fcn, void *pData, const size_t n, void* pStorage = nullptr, bool aip = false ) noexcept;
176 uint32_t hexStringToUnsigned( const char *s ) noexcept;
195 float64_t stringToFloat( const char *s ) noexcept;
206 char* floatToString( float64_t num, char *str, uint8_t precision = 10U ) noexcept;
227 int stringToInt( const char *s ) noexcept;
243 char* unsignedToString( unsigned_t num, char* str, uint8_t base = 10U ) noexcept;
263 char* integerToString( signed_t num, char* str, uint8_t base = 10U ) noexcept;
274 char* boolToString( const bool num, char *str ) noexcept;
275
277 }
278
279}
280
281#endif /*QOS_CPP_UTIL*/
bool outputRAW(const ioFcn_t fcn, void *pData, const size_t n, void *pStorage=nullptr, bool aip=false) noexcept
API interface to write n RAW data through fcn.
size_t strcat(char *dst, const char *src, size_t maxlen) noexcept
appends no more than maxlen−len(dst)−1 characters pointed to by src into the array pointed to by dst ...
char(*)(void *, const char) ioFcn_t
Pointer to function that perform a single character I/O operation.
Definition util.hpp:59
char * floatToString(float64_t num, char *str, uint8_t precision=10U) noexcept
Converts a float value to a formatted string.
void(*)(void *, const char) putChar_t
Pointer to function that write-out a single character.
Definition util.hpp:33
bool swapBytes(void *pData, const size_t n) noexcept
Invert the endianess for n bytes of the specified memory location.
bool checkEndianness(void) noexcept
Check the system endianess.
uint32_t hexStringToUnsigned(const char *s) noexcept
Converts the input string consisting of hexadecimal digits into an unsigned integer value....
bool printXData(util::putChar_t fcn, void *pData, size_t n, bool eol=true, void *pStorage=nullptr) noexcept
API interface to write data in HEX notation through fcn.
char * unsignedToString(unsigned_t num, char *str, uint8_t base=10U) noexcept
Converts an unsigned value to a null-terminated string using the specified base and stores the result...
int stringToInt(const char *s) noexcept
Parses the C-string s interpreting its content as an integral number, which is returned as a value of...
bool outputString(util::putChar_t fcn, const char *s, void *pStorage=nullptr, bool aip=false) noexcept
API interface to write a string through fcn.
char * integerToString(signed_t num, char *str, uint8_t base=10U) noexcept
Converts an integer value to a null-terminated string using the specified base and stores the result ...
float64_t stringToFloat(const char *s) noexcept
Parses the C string s, interpreting its content as a floating point number and returns its value as a...
size_t strlen(const char *s, size_t maxlen) noexcept
Returns the length of the given null-terminated byte string, that is, the number of characters in a c...
bool inputRAW(const ioFcn_t fcn, void *pData, const size_t n, void *pStorage=nullptr, bool aip=false) noexcept
API interface to get n RAW data through fcn.
char * strchr(const char *s, int c, size_t maxlen) noexcept
Returns a pointer to the first occurrence of character in the C string s. The terminating null-charac...
char * boolToString(const bool num, char *str) noexcept
Converts a boolean value to a null-terminated string. Input is considered true with any value differe...
size_t strcpy(char *dst, const char *src, size_t maxlen) noexcept
Copies up to (maxlen - 1) characters from the null-terminated string src to dst, null-terminating the...
unsigned long unsigned_t
A type to instantiate an unsigned variable.
Definition types.hpp:72
long int signed_t
A type to instantiate an signed variable.
Definition types.hpp:77
double float64_t
A type to instantiate a single-precision variable of 64-bits IEEE 754.
Definition types.hpp:87
OS/Kernel interfaces.
Definition bytebuffer.hpp:7