C++ Utilities
5.10.5
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
Contains all utilities provides by the c++utilities library. More...
Namespaces | |
BE | |
Encapsulates binary conversion functions using the big endian byte order. | |
EscapeCodes | |
Encapsulates functions for formatted terminal output using ANSI escape codes. | |
FlagEnumClassOperations | |
The FlagEnumClassOperations namespace contains operations for flag enums. | |
LE | |
Encapsulates binary conversion functions using the little endian byte order. | |
Literals | |
Contains literals to ease asserting with CPPUNIT_ASSERT_EQUAL. | |
Traits | |
Contains traits for conveniently exploiting SFINAE. | |
ValueConversion | |
Contains functions to convert raw argument values to certain types. | |
Classes | |
struct | ApplicationInfo |
Stores information about an application. More... | |
struct | ArgumentOccurrence |
The ArgumentOccurrence struct holds argument values for an occurrence of an argument. More... | |
class | Argument |
The Argument class is a wrapper for command line argument information. More... | |
class | HelpArgument |
The HelpArgument class prints help information for an argument parser when present (–help, -h). More... | |
class | OperationArgument |
The OperationArgument class is an Argument where denotesOperation() is true by default. More... | |
class | ConfigValueArgument |
The ConfigValueArgument class is an Argument where setCombinable() is true by default. 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... | |
class | ArgumentParser |
The ArgumentParser class provides a means for handling command line arguments. More... | |
struct | TerminalSize |
The TerminalSize struct describes a terminal size. More... | |
class | Indentation |
The Indentation class allows printing indentation conveniently, eg. 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 | DateTime |
Represents an instant in time, typically expressed as a date and time of day. More... | |
class | Period |
Represents a period of time. More... | |
class | TimeSpan |
Represents a time interval. More... | |
class | ConversionException |
The ConversionException class is thrown by the various conversion functions of this library when a conversion error occurs. More... | |
struct | StringDataDeleter |
The StringDataDeleter struct deletes the data of a StringData instance. 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 | CopyHelper |
The CopyHelper class helps to copy bytes from one stream to another. More... | |
class | IniFile |
The IniFile class allows parsing and writing INI files. More... | |
class | AdvancedIniFile |
The AdvancedIniFile 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 \tp T. 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... | |
struct | ArrayBasedMultiArray |
The ArrayBasedMultiArray struct allows using a fixed size array as underlying container for the MultiArray class. More... | |
struct | NoneOwningMultiArray |
The NoneOwningMultiArray struct allows using a caller-managed buffer array as underlying container for the MultiArray class. More... | |
class | MultiArray |
The MultiArray class provides an N-dimensional array. More... | |
class | ParseError |
The ParseError class is thrown by an ArgumentParser when a parsing error occurs. More... | |
class | TestApplication |
The TestApplication class simplifies writing test applications that require opening test files. 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 | OutputCheck |
The StandardOutputCheck class asserts whether the (standard) output written in the enclosing code block matches the expected output. More... | |
class | ArgumentReader |
The ArgumentReader class internally encapsulates the process of reading command line arguments. More... | |
class | Wrapper |
The Wrapper class is internally used print text which might needs to be wrapped preserving the indentation. More... | |
struct | ArgumentCompletionInfo |
The ArgumentCompletionInfo struct holds information internally used for shell completion and suggestions. 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. More... | |
using | NativeFileStream = std::fstream |
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 | 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 } |
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... | |
Functions | |
CPP_UTILITIES_EXPORT bool | confirmPrompt (const char *message, Response defaultResponse) |
Prompts for confirmation displaying the specified message. More... | |
CPP_UTILITIES_EXPORT TerminalSize | determineTerminalSize () |
Returns the current size of the terminal. More... | |
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. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint16_t | toFixed8 (float float32value) |
Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number. More... | |
constexpr CPP_UTILITIES_EXPORT float | toFloat32 (std::uint16_t fixed8value) |
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint32_t | toFixed16 (float float32value) |
Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number. More... | |
constexpr CPP_UTILITIES_EXPORT float | toFloat32 (std::uint32_t fixed16value) |
Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint32_t | toSynchsafeInt (std::uint32_t normalInt) |
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint32_t | toNormalInt (std::uint32_t synchsafeInt) |
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint16_t | swapOrder (std::uint16_t value) |
Swaps the byte order of the specified 16-bit unsigned integer. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint32_t | swapOrder (std::uint32_t value) |
Swaps the byte order of the specified 32-bit unsigned integer. More... | |
constexpr CPP_UTILITIES_EXPORT std::uint64_t | swapOrder (std::uint64_t value) |
Swaps the byte order of the specified 64-bit unsigned integer. More... | |
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. More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToUtf16LE (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to UTF-16 (little-endian). More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf16LEToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-16 (little-endian) string to UTF-8. More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToUtf16BE (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to UTF-16 (big-endian). More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf16BEToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-16 (big-endian) string to UTF-8. More... | |
CPP_UTILITIES_EXPORT StringData | convertLatin1ToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified Latin-1 string to UTF-8. More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToLatin1 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to Latin-1. More... | |
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. More... | |
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. More... | |
template<class Container = std::initializer_list<std::string>> | |
auto | toMultiline (const Container &arrayOfLines) |
Converts the specified arrayOfLines to a multiline string. More... | |
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. More... | |
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. More... | |
template<class Container = std::vector<std::string>> | |
auto | toArrayOfLines (const std::string &multilineString) |
Converts the specified multilineString to an array of lines. More... | |
template<typename StringType > | |
bool | startsWith (const StringType &str, const StringType &phrase) |
Returns whether str starts with phrase. More... | |
template<typename StringType > | |
bool | startsWith (const StringType &str, const typename StringType::value_type *phrase) |
Returns whether str starts with phrase. More... | |
template<typename StringType > | |
bool | endsWith (const StringType &str, const StringType &phrase) |
Returns whether str ends with phrase. More... | |
template<typename StringType > | |
bool | endsWith (const StringType &str, const typename StringType::value_type *phrase) |
Returns whether str ends with phrase. More... | |
template<typename StringType > | |
bool | containsSubstrings (const StringType &str, std::initializer_list< StringType > substrings) |
Returns whether str contains the specified substrings. More... | |
template<typename StringType > | |
bool | containsSubstrings (const StringType &str, std::initializer_list< const typename StringType::value_type * > substrings) |
Returns whether str contains the specified substrings. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
template<typename CharType > | |
constexpr CharType | digitToChar (CharType digit) |
Returns the character representation of the specified digit. More... | |
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. More... | |
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. More... | |
template<typename CharType > | |
CharType | charToDigit (CharType character, CharType base) |
Returns number/digit of the specified character representation using the specified base. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
CPP_UTILITIES_EXPORT std::string | bitrateToString (double bitrateInKbitsPerSecond, bool useIecBinaryPrefixes) |
Converts the specified bitrate in kbit/s to its equivalent std::string representation. More... | |
CPP_UTILITIES_EXPORT std::string | encodeBase64 (const std::uint8_t *data, std::uint32_t dataSize) |
Encodes the specified data to Base64. More... | |
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. More... | |
template<class StringType = std::string, class... Args> | |
StringType | tupleToString (const std::tuple< Args... > &tuple) |
Concatenates all strings hold by the specified tuple. More... | |
template<class StringType = std::string, class... Args> | |
StringType | argsToString (Args &&...args) |
template<class Tuple , class StringType , Traits::EnableIfAny< Traits::IsSpecializationOf< StringType, std::basic_string >, Traits::IsSpecializationOf< StringType, std::basic_string_view >> * = nullptr> | |
constexpr auto | operator% (const Tuple &lhs, const StringType &rhs) -> decltype(std::tuple_cat(lhs, std::make_tuple(&rhs))) |
Allows construction of string-tuples via %-operator, eg. More... | |
template<class Tuple > | |
constexpr auto | operator% (const Tuple &lhs, const char *rhs) -> decltype(std::tuple_cat(lhs, std::make_tuple(rhs))) |
Allows construction of string-tuples via %-operator, eg. More... | |
template<class Tuple , typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType >> * = nullptr> | |
constexpr auto | operator% (const Tuple &lhs, IntegralType rhs) -> decltype(std::tuple_cat(lhs, std::make_tuple(rhs))) |
Allows construction of string-tuples via %-operator, eg. More... | |
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::make_tuple(&lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
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::make_tuple(lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
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::make_tuple(&lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
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::make_tuple(&lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
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::make_tuple(lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
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. More... | |
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. More... | |
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. More... | |
CPP_UTILITIES_EXPORT std::string | fileName (const string &path) |
Returns the file name and extension of the specified path string. More... | |
CPP_UTILITIES_EXPORT std::string | directory (const string &path) |
Returns the directory of the specified path string (including trailing slash). More... | |
CPP_UTILITIES_EXPORT void | removeInvalidChars (std::string &fileName) |
Removes invalid characters from the specified fileName. More... | |
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. More... | |
CPP_UTILITIES_EXPORT void | writeFile (std::string_view path, std::string_view contents) |
Writes all contents to the specified file in a single call. More... | |
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. More... | |
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. More... | |
template<typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType >> * = nullptr> | |
constexpr IntegralType | factorial (IntegralType number) |
Returns the factorial of the given number. More... | |
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. More... | |
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. More... | |
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. More... | |
template<typename T > | |
constexpr T | min (T first, T second) |
Returns the smallest of the given items. More... | |
template<typename T1 , typename... T2> | |
constexpr T1 | min (T1 first, T1 second, T2... remaining) |
Returns the smallest of the given items. More... | |
template<typename T > | |
constexpr T | max (T first, T second) |
Returns the greatest of the given items. More... | |
template<typename T1 , typename... T2> | |
constexpr T1 | max (T1 first, T1 second, T2... remaining) |
Returns the greatest of the given items. More... | |
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. More... | |
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. More... | |
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. More... | |
CPP_UTILITIES_EXPORT std::ostream & | operator<< (std::ostream &o, const ParseError &failure) |
Prints an error message "Unable to parse arguments: ..." for the specified failure. More... | |
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(). More... | |
CPP_UTILITIES_EXPORT std::string | testDirPath (const std::string &relativeTestDirPath) |
Convenience function to invoke TestApplication::testDirPath(). More... | |
CPP_UTILITIES_EXPORT std::string | workingCopyPath (const std::string &relativeTestFilePath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) |
Convenience function to invoke TestApplication::workingCopyPath(). More... | |
CPP_UTILITIES_EXPORT std::string | workingCopyPathAs (const std::string &relativeTestFilePath, const std::string &relativeWorkingCopyPath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) |
Convenience function to invoke TestApplication::workingCopyPathAs(). More... | |
template<typename T > | |
bool | operator== (const AsHexNumber< T > &lhs, const AsHexNumber< T > &rhs) |
Provides operator == required by CPPUNIT_ASSERT_EQUAL. More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const AsHexNumber< T > &value) |
Provides the actual formatting of the output for AsHexNumber class. More... | |
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). More... | |
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). More... | |
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). More... | |
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. More... | |
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. More... | |
std::ostream & | operator<< (std::ostream &os, const Wrapper &wrapper) |
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. More... | |
Argument * | firstPresentUncombinableArg (const ArgumentVector &args, const Argument *except) |
This function return the first present and uncombinable argument of the given list of arguments. More... | |
bool | compareArgs (const Argument *arg1, const Argument *arg2) |
Returns whether arg1 should be listed before arg2 when printing completion. More... | |
void | insertSiblings (const ArgumentVector &siblings, list< const Argument * > &target) |
Inserts the specified siblings in the target list. More... | |
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::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. More... | |
Variables | |
CPP_UTILITIES_EXPORT ApplicationInfo | applicationInfo |
Stores global application info used by ArgumentParser::printHelp() and AboutDialog. More... | |
Contains all utilities provides by the c++utilities library.
Contains classes and functions utilizing creating of test applications.
using CppUtilities::ArgumentInitializerList = typedef std::initializer_list<Argument *> |
Definition at line 67 of file argumentparser.h.
using CppUtilities::ArgumentPredicate = typedef std::function<bool(Argument *)> |
Definition at line 69 of file argumentparser.h.
using CppUtilities::ArgumentVector = typedef std::vector<Argument *> |
Definition at line 68 of file argumentparser.h.
using CppUtilities::NativeFileStream = typedef std::fstream |
Definition at line 108 of file nativefilestream.h.
using CppUtilities::StringData = typedef 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.
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 59 of file argumentparser.cpp.
|
strong |
Specifies the date part.
Enumerator | |
---|---|
Year | year |
Month | month |
DayOfYear | day of year |
Day | day |
Definition at line 46 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 17 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 31 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 144 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 87 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 18 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 75 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 116 of file argumentparser.h.
|
strong |
The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPath().
Enumerator | |
---|---|
CreateCopy | a working copy of the test file is created |
NoCopy | only the directory for the working copy is created but not the test file itself |
Definition at line 16 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 232 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 302 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 538 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 487 of file stringconversion.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 1111 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 117 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 22 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 351 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 334 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 179 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 134 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 170 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 152 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 188 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 161 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 143 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 270 of file stringconversion.cpp.
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 381 of file stringconversion.cpp.
TerminalSize CppUtilities::determineTerminalSize | ( | ) |
Returns the current size of the terminal.
Definition at line 47 of file commandlineutils.cpp.
|
constexpr |
|
constexpr |
Returns the character representation of the specified digit.
Definition at line 408 of file stringconversion.h.
string CppUtilities::directory | ( | const std::string & | path | ) |
string CppUtilities::encodeBase64 | ( | const std::uint8_t * | data, |
std::uint32_t | dataSize | ||
) |
Encodes the specified data to Base64.
Definition at line 341 of file stringconversion.cpp.
bool CppUtilities::endsWith | ( | const StringType & | str, |
const StringType & | phrase | ||
) |
Returns whether str ends with phrase.
Definition at line 298 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 315 of file stringconversion.h.
|
constexpr |
string CppUtilities::fileName | ( | const std::string & | path | ) |
|
inline |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 378 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 367 of file stringconversion.h.
|
inline |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 388 of file stringconversion.h.
|
inline |
Replaces all occurrences of find with relpace in the specified str.
Definition at line 397 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 609 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 1126 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 242 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 252 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 709 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 38 of file argumentparser.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 98 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 |
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 83 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 476 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 421 of file stringconversion.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 343 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 310 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 332 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 321 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 299 of file stringbuilder.h.
|
constexpr |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 279 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 288 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 376 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 361 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 392 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 424 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 223 of file testutils.h.
|
inline |
Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL.
Definition at line 303 of file testutils.h.
|
inline |
Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL.
Definition at line 294 of file testutils.h.
|
inline |
Definition at line 83 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 215 of file testutils.h.
|
constexpr |
|
constexpr |
std::string CppUtilities::readFile | ( | const std::string & | path, |
std::string::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. |
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 160 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. |
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 212 of file stringconversion.h.
bool CppUtilities::startsWith | ( | const StringType & | str, |
const StringType & | phrase | ||
) |
Returns whether str starts with phrase.
Definition at line 261 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 281 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 646 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 665 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 679 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 587 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 631 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 603 of file stringconversion.h.
|
constexpr |
Swaps the byte order of the specified 16-bit unsigned integer.
Definition at line 154 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 32-bit unsigned integer.
Definition at line 162 of file binaryconversion.h.
|
constexpr |
Swaps the byte order of the specified 64-bit unsigned integer.
Definition at line 170 of file binaryconversion.h.
|
inline |
Convenience function to invoke TestApplication::testDirPath().
Definition at line 157 of file testutils.h.
|
inline |
Convenience function to invoke TestApplication::testFilePath().
Definition at line 148 of file testutils.h.
|
inline |
Converts the specified multilineString to an array of lines.
Definition at line 253 of file stringconversion.h.
|
constexpr |
Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number.
Definition at line 117 of file binaryconversion.h.
|
constexpr |
Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number.
Definition at line 101 of file binaryconversion.h.
|
constexpr |
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.
Definition at line 109 of file binaryconversion.h.
|
constexpr |
Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation.
Definition at line 125 of file binaryconversion.h.
|
inline |
Converts the specified arrayOfLines to a multiline string.
Definition at line 136 of file stringconversion.h.
|
constexpr |
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
Definition at line 145 of file binaryconversion.h.
|
constexpr |
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
Definition at line 135 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 257 of file stringconversion.cpp.
|
inline |
Concatenates all strings hold by the specified tuple.
Definition at line 252 of file stringbuilder.h.
|
inline |
Convenience function to invoke TestApplication::workingCopyPath().
Definition at line 166 of file testutils.h.
|
inline |
Convenience function to invoke TestApplication::workingCopyPathAs().
Definition at line 175 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 453 of file argumentparser.cpp.