Fixposition SDK 0.0.0-heads/main-0-g7b59b93
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
string.hpp File Reference

Fixposition SDK: String utilities. More...

#include <cinttypes>
#include <cstdarg>
#include <functional>
#include <string>
#include <vector>
Include dependency graph for string.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  fpsdk
 Fixposition SDK.
 
namespace  fpsdk::common
 Fixposition SDK: Common library.
 
namespace  fpsdk::common::string
 String utilities.
 

Macros

#define PRINTF_ATTR(n)   __attribute__((format(printf, n, n + 1)))
 Helper macro for marking functions as taking printf() style formatting strings.
 

Functions

std::string fpsdk::common::string::Sprintf (const char *const fmt,...) PRINTF_ATTR(1)
 Format string.
 
std::string fpsdk::common::string::Vsprintf (const char *fmt, va_list args)
 Format string.
 
std::string fpsdk::common::string::Strftime (const char *const fmt, const int64_t ts=0, const bool utc=false)
 Format time.
 
int fpsdk::common::string::StrReplace (std::string &str, const std::string &search, const std::string &replace, const int max=0)
 Search and replace.
 
void fpsdk::common::string::StrTrimLeft (std::string &str)
 Trim string left.
 
void fpsdk::common::string::StrTrimRight (std::string &str)
 Trim string right.
 
void fpsdk::common::string::StrTrim (std::string &str)
 Trim string left and right.
 
std::vector< std::string > fpsdk::common::string::StrSplit (const std::string &str, const std::string &sep, const int maxNum=0)
 Split string.
 
std::string fpsdk::common::string::StrJoin (const std::vector< std::string > &strs, const std::string &sep)
 Join strings.
 
std::vector< std::string > fpsdk::common::string::StrMap (const std::vector< std::string > &strs, std::function< std::string(const std::string &)> map)
 Map strings.
 
void fpsdk::common::string::MakeUnique (std::vector< std::string > &strs)
 Remove duplicates.
 
std::vector< std::string > fpsdk::common::string::HexDump (const std::vector< uint8_t > data)
 Format hexdump of data.
 
std::vector< std::string > fpsdk::common::string::HexDump (const uint8_t *data, const std::size_t size)
 Format hexdump of data.
 
bool fpsdk::common::string::StrStartsWith (const std::string &str, const std::string &prefix)
 Check if one string starts with another string.
 
bool fpsdk::common::string::StrEndsWith (const std::string &str, const std::string &suffix)
 Check if one string ends with another string.
 
bool fpsdk::common::string::StrContains (const std::string &str, const std::string &sub)
 Check if one string is contained within another string string.
 
bool fpsdk::common::string::StrToValue (const std::string &str, int8_t &value)
 Convert string to value (int8_t)
 
bool fpsdk::common::string::StrToValue (const std::string &str, uint8_t &value)
 Convert string to value (uint8_t)
 
bool fpsdk::common::string::StrToValue (const std::string &str, int16_t &value)
 Convert string to value (int16_t)
 
bool fpsdk::common::string::StrToValue (const std::string &str, uint16_t &value)
 Convert string to value (uint16_t)
 
bool fpsdk::common::string::StrToValue (const std::string &str, int32_t &value)
 Convert string to value (int32_t)
 
bool fpsdk::common::string::StrToValue (const std::string &str, uint32_t &value)
 Convert string to value (uint32_t)
 
bool fpsdk::common::string::StrToValue (const std::string &str, int64_t &value)
 Convert string to value (int64_t, long)
 
bool fpsdk::common::string::StrToValue (const std::string &str, uint64_t &value)
 Convert string to value (uint64_t, unsigned long)
 
bool fpsdk::common::string::StrToValue (const std::string &str, float &value)
 Convert string to value (float)
 
bool fpsdk::common::string::StrToValue (const std::string &str, double &value)
 Convert string to value (double)
 
std::string fpsdk::common::string::StrToUpper (const std::string &str)
 Convert string to all upper case.
 
std::string fpsdk::common::string::StrToLower (const std::string &str)
 Convert string to all lower case.
 

Detailed Description

Fixposition SDK: String utilities.

* ___    ___
* \  \  /  /
*  \  \/  /   Copyright (c) Fixposition AG (www.fixposition.com) and contributors
*  /  /\  \   License: see the LICENSE file
* /__/  \__\
* 

Definition in file string.hpp.

Macro Definition Documentation

◆ PRINTF_ATTR

#define PRINTF_ATTR ( n)    __attribute__((format(printf, n, n + 1)))

Helper macro for marking functions as taking printf() style formatting strings.

This helps the compiler to check that the number and types of the variable arguments match the format string.

Definition at line 46 of file string.hpp.