FARGOS/VISTA Object Management Environment Core
..
|
Extreme-performance text/number conversion routines. More...
#include <stdint.h>
#include <memory.h>
#include <math.h>
#include <utils/base/compiler_hints.h>
#include <utils/base/text2int_tbl.h>
#include <netinet/in.h>
Go to the source code of this file.
Classes | |
struct | VariableFixedPointValue |
Return value structure for representing fixed-point values with variable precision. More... | |
Macros | |
#define | CONVERT_UINT_TO_TEXT(varName, sourceVal) uint32_t _workBfr_ ## varName [6]; char *varName = uint_to_ascii(_workBfr_ ## varName, sizeof(_workBfr_ ## varName), sourceVal) |
Convenience macro to declare a work buffer and convert an unsigned value into text. More... | |
#define | CONVERT_INT_TO_TEXT(varName, sourceVal) uint32_t _workBfr_ ## varName [6]; char *varName = int_to_ascii(_workBfr_ ## varName, sizeof(_workBfr_ ## varName), sourceVal); |
Convenience macro to declare a work buffer and convert a signed value into text. If the value is known to be positive, CONVERT_UINT_TO_TEXT() is faster. More... | |
Functions | |
uint_fast32_t | text2uint32 (const char *textString, uint_fast8_t text_len) |
Convert a sequence of text characters into an unsigned integer as quickly as possible. Depending on string length, this routine is between 2-3 times faster than standard routines such as strtol(). Note: text2int32() can be used if negative numbers will be seen. More... | |
int_fast32_t | text2int32 (const char *textString, uint_fast8_t text_len) |
Convert a sequence of text characters into a 32-bit signed integer as quickly as possible. Optional leading "-" or "+" supported. More... | |
uint64_t | text2uint64 (const char *textString, uint_fast8_t text_len) |
Convert a sequence of text characters into a 64-bit unsigned integer as quickly as possible. More... | |
int64_t | text2int64 (const char *textString, uint_fast8_t text_len) |
Convert a sequence of text characters into a 64-bit signed integer as quickly as possible. Optional leading "-" or "+" supported. More... | |
uint32_t | n2to_uint32 (const void *byteData) |
Convert a network byte order 2-byte integer into a native unsigned 32-bit value. More... | |
uint32_t | n4to_uint32 (const void *byteData) |
Convert a network byte order 4-byte integer into a native unsigned 32-bit value. More... | |
uint64_t | n8to_uint64 (const void *byteData) |
Convert a network byte order 8-byte integer into a native unsigned 64-bit value. More... | |
CONSTEXPR uint16_t | const_uint16_ton2 (const uint16_t arg) OME_ALWAYS_INLINE OME_PURE_FUNCTION OME_ALWAYS_OPTIMIZE("-O3") |
Equivalent of htons(), but evaluated at compile time. More... | |
CONSTEXPR uint32_t | const_uint32_ton4 (const uint32_t arg) OME_ALWAYS_INLINE OME_PURE_FUNCTION OME_ALWAYS_OPTIMIZE("-O3") |
Equivalent of htonl(), but evaluated at compile time. More... | |
CONSTEXPR uint64_t | const_uint64_ton8 (const uint64_t arg) OME_ALWAYS_INLINE OME_PURE_FUNCTION OME_ALWAYS_OPTIMIZE("-O3") |
Equivalent of htonll(), but evaluated at compile time. More... | |
char * | uint_to_ascii (uint32_t workBfr[], uint_fast8_t bfrLen, uint64_t value, uint_fast8_t *retStrLen=nullptr) NONNULL_RETURN |
Quickly convert a binary integer into ASCII decimal text. More... | |
char * | int_to_ascii (uint32_t workBfr[], uint_fast8_t bfrLen, int64_t value, uint_fast8_t *retStrLen=nullptr) NONNULL_RETURN |
Identical to uint_to_ascii(), except that negative values are accepted. More... | |
char * | uint_to_ascii_right_justified (uint32_t workBfr[], uint_fast8_t bfrLen, uint64_t value, uint_fast8_t fieldWidth, char fillChar=' ') NONNULL_RETURN |
Convert a binary integer into right-justified ASCII decimal text and pad on the left with a specified fill character. More... | |
char * | fixedpoint_to_ascii (char *resultBfr, uint_fast8_t bfrLen, int64_t value, uint_fast8_t decimals, uint_fast8_t *retStrLen=nullptr, int_fast8_t outputPrecision=-2) NONNULL_RETURN |
Format a fixed-point value with indicated decimal places. More... | |
VariableFixedPointValue | fast_ascii_to_fixedpoint (const char *str, uint_fast8_t len=0, int_fast8_t desiredPrecision=-2) NONNULL_PARAMETERS(1) |
Convert ASCII decimal text string to fixed point representation. More... | |
int64_t | ascii_to_fixedpoint (const char *str, uint_fast8_t *resultPrecision=nullptr, uint_fast8_t len=0, int_fast8_t desiredPrecision=-2) NONNULL_PARAMETERS(1) OME_ALWAYS_INLINE |
Convert ASCII decimal text string to fixed point representation. More... | |
double | text2double (const char *str, uint_fast8_t len=0) NONNULL_PARAMETERS(1) |
Convert ASCII decimal text string to a double. More... | |
char * | float_to_ascii (char *resultBfr, uint_fast8_t bfrLen, double value, uint_fast8_t *retStrLen=nullptr, int_fast8_t outputPrecision=-2, bool roundValue=false) NONNULL_PARAMETERS(1) NONNULL_RETURN |
Format a double-precision value with indicated decimal places. More... | |
uint_fast8_t | bytesInUTFcharacter (const char val) |
Return number of bytes required to represent UTF-encoded character as indicated by value of leading byte. More... | |
uint_fast8_t | bytesInUTFchar (const void *s) |
Return number of bytes required to represent UTF-encoded character pointed to by argument. More... | |
template<unsigned int EXPONENT> | |
CONSTEXPR uint64_t | powerOf10Constant () |
Generate compile-time constant for integral power of 10. More... | |
template<unsigned int LEN> | |
uint_fast32_t | right_padded_strlen (const char *s, const char PADDING_CHAR) |
Templated convenience routine to return the length of a possibly padded string. The assumption is that the string is padded on the right with a consistent padding character up to a predefined length. More... | |
template<> | |
uint_fast32_t | right_padded_strlen< 0 > (const char *s, const char PADDING_CHAR) |
specialization to stop recursion at length 0 More... | |
template<uint_fast8_t FIELD_LEN> | |
uint64_t | textField2uint (const char *field) |
Templated ASCII-to-integer conversion routine that very quickly converts fixed-length fields of positive integers. More... | |
template<uint_fast8_t FIELD_LEN> | |
int64_t | textField2int (const char *field) |
Templated ASCII-to-integer conversion routine that converts fixed-length fields. More... | |
CONSTEXPR double | cleanedNumericValue (double v, double minPrecision) |
Return value clipped to 0 if not above a threshold of precision. More... | |
CONSTEXPR double | cleanedPositiveNumericValue (double v, double minPrecision) |
Return value clipped to 0 if not above a threshold of precision. More... | |
template<typename STREAMTYPE > | |
STREAMTYPE & | operator<< (STREAMTYPE &os, const VariableFixedPointValue arg) |
Extreme-performance text/number conversion routines.
![]() | Generated: Tue Jul 28 2020 16:03:26
Support Information |