C++ Utilities 5.27.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
Contains all utilities provides by the c++utilities library. More...
Namespaces | |
namespace | BE |
Encapsulates binary conversion functions using the big endian byte order. | |
namespace | EscapeCodes |
Encapsulates functions for formatted terminal output using ANSI escape codes. | |
namespace | FlagEnumClassOperations |
The FlagEnumClassOperations namespace contains operations for flag enums. | |
namespace | LE |
Encapsulates binary conversion functions using the little endian byte order. | |
namespace | Literals |
Contains literals to ease asserting with CPPUNIT_ASSERT_EQUAL. | |
namespace | Traits |
Contains traits for conveniently exploiting SFINAE. | |
namespace | ValueConversion |
Contains functions to convert raw argument values to certain types. | |
Classes | |
class | AdvancedIniFile |
The AdvancedIniFile class allows parsing and writing INI files. More... | |
struct | ApplicationInfo |
Stores information about an application. More... | |
class | ArchiveException |
The ArchiveException class is thrown by the various archiving-related functions of this library when a conversion error occurs. More... | |
struct | ArchiveFile |
The ArchiveFile class holds data about a file within an archive. More... | |
class | Argument |
The Argument class is a wrapper for command line argument information. More... | |
struct | ArgumentCompletionInfo |
The ArgumentCompletionInfo struct holds information internally used for shell completion and suggestions. More... | |
struct | ArgumentOccurrence |
The ArgumentOccurrence struct holds argument values for an occurrence of an argument. More... | |
class | ArgumentParser |
The ArgumentParser class provides a means for handling command line arguments. More... | |
class | ArgumentReader |
The ArgumentReader class internally encapsulates the process of reading command line arguments. More... | |
struct | ArrayBasedMultiArray |
The ArrayBasedMultiArray struct allows using a fixed size array as underlying container for the MultiArray class. More... | |
class | AsHexNumber |
The AsHexNumber class allows printing values asserted with cppunit (or similar test framework) using the hex system in the error case. More... | |
class | BinaryReader |
Reads primitive data types from a std::istream. More... | |
class | BinaryWriter |
Writes primitive data types to a std::ostream. More... | |
class | BitReader |
The BitReader class provides bitwise reading of buffered data. More... | |
class | BufferSearch |
The BufferSearch struct invokes a callback if an initially given search term occurs in consecutively provided buffers. More... | |
class | ConfigValueArgument |
The ConfigValueArgument class is an Argument where setCombinable() is true by default. More... | |
class | ConversionException |
The ConversionException class is thrown by the various conversion functions of this library when a conversion error occurs. More... | |
class | CopyHelper |
The CopyHelper class helps to copy bytes from one stream to another. More... | |
class | DateTime |
Represents an instant in time, typically expressed as a date and time of day. More... | |
struct | DateTimeExpression |
The DateTimeExpression struct holds information about a time expression (e.g. More... | |
class | FakeQtConfigArguments |
The FakeQtConfigArguments class provides arguments for the Qt GUI used when the application hasn't been built with Qt GUI support. More... | |
class | HelpArgument |
The HelpArgument class prints help information for an argument parser when present (–help, -h). More... | |
class | Indentation |
The Indentation class allows printing indentation conveniently, eg. More... | |
class | IniFile |
The IniFile class allows parsing and writing INI files. More... | |
struct | IsFlagEnumClass |
The IsFlagEnumClass class is used to decide whether to enable operations for flag enums for. More... | |
class | MultiArray |
The MultiArray class provides an N-dimensional array. More... | |
class | NoColorArgument |
The NoColorArgument class allows to specify whether use of escape codes or similar technique to provide formatted output on the terminal should be enabled/disabled. More... | |
struct | NoneOwningMultiArray |
The NoneOwningMultiArray struct allows using a caller-managed buffer array as underlying container for the MultiArray class. More... | |
class | OperationArgument |
The OperationArgument class is an Argument where denotesOperation() is true by default. More... | |
class | OutputCheck |
The StandardOutputCheck class asserts whether the (standard) output written in the enclosing code block matches the expected output. More... | |
class | ParseError |
The ParseError class is thrown by an ArgumentParser when a parsing error occurs. More... | |
class | Period |
Represents a period of time. More... | |
struct | StringDataDeleter |
The StringDataDeleter struct deletes the data of a StringData instance. More... | |
struct | TerminalSize |
The TerminalSize struct describes a terminal size. More... | |
class | TestApplication |
The TestApplication class simplifies writing test applications that require opening test files. More... | |
class | TimeSpan |
Represents a time interval. More... | |
struct | VectorBasedMultiArray |
The VectorBasedMultiArray struct allows using an std::vector with custom allocator as underlying container for the MultiArray class. More... | |
struct | VectorBasedMultiArray< void > |
The VectorBasedMultiArray struct allows using an std::vector as underlying container for the MultiArray class. More... | |
class | Wrapper |
The Wrapper class is internally used print text which might needs to be wrapped preserving the indentation. More... | |
Typedefs | |
using | ArgumentInitializerList = std::initializer_list<Argument *> |
using | ArgumentVector = std::vector<Argument *> |
using | ArgumentPredicate = std::function<bool(Argument *)> |
using | StringData = std::pair<std::unique_ptr<char[], StringDataDeleter>, std::size_t> |
Type used to return string encoding conversion result. | |
using | PathValueType |
The native type used by std::filesystem:path. | |
using | NativePathString = std::basic_string<PathValueType> |
The string type used to store paths in the native encoding. | |
using | NativePathStringView = std::basic_string_view<PathValueType> |
The string view type used to pass paths in the native encoding. | |
using | PathString = std::string |
The string type used to store paths UTF-8 encoded. | |
using | PathStringView = std::string_view |
The string view type used to pass paths UTF-8 encoded. | |
using | NativeFileStream = std::fstream |
using | FileMap = std::map<std::string, std::vector<ArchiveFile>> |
A map of files extracted from an archive. Keys represent directories and values files within those directories. | |
using | FilePredicate = std::function<bool(const char *, const char *, mode_t)> |
A function that is invoked for each file within an archive. If it returns true, the file is considered; otherwise the file is ignored. | |
using | DirectoryHandler = std::function<bool(std::string_view path)> |
A function that is invoked by the walk-through-functions to return a directory. | |
using | FileHandler = std::function<bool(std::string_view path, ArchiveFile &&file)> |
A function that is invoked by the walk-through-functions to return a file. | |
Enumerations | |
enum class | UnknownArgumentBehavior { Ignore , Warn , Fail } |
The UnknownArgumentBehavior enum specifies the behavior of the argument parser when an unknown argument is detected. More... | |
enum class | ParseArgumentBehavior { ReadArguments = 0x0 , CheckConstraints = 0x1 , InvokeCallbacks = 0x2 , ExitOnFailure = 0x4 } |
The ParseArgumentBehavior enum specifies the behavior when parsing arguments. More... | |
enum class | ValueCompletionBehavior : unsigned char { None = 0 , PreDefinedValues = 2 , Files = 4 , Directories = 8 , FileSystemIfNoPreDefinedValues = 16 , AppendEquationSign = 32 , InvokeCallback = 64 } |
The ValueCompletionBehavior enum specifies the items to be considered when generating completion for an argument value. More... | |
enum class | Response { None , Yes , No } |
The Response enum is used to specify the default response for the confirmPrompt() method. More... | |
enum class | DateTimeOutputFormat { DateAndTime , DateOnly , TimeOnly , DateTimeAndWeekday , DateTimeAndShortWeekday , Iso , IsoOmittingDefaultComponents } |
Specifies the output format. More... | |
enum class | DayOfWeek { Monday , Tuesday , Wednesday , Thursday , Friday , Saturday , Sunday } |
Specifies the day of the week. More... | |
enum class | DatePart { Year , Month , DayOfYear , Day } |
Specifies the date part. More... | |
enum class | DateTimeParts : std::uint64_t { None = 0 , Year = (1 << 0) , Month = (1 << 1) , Day = (1 << 2) , Hour = (1 << 3) , Minute = (1 << 4) , Second = (1 << 5) , SubSecond = (1 << 6) , DeltaHour = (1 << 7) , DeltaMinute = (1 << 8) , Date = Year | Month | Day , Time = Hour | Minute | Second | SubSecond , DateTime = Date | Time , TimeZoneDelta = DeltaHour | DeltaMinute , All = DateTime | TimeZoneDelta } |
The DateTimeParts enum specifies which parts of a timestamp are present. More... | |
enum class | TimeSpanOutputFormat { Normal , WithMeasures , TotalSeconds } |
Specifies the output format. More... | |
enum class | EmptyPartsTreat { Keep , Omit , Merge } |
Specifies the role of empty parts when splitting strings. More... | |
enum class | IniFileParseOptions { None = 0 } |
enum class | IniFileMakeOptions { None = 0 } |
enum class | IniFileFieldFlags { None = 0 , HasValue = (1 << 0) } |
enum class | IniFileSectionFlags { None = 0 , Implicit = (1 << 0) , Truncated = (1 << 1) } |
enum class | WorkingCopyMode { CreateCopy , NoCopy , Cleanup } |
The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPath(). More... | |
enum | ArgumentDenotationType : unsigned char { Value = 0 , Abbreviation = 1 , FullName = 2 } |
The ArgumentDenotationType enum specifies the type of a given argument denotation. More... | |
enum class | ArchiveFileType { Regular , Link } |
The ArchiveFileType enum specifies the type of a file within an archive. More... | |
Functions | |
CPP_UTILITIES_EXPORT bool | confirmPrompt (const char *message, Response defaultResponse) |
Prompts for confirmation displaying the specified message. | |
CPP_UTILITIES_EXPORT std::optional< bool > | isEnvVariableSet (const char *variableName) |
Returns whether the specified env variable is set to a non-zero and non-white-space-only value. | |
CPP_UTILITIES_EXPORT TerminalSize | determineTerminalSize () |
Returns the current size of the terminal. | |
CPP_UTILITIES_EXPORT std::ostream & | operator<< (std::ostream &out, Indentation indentation) |
CPP_UTILITIES_EXPORT DateTime | operator+ (DateTime begin, Period period) |
Adds the specified period to the specified date. | |
CPP_UTILITIES_EXPORT constexpr std::uint16_t | toFixed8 (float float32value) |
Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number. | |
CPP_UTILITIES_EXPORT constexpr float | toFloat32 (std::uint16_t fixed8value) |
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation. | |
CPP_UTILITIES_EXPORT constexpr std::uint32_t | toFixed16 (float float32value) |
Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number. | |
CPP_UTILITIES_EXPORT constexpr float | toFloat32 (std::uint32_t fixed16value) |
Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation. | |
CPP_UTILITIES_EXPORT constexpr std::uint32_t | toSynchsafeInt (std::uint32_t normalInt) |
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer. | |
CPP_UTILITIES_EXPORT constexpr std::uint32_t | toNormalInt (std::uint32_t synchsafeInt) |
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer. | |
CPP_UTILITIES_EXPORT constexpr std::uint16_t | swapOrder (std::uint16_t value) |
Swaps the byte order of the specified 16-bit unsigned integer. | |
CPP_UTILITIES_EXPORT constexpr std::uint32_t | swapOrder (std::uint32_t value) |
Swaps the byte order of the specified 32-bit unsigned integer. | |
CPP_UTILITIES_EXPORT constexpr std::uint64_t | swapOrder (std::uint64_t value) |
Swaps the byte order of the specified 64-bit unsigned integer. | |
CPP_UTILITIES_EXPORT constexpr std::int16_t | swapOrder (std::int16_t value) |
Swaps the byte order of the specified 16-bit integer. | |
CPP_UTILITIES_EXPORT constexpr std::int32_t | swapOrder (std::int32_t value) |
Swaps the byte order of the specified 32-bit integer. | |
CPP_UTILITIES_EXPORT constexpr std::int64_t | swapOrder (std::int64_t value) |
Swaps the byte order of the specified 64-bit integer. | |
CPP_UTILITIES_EXPORT StringData | convertString (const char *fromCharset, const char *toCharset, const char *inputBuffer, std::size_t inputBufferSize, float outputBufferSizeFactor) |
Converts the specified string from one character set to another. | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToUtf16LE (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to UTF-16 (little-endian). | |
CPP_UTILITIES_EXPORT StringData | convertUtf16LEToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-16 (little-endian) string to UTF-8. | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToUtf16BE (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to UTF-16 (big-endian). | |
CPP_UTILITIES_EXPORT StringData | convertUtf16BEToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-16 (big-endian) string to UTF-8. | |
CPP_UTILITIES_EXPORT StringData | convertLatin1ToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified Latin-1 string to UTF-8. | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToLatin1 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to Latin-1. | |
CPP_UTILITIES_EXPORT void | truncateString (string &str, char terminationChar) |
Truncates all characters after the first occurrence of the specified terminationChar and the termination character as well. | |
template<class Container = std::initializer_list<std::string>, class ReturnType = Detail::DefaultReturnTypeForContainer<Container>> | |
ReturnType | joinStrings (const Container &strings, Detail::StringParamForContainer< Container > delimiter=Detail::StringParamForContainer< Container >(), bool omitEmpty=false, Detail::StringParamForContainer< Container > leftClosure=Detail::StringParamForContainer< Container >(), Detail::StringParamForContainer< Container > rightClosure=Detail::StringParamForContainer< Container >()) |
Joins the given strings using the specified delimiter. | |
template<class Container = std::initializer_list<std::string>> | |
auto | toMultiline (const Container &arrayOfLines) |
Converts the specified arrayOfLines to a multiline string. | |
template<class Container = std::list<std::string>> | |
Container | splitString (Detail::StringParamForContainer< Container > string, Detail::StringParamForContainer< Container > delimiter, EmptyPartsTreat emptyPartsRole=EmptyPartsTreat::Keep, int maxParts=-1) |
Splits the given string at the specified delimiter. | |
template<class Container = std::list<std::string>> | |
Container | splitStringSimple (Detail::StringParamForContainer< Container > string, Detail::StringParamForContainer< Container > delimiter, int maxParts=-1) |
Splits the given string (which might also be a string view) at the specified delimiter. | |
template<class Container = std::vector<std::string>> | |
auto | toArrayOfLines (const std::string &multilineString) |
Converts the specified multilineString to an array of lines. | |
template<typename StringType > | |
bool | startsWith (const StringType &str, const StringType &phrase) |
Returns whether str starts with phrase. | |
template<typename StringType > | |
bool | startsWith (const StringType &str, const typename StringType::value_type *phrase) |
Returns whether str starts with phrase. | |
template<typename StringType > | |
bool | endsWith (const StringType &str, const StringType &phrase) |
Returns whether str ends with phrase. | |
template<typename StringType > | |
bool | endsWith (const StringType &str, const typename StringType::value_type *phrase) |
Returns whether str ends with phrase. | |
template<typename StringType > | |
bool | containsSubstrings (const StringType &str, std::initializer_list< StringType > substrings) |
Returns whether str contains the specified substrings. | |
template<typename StringType > | |
bool | containsSubstrings (const StringType &str, std::initializer_list< const typename StringType::value_type * > substrings) |
Returns whether str contains the specified substrings. | |
template<typename StringType1 , typename StringType2 , typename StringType3 > | |
void | findAndReplace (StringType1 &str, const StringType2 &find, const StringType3 &replace) |
Replaces all occurrences of find with relpace in the specified str. | |
template<typename StringType > | |
void | findAndReplace (StringType &str, const typename StringType::value_type *find, const typename StringType::value_type *replace) |
Replaces all occurrences of find with relpace in the specified str. | |
template<typename StringType1 , typename StringType2 > | |
void | findAndReplace (StringType1 &str, const StringType2 &find, const typename StringType1::value_type *replace) |
Replaces all occurrences of find with relpace in the specified str. | |
template<typename StringType1 , typename StringType2 > | |
void | findAndReplace (StringType1 &str, const typename StringType1::value_type *find, const StringType2 &replace) |
Replaces all occurrences of find with relpace in the specified str. | |
template<typename CharType > | |
constexpr CharType | digitToChar (CharType digit) |
Returns the character representation of the specified digit. | |
template<typename IntegralType , class StringType = std::string, typename BaseType = IntegralType, CppUtilities::Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType > > * = nullptr> | |
StringType | numberToString (IntegralType number, BaseType base=10) |
Converts the given number to its equivalent string representation using the specified base. | |
template<typename FloatingType , class StringType = std::string, Traits::EnableIf< std::is_floating_point< FloatingType > > * = nullptr> | |
StringType | numberToString (FloatingType number, int base=10) |
Converts the given number to its equivalent string representation using the specified base. | |
template<typename CharType > | |
CharType | charToDigit (CharType character, CharType base) |
Returns number/digit of the specified character representation using the specified base. | |
template<typename IntegralType , class CharType , typename BaseType = IntegralType, Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType > > * = nullptr> | |
IntegralType | bufferToNumber (const CharType *string, std::size_t size, BaseType base=10) |
Converts the given string of size characters to an unsigned numeric value using the specified base. | |
template<typename IntegralType , class StringType , typename BaseType = IntegralType, Traits::EnableIf< std::is_integral< IntegralType >, Traits::Not< std::is_scalar< std::decay_t< StringType > > > > * = nullptr> | |
IntegralType | stringToNumber (const StringType &string, BaseType base=10) |
Converts the given string to an unsigned/signed number assuming string uses the specified base. | |
template<typename FloatingType , class StringViewType , Traits::EnableIf< std::is_floating_point< FloatingType >, Traits::IsSpecializationOf< StringViewType, std::basic_string_view > > * = nullptr> | |
FloatingType | stringToNumber (StringViewType stringView, int base=10) |
Converts the given stringView to a number assuming stringView uses the specified base. | |
template<typename FloatingType , class StringType , Traits::EnableIf< std::is_floating_point< FloatingType >, Traits::Not< std::is_scalar< std::decay_t< StringType > > >, Traits::Not< Traits::IsSpecializationOf< StringType, std::basic_string_view > > > * = nullptr> | |
FloatingType | stringToNumber (const StringType &string, int base=10) |
Converts the given string to a number assuming string uses the specified base. | |
template<typename IntegralType , typename CharType , typename BaseType = IntegralType, Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType > > * = nullptr> | |
IntegralType | stringToNumber (const CharType *string, BaseType base=10) |
Converts the given null-terminated string to an unsigned numeric value using the specified base. | |
template<typename FloatingType , class CharType , Traits::EnableIf< std::is_floating_point< FloatingType > > * = nullptr> | |
FloatingType | stringToNumber (const CharType *string, int base=10) |
Converts the given null-terminated string to a number assuming string uses the specified base. | |
template<typename IntegralType , typename CharType , typename BaseType = IntegralType, Traits::EnableIf< std::is_integral< IntegralType >, std::is_signed< IntegralType > > * = nullptr> | |
IntegralType | stringToNumber (const CharType *string, IntegralType base=10) |
Converts the given null-terminated string to a signed numeric value using the specified base. | |
template<typename T > | |
std::string | interpretIntegerAsString (T integer, int startOffset=0) |
Interprets the given integer at the specified position as std::string using the specified byte order. | |
CPP_UTILITIES_EXPORT std::string | dataSizeToString (std::uint64_t sizeInByte, bool includeByte) |
Converts the specified data size in byte to its equivalent std::string representation. | |
CPP_UTILITIES_EXPORT std::string | bitrateToString (double bitrateInKbitsPerSecond, bool useIecBinaryPrefixes) |
Converts the specified bitrate in kbit/s to its equivalent std::string representation. | |
CPP_UTILITIES_EXPORT std::string | encodeBase64 (const std::uint8_t *data, std::uint32_t dataSize) |
Encodes the specified data to Base64. | |
CPP_UTILITIES_EXPORT std::pair< std::unique_ptr< std::uint8_t[]>, std::uint32_t > | decodeBase64 (const char *encodedStr, const std::uint32_t strSize) |
Decodes the specified Base64 encoded string. | |
template<class StringType = std::string, class... Args> | |
StringType | tupleToString (const std::tuple< Args... > &tuple) |
Concatenates all strings hold by the specified tuple. | |
template<class StringType = std::string, class... Args> | |
StringType | argsToString (Args &&...args) |
template<class Tuple , class StringType , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >, Traits::IsSpecializingAnyOf< StringType, std::basic_string, std::basic_string_view > > * = nullptr> | |
constexpr auto | operator% (const Tuple &lhs, const StringType &rhs) -> decltype(std::tuple_cat(lhs, std::tuple< const StringType & >(rhs))) |
Allows construction of string-tuples via %-operator, eg. | |
template<class Tuple , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple > > * = nullptr> | |
constexpr auto | operator% (const Tuple &lhs, const char *rhs) -> decltype(std::tuple_cat(lhs, std::tuple< const char * >(rhs))) |
Allows construction of string-tuples via %-operator, eg. | |
template<class Tuple , typename IntegralType , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >, std::is_integral< IntegralType > > * = nullptr> | |
constexpr auto | operator% (const Tuple &lhs, IntegralType rhs) -> decltype(std::tuple_cat(lhs, std::tuple< IntegralType >(rhs))) |
Allows construction of string-tuples via %-operator, eg. | |
template<class StringType , Traits::EnableIfAny< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view > > * = nullptr> | |
constexpr auto | operator% (const StringType &lhs, const StringType &rhs) -> decltype(std::tuple< const StringType &, const StringType & >(lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. | |
template<class StringType , Traits::EnableIfAny< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view > > * = nullptr> | |
constexpr auto | operator% (const char *lhs, const StringType &rhs) -> decltype(std::tuple< const char *, const StringType & >(lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. | |
template<class StringType , Traits::EnableIfAny< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view > > * = nullptr> | |
constexpr auto | operator% (const StringType &lhs, const char *rhs) -> decltype(std::tuple< const StringType &, const char * >(lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. | |
template<class StringType , Traits::EnableIfAny< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view > > * = nullptr> | |
constexpr auto | operator% (const StringType &lhs, char rhs) -> decltype(std::tuple< const StringType &, char >(lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. | |
template<class StringType , Traits::EnableIfAny< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view > > * = nullptr> | |
constexpr auto | operator% (char lhs, const StringType &rhs) -> decltype(std::tuple< char, const StringType & >(lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. | |
template<class Tuple , class StringType , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >, Traits::Any< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view > > > * = nullptr> | |
std::string | operator+ (const Tuple &lhs, const StringType &rhs) |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator. | |
template<class Tuple , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple > > * = nullptr> | |
std::string | operator+ (const Tuple &lhs, const char *rhs) |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator. | |
template<class Tuple , typename IntegralType , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >, std::is_integral< IntegralType > > * = nullptr> | |
std::string | operator+ (const Tuple &lhs, IntegralType rhs) |
Allows construction of final string from previously constructed string-tuple and trailing char via +-operator. | |
CPP_UTILITIES_EXPORT std::string | fileName (const std::string &path) |
Returns the file name and extension of the specified path string. | |
CPP_UTILITIES_EXPORT std::string | directory (const std::string &path) |
Returns the directory of the specified path string (including trailing slash). | |
CPP_UTILITIES_EXPORT void | removeInvalidChars (std::string &fileName) |
Removes invalid characters from the specified fileName. | |
NativePathStringView | makeNativePath (PathStringView path) |
Returns path in the platform's native encoding. | |
PathStringView | extractNativePath (NativePathStringView path) |
Returns path as UTF-8 string or string view. | |
CPP_UTILITIES_EXPORT std::string | readFile (const std::string &path, std::string::size_type maxSize) |
Reads all contents of the specified file in a single call. | |
CPP_UTILITIES_EXPORT void | writeFile (std::string_view path, std::string_view contents) |
Writes all contents to the specified file in a single call. | |
template<typename FlagEnumClass , Traits::EnableIf< IsFlagEnumClass< FlagEnumClass > > * = nullptr> | |
constexpr FlagEnumClass & | modFlagEnum (FlagEnumClass &flagVariable, FlagEnumClass relevantFlags, bool value) |
Sets the specified relevantFlags in the specified flagVariable to the specified value. | |
template<typename FlagEnumClass , Traits::EnableIf< IsFlagEnumClass< FlagEnumClass > > * = nullptr> | |
constexpr bool | checkFlagEnum (FlagEnumClass flagVariable, FlagEnumClass flagsToCheck) |
Returns whether the specified flagVariable has set all flags specified via flagsToCheck to true. | |
template<typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType > > * = nullptr> | |
constexpr IntegralType | digitsum (IntegralType number, IntegralType base=10) |
Returns the digitsum of the given number using the specified base. | |
template<typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType > > * = nullptr> | |
constexpr IntegralType | factorial (IntegralType number) |
Returns the factorial of the given number. | |
template<typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType > > * = nullptr> | |
constexpr IntegralType | powerModulo (const IntegralType base, const IntegralType exponent, const IntegralType module) |
Computes base power exponent modulo module. | |
template<typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType > > * = nullptr> | |
constexpr IntegralType | inverseModulo (IntegralType number, IntegralType module) |
Computes the inverse of number modulo module. | |
template<typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType > > * = nullptr> | |
constexpr IntegralType | orderModulo (const IntegralType number, const IntegralType module) |
Computes the order of number modulo module. | |
template<typename T > | |
constexpr T | min (T first, T second) |
Returns the smallest of the given items. | |
template<typename T1 , typename... T2> | |
constexpr T1 | min (T1 first, T1 second, T2... remaining) |
Returns the smallest of the given items. | |
template<typename T > | |
constexpr T | max (T first, T second) |
Returns the greatest of the given items. | |
template<typename T1 , typename... T2> | |
constexpr T1 | max (T1 first, T1 second, T2... remaining) |
Returns the greatest of the given items. | |
template<typename ValueType , typename... DimensionSizes> | |
auto | makeMultiArray (DimensionSizes... dimensionSizes) |
Constructs a new N-dimensional array using an std::vector with std::allocator as underlying container. The sizes for the dimensions are passed as arguments. | |
template<typename ValueType , std::size_t size, typename... DimensionSizes> | |
auto | makeFixedSizeMultiArray (DimensionSizes... dimensionSizes) |
Constructs a new N-dimensional array using a fixed size array as underlying container. The sizes for the dimensions are passed as arguments. | |
template<typename ValueType , typename... DimensionSizes> | |
auto | makeNoneOwningMultiArray (DimensionSizes... dimensionSizes) |
Constructs a new N-dimensional array using a caller-managed buffer as underlying container. The sizes for the dimensions are passed as arguments. | |
CPP_UTILITIES_EXPORT std::ostream & | operator<< (std::ostream &o, const ParseError &failure) |
Prints an error message "Unable to parse arguments: ..." for the specified failure. | |
CPP_UTILITIES_EXPORT std::size_t | computeDamerauLevenshteinDistance (const char *str1, std::size_t size1, const char *str2, std::size_t size2) |
std::size_t | computeDamerauLevenshteinDistance (const std::string &str1, const std::string &str2) |
std::size_t | computeDamerauLevenshteinDistance (const char *str1, const char *str2) |
CPP_UTILITIES_EXPORT std::string | testFilePath (const std::string &relativeTestFilePath) |
Convenience function to invoke TestApplication::testFilePath(). | |
CPP_UTILITIES_EXPORT std::string | testDirPath (const std::string &relativeTestDirPath) |
Convenience function to invoke TestApplication::testDirPath(). | |
CPP_UTILITIES_EXPORT std::string | workingCopyPath (const std::string &relativeTestFilePath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) |
Convenience function to invoke TestApplication::workingCopyPath(). | |
CPP_UTILITIES_EXPORT std::string | workingCopyPathAs (const std::string &relativeTestFilePath, const std::string &relativeWorkingCopyPath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) |
Convenience function to invoke TestApplication::workingCopyPathAs(). | |
template<typename Optional , Traits::EnableIf< Traits::IsSpecializationOf< Optional, std::optional > > * = nullptr> | |
std::ostream & | operator<< (std::ostream &out, const Optional &optional) |
Allows printing std::optional objects so those can be asserted using CPPUNIT_ASSERT_EQUAL. | |
template<typename T > | |
bool | operator== (const AsHexNumber< T > &lhs, const AsHexNumber< T > &rhs) |
Provides operator == required by CPPUNIT_ASSERT_EQUAL. | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const AsHexNumber< T > &value) |
Provides the actual formatting of the output for AsHexNumber class. | |
template<typename T > | |
AsHexNumber< T > | asHexNumber (const T &value) |
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework). | |
template<typename T , Traits::EnableIf< std::is_integral< T > > * = nullptr> | |
AsHexNumber< T > | integralsAsHexNumber (const T &value) |
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework). | |
template<typename T , Traits::DisableIf< std::is_integral< T > > * = nullptr> | |
const T & | integralsAsHexNumber (const T &value) |
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework). | |
template<typename Pair , CppUtilities::Traits::EnableIf< CppUtilities::Traits::IsSpecializationOf< Pair, std::pair > > * = nullptr> | |
std::ostream & | operator<< (std::ostream &out, const Pair &pair) |
Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL. | |
template<typename Iteratable , Traits::EnableIf< Traits::IsIteratable< Iteratable >, Traits::Not< Traits::IsString< Iteratable > > > * = nullptr> | |
std::ostream & | operator<< (std::ostream &out, const Iteratable &iteratable) |
Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL. | |
std::ostream & | operator<< (std::ostream &os, const Wrapper &wrapper) |
Argument * | firstPresentUncombinableArg (const ArgumentVector &args, const Argument *except) |
This function return the first present and uncombinable argument of the given list of arguments. | |
bool | compareArgs (const Argument *arg1, const Argument *arg2) |
Returns whether arg1 should be listed before arg2 when printing completion. | |
void | insertSiblings (const ArgumentVector &siblings, list< const Argument * > &target) |
Inserts the specified siblings in the target list. | |
template<typename num1 , typename num2 , typename num3 > | |
constexpr bool | inRangeInclMax (num1 val, num2 min, num3 max) |
template<typename num1 , typename num2 , typename num3 > | |
constexpr bool | inRangeExclMax (num1 val, num2 min, num3 max) |
std::string_view | fileName (std::string_view path) |
Returns the file name and extension of the specified path string. | |
std::string_view | directory (std::string_view path) |
Returns the directory of the specified path string (including trailing slash). | |
std::string | readFile (std::string_view path, std::string_view::size_type maxSize) |
Reads all contents of the specified file in a single call. | |
std::size_t | computeDamerauLevenshteinDistance (const char *const str1, const size_t size1, const char *const str2, const size_t size2) |
Computes Damerau–Levenshtein distance with adjacent transpositions. | |
CPP_UTILITIES_EXPORT FileMap | extractFiles (std::string_view archivePath, const FilePredicate &isFileRelevant) |
Extracts the specified archive. | |
CPP_UTILITIES_EXPORT void | walkThroughArchive (std::string_view archivePath, const FilePredicate &isFileRelevant, FileHandler &&fileHandler, DirectoryHandler &&directoryHandler) |
Invokes callbacks for files and directories in the specified archive. | |
CPP_UTILITIES_EXPORT FileMap | extractFilesFromBuffer (std::string_view archiveData, std::string_view archiveName, const FilePredicate &isFileRelevant) |
Extracts the specified archive. | |
CPP_UTILITIES_EXPORT void | walkThroughArchiveFromBuffer (std::string_view archiveData, std::string_view archiveName, const FilePredicate &isFileRelevant, FileHandler &&fileHandler, DirectoryHandler &&directoryHandler) |
Invokes callbacks for files and directories in the specified archive. | |
Variables | |
CPP_UTILITIES_EXPORT ApplicationInfo | applicationInfo |
Stores global application info used by ArgumentParser::printHelp() and AboutDialog. | |
Contains all utilities provides by the c++utilities library.
Contains classes and functions utilizing creating of test applications.
using CppUtilities::ArgumentInitializerList = std::initializer_list<Argument *> |
Definition at line 68 of file argumentparser.h.
using CppUtilities::ArgumentPredicate = std::function<bool(Argument *)> |
Definition at line 70 of file argumentparser.h.
using CppUtilities::ArgumentVector = std::vector<Argument *> |
Definition at line 69 of file argumentparser.h.
using CppUtilities::DirectoryHandler = std::function<bool(std::string_view path)> |
using CppUtilities::FileHandler = std::function<bool(std::string_view path, ArchiveFile &&file)> |
using CppUtilities::FileMap = std::map<std::string, std::vector<ArchiveFile>> |
using CppUtilities::FilePredicate = std::function<bool(const char *, const char *, mode_t)> |
using CppUtilities::NativeFileStream = std::fstream |
Definition at line 131 of file nativefilestream.h.
using CppUtilities::NativePathString = std::basic_string<PathValueType> |
using CppUtilities::NativePathStringView = std::basic_string_view<PathValueType> |
using CppUtilities::PathString = std::string |
using CppUtilities::PathStringView = std::string_view |
using CppUtilities::StringData = std::pair<std::unique_ptr<char[], StringDataDeleter>, std::size_t> |
Type used to return string encoding conversion result.
Definition at line 47 of file stringconversion.h.
|
strong |
enum CppUtilities::ArgumentDenotationType : unsigned char |
The ArgumentDenotationType enum specifies the type of a given argument denotation.
Enumerator | |
---|---|
Value | parameter value |
Abbreviation | argument abbreviation |
FullName | full argument name |
Definition at line 38 of file argumentparser.cpp.
|
strong |
Specifies the date part.
Enumerator | |
---|---|
Year | year |
Month | month |
DayOfYear | day of year |
Day | day |
Definition at line 48 of file datetime.h.
|
strong |
Specifies the output format.
Enumerator | |
---|---|
DateAndTime | date and time |
DateOnly | date only |
TimeOnly | time only |
DateTimeAndWeekday | date with weekday and time |
DateTimeAndShortWeekday | date with abbreviated weekday and time |
Iso | ISO format like DateTime::toIsoString() |
IsoOmittingDefaultComponents | ISO format like DateTime::toIsoString() omitting default components, e.g. just "2017" instead of "2017-01-01T00:00:00" |
Definition at line 19 of file datetime.h.
|
strong |
The DateTimeParts enum specifies which parts of a timestamp are present.
Enumerator | |
---|---|
None | no parts are present |
Year | the year is present |
Month | the month is present |
Day | the day is present |
Hour | the hour is present |
Minute | the minute is present |
Second | the second is present |
SubSecond | the second contains a fractional part |
DeltaHour | the timezone-delta hour is present |
DeltaMinute | the timezone-delta minute is present |
Date | year, month and day are present |
Time | hour, minute and (sub)second are present |
DateTime | all parts a DateTime object can represent are present |
TimeZoneDelta | the timezone-delta hour and minute are present |
All | all parts a DateTime object can represent plus the full timezone-delta are present |
Definition at line 145 of file datetime.h.
|
strong |
Specifies the day of the week.
Enumerator | |
---|---|
Monday | Monday |
Tuesday | Tuesday |
Wednesday | Wednesday |
Thursday | Thursday |
Friday | Friday |
Saturday | Saturday |
Sunday | Sunday |
Definition at line 33 of file datetime.h.
|
strong |
Specifies the role of empty parts when splitting strings.
Enumerator | |
---|---|
Keep | empty parts are kept |
Omit | empty parts are omitted |
Merge | empty parts are omitted but cause the adjacent parts being joined using the delimiter |
Definition at line 147 of file stringconversion.h.
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
The ParseArgumentBehavior enum specifies the behavior when parsing arguments.
This concerns checking constraints, invoking callbacks and handling failures. The values are supposed to be combined using the |-operator. Note that ParseArgumentBehavior::ReadArguments is always implied.
Definition at line 88 of file argumentparser.h.
|
strong |
The Response enum is used to specify the default response for the confirmPrompt() method.
Enumerator | |
---|---|
None | |
Yes | |
No |
Definition at line 19 of file commandlineutils.h.
|
strong |
Specifies the output format.
Definition at line 19 of file timespan.h.
|
strong |
The UnknownArgumentBehavior enum specifies the behavior of the argument parser when an unknown argument is detected.
Definition at line 76 of file argumentparser.h.
|
strong |
The ValueCompletionBehavior enum specifies the items to be considered when generating completion for an argument value.
Enumerator | |
---|---|
None | no auto-completion |
PreDefinedValues | values assigned with Argument::setPreDefinedCompletionValues() |
Files | files |
Directories | directories |
FileSystemIfNoPreDefinedValues | files and directories but only if no values have been assigned (default behavior) |
AppendEquationSign | an equation sign is appended to values which not contain an equation sign already |
InvokeCallback | whether to invoke the callback before reading pre-defined values |
Definition at line 117 of file argumentparser.h.
|
strong |
The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPath().
Definition at line 28 of file testutils.h.
|
inline |
Definition at line 260 of file stringbuilder.h.
AsHexNumber< T > CppUtilities::asHexNumber | ( | const T & | value | ) |
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework).
Definition at line 258 of file testutils.h.
string CppUtilities::bitrateToString | ( | double | bitrateInKbitsPerSecond, |
bool | useIecBinaryPrefixes ) |
Converts the specified bitrate in kbit/s to its equivalent std::string representation.
The unit with appropriate binary prefix will be appended.
bitrateInKbitsPerSecond | Specifies the bitrate in kbit/s. |
useIecBinaryPrefixes | Indicates whether IEC binary prefixes should be used (eg. KiB/s). |
Definition at line 345 of file stringconversion.cpp.
IntegralType CppUtilities::bufferToNumber | ( | const CharType * | string, |
std::size_t | size, | ||
BaseType | base = 10 ) |
Converts the given string of size characters to an unsigned numeric value using the specified base.
Converts the given string of size characters to a signed numeric value using the specified base.
IntegralType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 546 of file stringconversion.h.
CharType CppUtilities::charToDigit | ( | CharType | character, |
CharType | base ) |
Returns number/digit of the specified character representation using the specified base.
A | ConversionException will be thrown if the provided character does not represent a valid digit for the specified base. |
Definition at line 493 of file stringconversion.h.
|
constexpr |
Returns whether the specified flagVariable has set all flags specified via flagsToCheck to true.
Definition at line 104 of file flagenumclass.h.
Returns whether arg1 should be listed before arg2 when printing completion.
Arguments are sorted by name (ascending order). However, all arguments denoting an operation are listed before all other arguments.
Definition at line 1120 of file argumentparser.cpp.
std::size_t CppUtilities::computeDamerauLevenshteinDistance | ( | const char *const | str1, |
const size_t | size1, | ||
const char *const | str2, | ||
const size_t | size2 ) |
Computes Damerau–Levenshtein distance with adjacent transpositions.
Definition at line 125 of file levenshtein.cpp.
|
inline |
Definition at line 18 of file levenshtein.h.
CPP_UTILITIES_EXPORT std::size_t CppUtilities::computeDamerauLevenshteinDistance | ( | const char * | str1, |
std::size_t | size1, | ||
const char * | str2, | ||
std::size_t | size2 ) |
|
inline |
Definition at line 13 of file levenshtein.h.
bool CppUtilities::confirmPrompt | ( | const char * | message, |
Response | defaultResponse = Response::None ) |
Prompts for confirmation displaying the specified message.
Definition at line 27 of file commandlineutils.cpp.
bool CppUtilities::containsSubstrings | ( | const StringType & | str, |
std::initializer_list< const typename StringType::value_type * > | substrings ) |
Returns whether str contains the specified substrings.
Definition at line 354 of file stringconversion.h.
bool CppUtilities::containsSubstrings | ( | const StringType & | str, |
std::initializer_list< StringType > | substrings ) |
Returns whether str contains the specified substrings.
Definition at line 337 of file stringconversion.h.
StringData CppUtilities::convertLatin1ToUtf8 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize ) |
Converts the specified Latin-1 string to UTF-8.
Definition at line 194 of file stringconversion.cpp.
StringData CppUtilities::convertString | ( | const char * | fromCharset, |
const char * | toCharset, | ||
const char * | inputBuffer, | ||
std::size_t | inputBufferSize, | ||
float | outputBufferSizeFactor ) |
Converts the specified string from one character set to another.
Definition at line 149 of file stringconversion.cpp.
StringData CppUtilities::convertUtf16BEToUtf8 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize ) |
Converts the specified UTF-16 (big-endian) string to UTF-8.
Definition at line 185 of file stringconversion.cpp.
StringData CppUtilities::convertUtf16LEToUtf8 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize ) |
Converts the specified UTF-16 (little-endian) string to UTF-8.
Definition at line 167 of file stringconversion.cpp.
StringData CppUtilities::convertUtf8ToLatin1 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize ) |
Converts the specified UTF-8 string to Latin-1.
Definition at line 203 of file stringconversion.cpp.
StringData CppUtilities::convertUtf8ToUtf16BE | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize ) |
Converts the specified UTF-8 string to UTF-16 (big-endian).
Definition at line 176 of file stringconversion.cpp.
StringData CppUtilities::convertUtf8ToUtf16LE | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize ) |
Converts the specified UTF-8 string to UTF-16 (little-endian).
Definition at line 158 of file stringconversion.cpp.
string CppUtilities::dataSizeToString | ( | std::uint64_t | sizeInByte, |
bool | includeByte ) |
Converts the specified data size in byte to its equivalent std::string representation.
The unit with appropriate binary prefix will be appended.
Definition at line 313 of file stringconversion.cpp.
std::pair< unique_ptr< std::uint8_t[]>, std::uint32_t > CppUtilities::decodeBase64 | ( | const char * | encodedStr, |
const std::uint32_t | strSize ) |
Decodes the specified Base64 encoded string.
Throws | a ConversionException if the specified string is no valid Base64. |
Definition at line 424 of file stringconversion.cpp.
TerminalSize CppUtilities::determineTerminalSize | ( | ) |
Returns the current size of the terminal.
Definition at line 73 of file commandlineutils.cpp.
|
constexpr |
|
constexpr |
Returns the character representation of the specified digit.
Definition at line 411 of file stringconversion.h.
std::string CppUtilities::directory | ( | const std::string & | path | ) |
std::string_view CppUtilities::directory | ( | std::string_view | path | ) |
string CppUtilities::encodeBase64 | ( | const std::uint8_t * | data, |
std::uint32_t | dataSize ) |
Encodes the specified data to Base64.
Definition at line 384 of file stringconversion.cpp.
bool CppUtilities::endsWith | ( | const StringType & | str, |
const StringType & | phrase ) |
Returns whether str ends with phrase.
Definition at line 301 of file stringconversion.h.
bool CppUtilities::endsWith | ( | const StringType & | str, |
const typename StringType::value_type * | phrase ) |
Returns whether str ends with phrase.
Definition at line 318 of file stringconversion.h.
FileMap CppUtilities::extractFiles | ( | std::string_view | archivePath, |
const FilePredicate & | isFileRelevant = FilePredicate() ) |
Extracts the specified archive.
Definition at line 259 of file archive.cpp.
FileMap CppUtilities::extractFilesFromBuffer | ( | std::string_view | archiveData, |
std::string_view | archiveName, | ||
const FilePredicate & | isFileRelevant = FilePredicate() ) |
Extracts the specified archive.
Definition at line 217 of file archive.cpp.
|
inline |
Returns path as UTF-8 string or string view.
|
constexpr |
std::string CppUtilities::fileName | ( | const std::string & | path | ) |
std::string_view CppUtilities::fileName | ( | std::string_view | path | ) |
|
inline |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 381 of file stringconversion.h.
void CppUtilities::findAndReplace | ( | StringType1 & | str, |
const StringType2 & | find, | ||
const StringType3 & | replace ) |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 370 of file stringconversion.h.
|
inline |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 391 of file stringconversion.h.
|
inline |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 400 of file stringconversion.h.
Argument * CppUtilities::firstPresentUncombinableArg | ( | const ArgumentVector & | args, |
const Argument * | except ) |
This function return the first present and uncombinable argument of the given list of arguments.
The Argument except will be ignored.
Definition at line 592 of file argumentparser.cpp.
|
constexpr |
Definition at line 31 of file datetime.cpp.
|
constexpr |
Definition at line 26 of file datetime.cpp.
void CppUtilities::insertSiblings | ( | const ArgumentVector & | siblings, |
list< const Argument * > & | target ) |
Inserts the specified siblings in the target list.
Definition at line 1135 of file argumentparser.cpp.
AsHexNumber< T > CppUtilities::integralsAsHexNumber | ( | const T & | value | ) |
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework).
Definition at line 268 of file testutils.h.
const T & CppUtilities::integralsAsHexNumber | ( | const T & | value | ) |
Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework).
Definition at line 278 of file testutils.h.
std::string CppUtilities::interpretIntegerAsString | ( | T | integer, |
int | startOffset = 0 ) |
Interprets the given integer at the specified position as std::string using the specified byte order.
Example: interpretation of ID3v2 frame IDs (stored as 32-bit integer) as string
T | The data type of the integer to be interpreted. |
Definition at line 717 of file stringconversion.h.
|
constexpr |
std::optional< bool > CppUtilities::isEnvVariableSet | ( | const char * | variableName | ) |
Returns whether the specified env variable is set to a non-zero and non-white-space-only value.
Definition at line 51 of file commandlineutils.cpp.
ReturnType CppUtilities::joinStrings | ( | const Container & | strings, |
Detail::StringParamForContainer< Container > | delimiter = Detail::StringParamForContainer<Container>(), | ||
bool | omitEmpty = false, | ||
Detail::StringParamForContainer< Container > | leftClosure = Detail::StringParamForContainer<Container>(), | ||
Detail::StringParamForContainer< Container > | rightClosure = Detail::StringParamForContainer<Container>() ) |
Joins the given strings using the specified delimiter.
The strings will be enclosed using the provided closures leftClosure and rightClosure.
strings | The string parts to be joined. |
delimiter | Specifies a delimiter to be used (empty string by default). |
omitEmpty | Indicates whether empty part should be omitted. |
leftClosure | Specifies a string to be inserted before each string (empty string by default). |
rightClosure | Specifies a string to be appended after each string (empty string by default). |
Container | Container The STL-container used to provide the strings. |
ReturnType | Type to store the result; defaults to the container's element type. |
Definition at line 101 of file stringconversion.h.
|
inline |
Constructs a new N-dimensional array using a fixed size array as underlying container. The sizes for the dimensions are passed as arguments.
Definition at line 177 of file multiarray.h.
|
inline |
Constructs a new N-dimensional array using an std::vector with std::allocator as underlying container. The sizes for the dimensions are passed as arguments.
Definition at line 169 of file multiarray.h.
|
inline |
Returns path in the platform's native encoding.
std::filesystem::u8path
implementation. However, the C++ standard actually imposes a conversion to UTF-8 when a non-UTF-8 narrow encoding is used. That's not wanted here. Besides, that function is deprecated in C++ 20.
|
inline |
Constructs a new N-dimensional array using a caller-managed buffer as underlying container. The sizes for the dimensions are passed as arguments.
Definition at line 185 of file multiarray.h.
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Sets the specified relevantFlags in the specified flagVariable to the specified value.
Definition at line 95 of file flagenumclass.h.
StringType CppUtilities::numberToString | ( | FloatingType | number, |
int | base = 10 ) |
Converts the given number to its equivalent string representation using the specified base.
FloatingType | The data type of the given number. |
StringType | The string type (should be an instantiation of the basic_string class template). |
Definition at line 482 of file stringconversion.h.
StringType CppUtilities::numberToString | ( | IntegralType | number, |
BaseType | base = 10 ) |
Converts the given number to its equivalent string representation using the specified base.
IntegralType | The data type of the given number. |
StringType | The string type (should be an instantiation of the basic_string class template). |
Definition at line 424 of file stringconversion.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 345 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 312 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 334 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 323 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 301 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 280 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 271 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 290 of file stringbuilder.h.
|
inline |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator.
This is meant to be used for fast string building without multiple heap allocation, eg.
Definition at line 378 of file stringbuilder.h.
|
inline |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator.
This is meant to be used for fast string building without multiple heap allocation, eg.
Definition at line 363 of file stringbuilder.h.
|
inline |
Allows construction of final string from previously constructed string-tuple and trailing char via +-operator.
This is meant to be used for fast string building without multiple heap allocation, eg.
Definition at line 394 of file stringbuilder.h.
Adds the specified period to the specified date.
Might | throw ConversionException if resulting DateTime would be out-of-range. |
Definition at line 60 of file period.cpp.
std::ostream & CppUtilities::operator<< | ( | std::ostream & | o, |
const ParseError & | failure ) |
Prints an error message "Unable to parse arguments: ..." for the specified failure.
Definition at line 26 of file parseerror.cpp.
ostream & CppUtilities::operator<< | ( | std::ostream & | os, |
const Wrapper & | wrapper ) |
Definition at line 407 of file argumentparser.cpp.
std::ostream & CppUtilities::operator<< | ( | std::ostream & | out, |
const AsHexNumber< T > & | value ) |
Provides the actual formatting of the output for AsHexNumber class.
Definition at line 249 of file testutils.h.
|
inline |
Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL.
Definition at line 354 of file testutils.h.
|
inline |
Allows printing std::optional objects so those can be asserted using CPPUNIT_ASSERT_EQUAL.
Definition at line 215 of file testutils.h.
|
inline |
Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL.
Definition at line 345 of file testutils.h.
|
inline |
Definition at line 88 of file commandlineutils.h.
bool CppUtilities::operator== | ( | const AsHexNumber< T > & | lhs, |
const AsHexNumber< T > & | rhs ) |
Provides operator == required by CPPUNIT_ASSERT_EQUAL.
Definition at line 241 of file testutils.h.
|
constexpr |
|
constexpr |
std::string CppUtilities::readFile | ( | const std::string & | path, |
std::string::size_type | maxSize ) |
std::string CppUtilities::readFile | ( | std::string_view | path, |
std::string_view::size_type | maxSize ) |
void CppUtilities::removeInvalidChars | ( | std::string & | fileName | ) |
Container CppUtilities::splitString | ( | Detail::StringParamForContainer< Container > | string, |
Detail::StringParamForContainer< Container > | delimiter, | ||
EmptyPartsTreat | emptyPartsRole = EmptyPartsTreat::Keep, | ||
int | maxParts = -1 ) |
Splits the given string at the specified delimiter.
string | The string to be split. |
delimiter | Specifies the delimiter which must not be empty. |
emptyPartsRole | Specifies the treatment of empty parts. |
maxParts | Specifies the maximal number of parts. Values less or equal zero indicate an unlimited number of parts. |
Container | The STL-container used to return the parts. |
Definition at line 163 of file stringconversion.h.
Container CppUtilities::splitStringSimple | ( | Detail::StringParamForContainer< Container > | string, |
Detail::StringParamForContainer< Container > | delimiter, | ||
int | maxParts = -1 ) |
Splits the given string (which might also be a string view) at the specified delimiter.
string | The string to be split. |
delimiter | Specifies the delimiter which must not be empty. |
maxParts | Specifies the maximal number of parts. Values less or equal zero indicate an unlimited number of parts. |
Container | The STL-container used to return the parts. |
Definition at line 215 of file stringconversion.h.
bool CppUtilities::startsWith | ( | const StringType & | str, |
const StringType & | phrase ) |
Returns whether str starts with phrase.
Definition at line 264 of file stringconversion.h.
bool CppUtilities::startsWith | ( | const StringType & | str, |
const typename StringType::value_type * | phrase ) |
Returns whether str starts with phrase.
Definition at line 284 of file stringconversion.h.
IntegralType CppUtilities::stringToNumber | ( | const CharType * | string, |
BaseType | base = 10 ) |
Converts the given null-terminated string to an unsigned numeric value using the specified base.
IntegralType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 654 of file stringconversion.h.
FloatingType CppUtilities::stringToNumber | ( | const CharType * | string, |
int | base = 10 ) |
Converts the given null-terminated string to a number assuming string uses the specified base.
FloatingType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 673 of file stringconversion.h.
IntegralType CppUtilities::stringToNumber | ( | const CharType * | string, |
IntegralType | base = 10 ) |
Converts the given null-terminated string to a signed numeric value using the specified base.
IntegralType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 687 of file stringconversion.h.
IntegralType CppUtilities::stringToNumber | ( | const StringType & | string, |
BaseType | base = 10 ) |
Converts the given string to an unsigned/signed number assuming string uses the specified base.
IntegralType | The data type used to store the converted value. |
StringType | The string type (should be an instantiation of the basic_string class template). |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 595 of file stringconversion.h.
FloatingType CppUtilities::stringToNumber | ( | const StringType & | string, |
int | base = 10 ) |
Converts the given string to a number assuming string uses the specified base.
FloatingType | The data type used to store the converted value. |
StringType | The string type (should be an instantiation of the basic_string class template). |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 639 of file stringconversion.h.
FloatingType CppUtilities::stringToNumber | ( | StringViewType | stringView, |
int | base = 10 ) |
Converts the given stringView to a number assuming stringView uses the specified base.
FloatingType | The data type used to store the converted value. |
StringViewType | The string view type (must be an instantiation of the basic_string_view class template). |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 611 of file stringconversion.h.
|
constexpr |
Swaps the byte order of the specified 16-bit integer.
Definition at line 174 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 32-bit integer.
Definition at line 182 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 64-bit integer.
Definition at line 191 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 16-bit unsigned integer.
Definition at line 148 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 32-bit unsigned integer.
Definition at line 156 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 64-bit unsigned integer.
Definition at line 164 of file binaryconversion.h.
|
inline |
Convenience function to invoke TestApplication::testDirPath().
Definition at line 170 of file testutils.h.
|
inline |
Convenience function to invoke TestApplication::testFilePath().
Definition at line 161 of file testutils.h.
|
inline |
Converts the specified multilineString to an array of lines.
Definition at line 256 of file stringconversion.h.
|
constexpr |
Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number.
Definition at line 102 of file binaryconversion.h.
|
constexpr |
Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number.
Definition at line 86 of file binaryconversion.h.
|
constexpr |
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.
Definition at line 94 of file binaryconversion.h.
|
constexpr |
Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation.
Definition at line 110 of file binaryconversion.h.
|
inline |
Converts the specified arrayOfLines to a multiline string.
Definition at line 139 of file stringconversion.h.
|
constexpr |
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
Definition at line 130 of file binaryconversion.h.
|
constexpr |
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
Definition at line 120 of file binaryconversion.h.
void CppUtilities::truncateString | ( | std::string & | str, |
char | terminationChar = '\0' ) |
Truncates all characters after the first occurrence of the specified terminationChar and the termination character as well.
Definition at line 300 of file stringconversion.cpp.
|
inline |
Concatenates all strings hold by the specified tuple.
Definition at line 252 of file stringbuilder.h.
void CppUtilities::walkThroughArchive | ( | std::string_view | archivePath, |
const FilePredicate & | isFileRelevant = FilePredicate(), | ||
FileHandler && | fileHandler = FileHandler(), | ||
DirectoryHandler && | directoryHandler = DirectoryHandler() ) |
Invokes callbacks for files and directories in the specified archive.
Definition at line 227 of file archive.cpp.
void CppUtilities::walkThroughArchiveFromBuffer | ( | std::string_view | archiveData, |
std::string_view | archiveName, | ||
const FilePredicate & | isFileRelevant = FilePredicate(), | ||
FileHandler && | fileHandler = FileHandler(), | ||
DirectoryHandler && | directoryHandler = DirectoryHandler() ) |
Invokes callbacks for files and directories in the specified archive.
Definition at line 192 of file archive.cpp.
|
inline |
Convenience function to invoke TestApplication::workingCopyPath().
Definition at line 179 of file testutils.h.
|
inline |
Convenience function to invoke TestApplication::workingCopyPathAs().
Definition at line 188 of file testutils.h.
void CppUtilities::writeFile | ( | std::string_view | path, |
std::string_view | contents ) |
CPP_UTILITIES_EXPORT ApplicationInfo CppUtilities::applicationInfo |
Stores global application info used by ArgumentParser::printHelp() and AboutDialog.
Definition at line 436 of file argumentparser.cpp.