Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
string.h File Reference
#include <misc/gen/Locale.h>
#include <misc/gen/math.h>
#include <misc/global.h>
#include <string>
#include <misc/gen/string.hpp>
Include dependency graph for string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  sf
 

Functions

_MISC_FUNC char * sf::decimal_separator_fix (char *buffer, size_t len)
 Replaces a decimal comma for a point. This instead of changing the global locale. Used by template functions.
 
_MISC_FUNC size_t sf::strncspn (const char *s, size_t n, const char *reject)
 The strncspn() function calculates the length of the initial segment of 's' which consists entirely of characters not in reject up to a maximum 'n'. When no reject chars were found n is returned.
 
_MISC_FUNC size_t sf::strnspn (const char *s, size_t n, const char *accept)
 The strncspn() function calculates the length of the initial segment of 's' which consists entirely of characters in accept up to a maximum 'n'.
 
_MISC_FUNC const char * sf::strnstr (const char *s, const char *find, size_t n)
 Find the first occurrence of find in s, where the search is limited to the first slen characters of s.
 
_MISC_FUNC std::string sf::demangle (const char *name)
 Returns the unmangled function name returned by type ID.
 
_MISC_FUNC char sf::hexCharValue (char ch)
 Returns numeric the value of the passed hexadecimal character.
 
_MISC_FUNC size_t sf::stringHex (const char *hexstr, void *buffer, size_t sz)
 Converts a hexadecimal string to a block of data.
 
_MISC_FUNC std::string sf::hexString (const void *buffer, size_t sz)
 Converts a block of data to a hexadecimal string.
 
_MISC_FUNC std::string sf::bitToString (unsigned long wrd, size_t count)
 Converts an integer value to bit string '0' and '1' characters where the first character is the first bit.
 
_MISC_FUNC std::string sf::escape (const std::string &str, char delimiter='\0')
 Escapes all control and non ascii characters.
 
_MISC_FUNC std::string sf::unescape (const std::string &str)
 Unescapes the passed string escaped by the escape() function.
 
_MISC_FUNC std::string sf::filter (std::string str, const std::string &filter)
 Filters all characters from the passed string and returns the resulting string.
 
_MISC_FUNC std::string sf::toLower (std::string s)
 Converts the passed string into a lower case one and returns it.
 
_MISC_FUNC std::string sf::toUpper (std::string s)
 Converts the passed string into an upper case one and returns it.
 
_MISC_FUNC std::string sf::trim (std::string s, const std::string &t=" ")
 Trims a passed string at both sides and returns it.
 
_MISC_FUNC std::string sf::trimLeft (std::string s, const std::string &t=" ")
 Trims a passed string left and returns it.
 
_MISC_FUNC std::string sf::trimRight (std::string s, const std::string &t=" ")
 Trims a passed string right and returns it.
 
_MISC_FUNC int sf::wildcmp (const char *wild, const char *str, bool case_s)
 Matches a string against a wildcard string such as "*.*" or "bl?h.*" etc.
 
int sf::wildcmp (const std::string &wild, const std::string &str, bool case_s)
 Matches a string against a wildcard string such as "*.*" or "bl?h.*" etc.
 
_MISC_FUNC std::string sf::error_string (int error_num)
 Thread safe version strerror_r() or strerror_s() when cross compiling for Windows.
 
_MISC_FUNC std::string sf::stringf (const char *fmt,...)
 Creates a formatted string and returns it in a string class instance.
 
_MISC_FUNC std::string sf::replaceAll (const std::string &s, const std::string &from, const std::string &to)
 Replaces all occurrences of 'from' substring and replaces them with 'to' string.
 
template<typename... Args>
std::string sf::string_format (const std::string &format, Args &&... args)
 Better implementation of 'stringf' ?
 
template<typename T >
char * sf::gcvt (T value, int ndigits, char *buf, size_t len)
 Converts a floating-point number to a string always using a decimal point. It produces 'digits' significant digits in either printf(3) F format or E (scientific) format. Always returns a decimal point without setting the global locale.
 
template<typename T >
std::string sf::gcvtString (T value, int ndigits=0)
 Converts a floating-point number to a string always using a decimal point.
 
template<typename T >
char * sf::itoa (T value, char *buffer, int base=10)
 Converts an integer type value to a buffer. The itoa function converts value to a null-terminated buffer and stores the result in buffer. With itoa, value is an integer. Note: The space allocated for buffer must be large enough to hold the returned buffer, including the terminating null character (\0). itoa can return up to (sizeof(T) * CHAR_BIT + 1) bytes.
 
template<typename T >
std::string sf::itostr (T value, int base=10)
 Converts an integer type value to a std::string.
 
template<typename T >
sf::toFloat (const char *ptr, char **end_ptr=nullptr)
 A locale independent template version for std::strtof(), std::strtod() and std::strtold() functions which uses locale "C".
 
template<typename T , typename S = std::string>
sf::toNumber (const S &s, size_t *idx=nullptr)
 Converts a std::string to a T value and whe not possible it returns the passed default.
 
template<typename T , typename S = std::string>
sf::toNumberDefault (const S &s, T def)
 Converts a std::string to a T value and when not possible it returns the passed default.
 
template<typename T >
std::string sf::toString (T value, int digits=0)
 The function converts number to a minimal length. It produces 'digits' significant digits in either printf(3) F format or E (scientific) format. Always returns a decimal point without setting the global locale. In case of more than 3 trailing zeros with large numbers a scientific notation is formed instead.
 
template<typename T >
std::string sf::toStringPrecision (T value, int prec=std::numeric_limits< int >::max())
 Converts any floating point value in to a string with a given precision. The default precision shows a .
 
_MISC_FUNC std::string sf::numberString (double value, int digits, bool sign_on=true)
 String formats a floating point or integer value using scientific notation. where the exponent is always a multiple of 3.
 
_MISC_FUNC std::istream & sf::read_to_delimiter (std::istream &is, std::string &s, char delimiter)
 Read a stream until a given delimiter.
 
template<typename T >
int sf::fcvt_r (T value, int ndigit, int *decpt, int *sign, char *buf, size_t len)
 Function identical to ecvt(), except that 'ndigits' specifies the number of digits after the decimal point.
 
template<typename T >
int sf::ecvt_r (T value, int ndigit, int *decpt, int *sign, char *buf, size_t len)
 Converts number to a null-terminated string of 'ndigits' digits. where 'ndigits' is reduced to a system-specific limit determined by the precision of a double. The high-order digit is nonzero, unless number is zero. The low order digit is rounded. The string itself does not contain a decimal point; however, the position of the decimal point relative to the start of the string is stored in *decpt. A negative value for *decpt means that the decimal point is to the left of the start of the string. If the sign of number is negative, *sign is set to a nonzero value, otherwise it is set to 0. If number is zero, it is unspecified whether *decpt is 0 or 1.