nx_video_source_sdk
1.0
Video Source SDK
|
#include <cstddef>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <stdint.h>
#include <string>
#include <sstream>
#include <vector>
#include <map>
Go to the source code of this file.
Macros | |
#define | NX_KIT_API /*empty*/ |
Functions | |
bool | nx::kit::utils::isAsciiPrintable (int c) |
bool | nx::kit::utils::isSpaceOrControlChar (char c) |
NX_KIT_API std::string | nx::kit::utils::decodeEscapedString (const std::string &s, std::string *errorMessage) |
template<typename T > | |
std::string | nx::kit::utils::toString (T value) |
template<typename... Args> | |
std::string | nx::kit::utils::format (const std::string &formatStr, Args... args) |
bool | nx::kit::utils::fromString (const std::string &s, int *value) |
bool | nx::kit::utils::fromString (const std::string &s, double *outValue) |
bool | nx::kit::utils::fromString (const std::string &s, float *outValue) |
bool | nx::kit::utils::fromString (const std::string &s, bool *value) |
void | nx::kit::utils::stringReplaceAllChars (std::string *s, char sample, char replacement) |
void | nx::kit::utils::stringInsertAfterEach (std::string *s, char sample, const char *const insertion) |
void | nx::kit::utils::stringReplaceAll (std::string *s, const std::string &sample, const std::string &replacement) |
bool | nx::kit::utils::stringStartsWith (const std::string &s, const std::string &prefix) |
bool | nx::kit::utils::stringEndsWith (const std::string &s, const std::string &suffix) |
std::string | nx::kit::utils::trimString (const std::string &s) |
std::string | nx::kit::utils::baseName (std::string path) |
std::string | nx::kit::utils::absolutePath (const std::string &originDir, const std::string &path) |
std::string | nx::kit::utils::getProcessName () |
const std::vector< std::string > & | nx::kit::utils::getProcessCmdLineArgs () |
bool | nx::kit::utils::fileExists (const char *filename) |
size_t | nx::kit::utils::alignUp (size_t value, size_t alignment) |
uint8_t * | nx::kit::utils::misalignedPtr (void *data) |
template<class MallocFunc > | |
void * | nx::kit::utils::mallocAligned (size_t size, size_t alignment, MallocFunc mallocFunc) |
void * | nx::kit::utils::mallocAligned (size_t size, size_t alignment) |
template<class FreeFunc > | |
void | nx::kit::utils::freeAligned (void *ptr, FreeFunc freeFunc) |
void | nx::kit::utils::freeAligned (void *ptr) |
std::string | nx::kit::utils::toString (bool b) |
std::string | nx::kit::utils::toString (const void *ptr) |
std::string | nx::kit::utils::toString (void *ptr) |
std::string | nx::kit::utils::toString (std::nullptr_t ptr) |
std::string | nx::kit::utils::toString (uint8_t i) |
std::string | nx::kit::utils::toString (int8_t i) |
std::string | nx::kit::utils::toString (char c) |
std::string | nx::kit::utils::toString (const char *s) |
std::string | nx::kit::utils::toString (char *s) |
std::string | nx::kit::utils::toString (wchar_t w) |
std::string | nx::kit::utils::toString (const wchar_t *w) |
std::string | nx::kit::utils::toString (wchar_t *w) |
std::string | nx::kit::utils::toString (const std::string &s) |
std::string | nx::kit::utils::toString (const std::wstring &w) |
template<typename P > | |
std::string | nx::kit::utils::toString (P *ptr) |
bool | nx::kit::utils::parseNameValueFile (const std::string &nameValueFilePath, std::map< std::string, std::string > *nameValueMap, const std::string &errorPrefix, std::ostream *output, bool *isFileEmpty) |
std::string | nx::kit::utils::toUpper (const std::string &str) |
Variables | |
constexpr char | nx::kit::utils::kPathSeparator |
Various utilities. Used by other nx_kit components.
This unit can be compiled in the context of any C++ project. If Qt headers are included before this one, some Qt support is enabled via "#if defined(QT_CORE_LIB)".
NX_KIT_API std::string nx::kit::utils::absolutePath | ( | const std::string & | originDir, |
const std::string & | path | ||
) |
If the specified path is absolute, just return it, otherwise, convert it to an absolute path using the specified origin dir. On Windows, both /
and \
are supported, and paths without a drive letter but started with /
or \
are treated as absolute.
|
inline |
Aligns value up to alignment boundary.
alignment | If zero, value is returned unchanged. |
NX_KIT_API std::string nx::kit::utils::baseName | ( | std::string | path | ) |
<drive>:
prefix is excluded and both /
and \
are supported. If path is empty, the result is empty. NX_KIT_API std::string nx::kit::utils::decodeEscapedString | ( | const std::string & | s, |
std::string * | outErrorMessage = nullptr |
||
) |
Decodes a string encoded using C/C++ string literal rules: enquoted, potentially containing escape sequences. Supports concatenation of consecutive literals, thus, fully compatible with strings encoded by nx::kit::utils::toString().
outErrorMessage | In case of any error in the encoded string, the function attempts to recover using the most obvious way, still producing the result, and reports all such cases via this argument if it is not null. |
std::string nx::kit::utils::format | ( | const std::string & | formatStr, |
Args... | args | ||
) |
ATTENTION: std::string is not supported as one of args
, and will cause undefined behavior.
void nx::kit::utils::freeAligned | ( | void * | ptr, |
FreeFunc | freeFunc | ||
) |
Free ptr allocated with a call to mallocAligned().
NOTE: This function is as safe as ::free().
freeFunc | Function with the signature void(void*), which is called to free the memory. |
|
inline |
Calls freeAligned() passing standard free() as freeFunc.
NX_KIT_API const std::vector< std::string > & nx::kit::utils::getProcessCmdLineArgs | ( | ) |
NX_KIT_API std::string nx::kit::utils::getProcessName | ( | ) |
void* nx::kit::utils::mallocAligned | ( | size_t | size, |
size_t | alignment, | ||
MallocFunc | mallocFunc | ||
) |
Allocates size bytes of data, aligned to alignment boundary.
NOTE: Allocated memory must be freed with a call to freeAligned(). NOTE: This function is as safe as malloc().
mallocFunc | Function with the signature void*(size_t), which is called to allocate memory. |
|
inline |
Calls mallocAligned() passing standard malloc() as mallocFunc.
|
inline |
Shifts the pointer up to deliberately misalign it to an odd address - intended for tests.
std::string nx::kit::utils::toString | ( | T | value | ) |
Converts a value to its report-friendly text representation; for strings it being a quoted and C-style-escaped string. Non-printable chars in a string are represented as hex escape sequences like \xFF""
- note that the two quotes after it are inserted to indicate the end of the hex number, because according to the C/C++ standards, \x
consumes as much hex digits as possible.
For unknown types, use their operator<<().
NX_KIT_API std::string nx::kit::utils::toUpper | ( | const std::string & | str | ) |
Converts ASCII characters from the input string to the upper case.
constexpr char nx::kit::utils::kPathSeparator |