Have everything in one top-level namespace
This commit is contained in:
parent
d9e498ba79
commit
b48b2f5c06
|
@ -21,15 +21,13 @@
|
|||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace std::literals;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace EscapeCodes;
|
||||
using namespace IoUtilities;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
|
||||
/*!
|
||||
* \namespace ApplicationUtilities
|
||||
* \brief Contains currently only ArgumentParser and related classes.
|
||||
* \namespace CppUtilities
|
||||
* \brief Contains all utilities provides by the c++utilities library.
|
||||
*/
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief The ArgumentDenotationType enum specifies the type of a given argument denotation.
|
||||
|
@ -82,7 +80,7 @@ struct ArgumentSuggestion {
|
|||
ArgumentSuggestion::ArgumentSuggestion(const char *unknownArg, size_t unknownArgSize, const char *suggestion, size_t suggestionSize, bool isOperation)
|
||||
: suggestion(suggestion)
|
||||
, suggestionSize(suggestionSize)
|
||||
, editingDistance(MiscUtilities::computeDamerauLevenshteinDistance(unknownArg, unknownArgSize, suggestion, suggestionSize))
|
||||
, editingDistance(computeDamerauLevenshteinDistance(unknownArg, unknownArgSize, suggestion, suggestionSize))
|
||||
, hasDashPrefix(isOperation)
|
||||
{
|
||||
}
|
||||
|
@ -1022,7 +1020,7 @@ bool ArgumentParser::isUncombinableMainArgPresent() const
|
|||
* - Verifies the sub arguments, too.
|
||||
* - For debugging purposes only; hence only used in debug builds.
|
||||
*/
|
||||
void ApplicationUtilities::ArgumentParser::verifyArgs(const ArgumentVector &args)
|
||||
void ArgumentParser::verifyArgs(const ArgumentVector &args)
|
||||
{
|
||||
vector<const Argument *> verifiedArgs;
|
||||
verifiedArgs.reserve(args.size());
|
||||
|
@ -1745,4 +1743,4 @@ void ArgumentOccurrence::throwNumberOfValuesNotSufficient(unsigned long valuesTo
|
|||
" have been specified."));
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define APPLICATION_UTILITIES_ARGUMENTPARSER_H
|
||||
|
||||
#include "../conversion/stringconversion.h"
|
||||
#include "../global.h"
|
||||
#include "../misc/traits.h"
|
||||
|
||||
#include <functional>
|
||||
|
@ -13,9 +12,9 @@
|
|||
#include <cassert>
|
||||
#endif
|
||||
|
||||
class ArgumentParserTests;
|
||||
class ArgumentParserTests; // not a public class (only used for internal tests)
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Stores information about an application.
|
||||
|
@ -42,7 +41,7 @@ CPP_UTILITIES_EXPORT extern ApplicationInfo applicationInfo;
|
|||
* used by ArgumentParser::printHelp().
|
||||
* \remarks Reads those data from the config header so "config.h" must be included.
|
||||
*/
|
||||
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::applicationInfo.dependencyVersions = DEPENCENCY_VERSIONS
|
||||
#define SET_DEPENDENCY_INFO ::CppUtilities::applicationInfo.dependencyVersions = DEPENCENCY_VERSIONS
|
||||
|
||||
/*!
|
||||
* \def SET_APPLICATION_INFO
|
||||
|
@ -50,13 +49,13 @@ CPP_UTILITIES_EXPORT extern ApplicationInfo applicationInfo;
|
|||
* \remarks Reads those data from the config header so "config.h" must be included.
|
||||
*/
|
||||
#define SET_APPLICATION_INFO \
|
||||
::ApplicationUtilities::applicationInfo.name = APP_NAME; \
|
||||
::ApplicationUtilities::applicationInfo.author = APP_AUTHOR; \
|
||||
::ApplicationUtilities::applicationInfo.version = APP_VERSION; \
|
||||
::ApplicationUtilities::applicationInfo.url = APP_URL; \
|
||||
::ApplicationUtilities::applicationInfo.description = APP_DESCRIPTION; \
|
||||
::ApplicationUtilities::applicationInfo.license = PROJECT_LICENSE; \
|
||||
::ApplicationUtilities::applicationInfo.credits = APP_CREDITS; \
|
||||
::CppUtilities::applicationInfo.name = APP_NAME; \
|
||||
::CppUtilities::applicationInfo.author = APP_AUTHOR; \
|
||||
::CppUtilities::applicationInfo.version = APP_VERSION; \
|
||||
::CppUtilities::applicationInfo.url = APP_URL; \
|
||||
::CppUtilities::applicationInfo.description = APP_DESCRIPTION; \
|
||||
::CppUtilities::applicationInfo.license = PROJECT_LICENSE; \
|
||||
::CppUtilities::applicationInfo.credits = APP_CREDITS; \
|
||||
SET_DEPENDENCY_INFO
|
||||
|
||||
class Argument;
|
||||
|
@ -149,7 +148,7 @@ template <typename TargetType, Traits::EnableIf<std::is_same<TargetType, std::st
|
|||
|
||||
template <typename TargetType, Traits::EnableIf<std::is_arithmetic<TargetType>> * = nullptr> TargetType convert(const char *value)
|
||||
{
|
||||
return ConversionUtilities::stringToNumber<TargetType>(value);
|
||||
return stringToNumber<TargetType>(value);
|
||||
}
|
||||
|
||||
/// \cond
|
||||
|
@ -176,7 +175,7 @@ template <typename FirstTargetType, typename... RemainingTargetTypes> struct Arg
|
|||
// FIXME: maybe use std::expected here when available
|
||||
try {
|
||||
return std::make_tuple<FirstTargetType>(ValueConversion::convert<FirstTargetType>(*firstValue));
|
||||
} catch (const ConversionUtilities::ConversionException &exception) {
|
||||
} catch (const ConversionException &exception) {
|
||||
throw ArgumentValueConversionError{ exception.what(), *firstValue, typeid(FirstTargetType).name() };
|
||||
}
|
||||
}
|
||||
|
@ -1203,6 +1202,6 @@ inline NoColorArgument &ArgumentParser::noColorArg()
|
|||
return m_noColorArg;
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // APPLICATION_UTILITIES_ARGUMENTPARSER_H
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
#include "./argumentparser.h"
|
||||
#include "./commandlineutils.h"
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT ArgumentReader {
|
||||
public:
|
||||
ArgumentReader(ArgumentParser &parser, const char *const *argv, const char *const *end, bool completionMode = false);
|
||||
ApplicationUtilities::ArgumentReader &reset(const char *const *argv, const char *const *end);
|
||||
ArgumentReader &reset(const char *const *argv, const char *const *end);
|
||||
bool read();
|
||||
bool read(ArgumentVector &args);
|
||||
|
||||
|
@ -56,6 +56,6 @@ inline Wrapper::Wrapper(const char *str, Indentation currentIndentation)
|
|||
{
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // APPLICATION_UTILITIES_ARGUMENTPARSER_PRIVATE_H
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Prompts for confirmation displaying the specified \a message.
|
||||
|
@ -158,4 +158,4 @@ pair<vector<unique_ptr<char[]>>, vector<char *>> convertArgsToUtf8()
|
|||
}
|
||||
#endif
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief The Response enum is used to specify the default response for the confirmPrompt() method.
|
||||
|
@ -88,6 +88,6 @@ inline CPP_UTILITIES_EXPORT std::ostream &operator<<(std::ostream &out, Indentat
|
|||
return out;
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // APPLICATIONUTILITIES_COMMANDLINEUTILS_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "./fakeqtconfigarguments.h"
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class FakeQtConfigArguments
|
||||
|
@ -20,4 +20,4 @@ FakeQtConfigArguments::FakeQtConfigArguments()
|
|||
{
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "./argumentparser.h"
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT FakeQtConfigArguments {
|
||||
public:
|
||||
|
@ -43,10 +43,10 @@ inline bool FakeQtConfigArguments::areQtGuiArgsPresent() const
|
|||
return m_qtWidgetsGuiArg.isPresent() || m_qtQuickGuiArg.isPresent();
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#ifndef QT_CONFIG_ARGUMENTS
|
||||
#define QT_CONFIG_ARGUMENTS ApplicationUtilities::FakeQtConfigArguments
|
||||
#define QT_CONFIG_ARGUMENTS CppUtilities::FakeQtConfigArguments
|
||||
#endif
|
||||
|
||||
#endif // APPLICATIONUTILITIES_FAKEQTCONFIGARGUMENTS_H
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <stdexcept>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
const int DateTime::m_daysPerYear = 365;
|
||||
const int DateTime::m_daysPer4Years = 1461;
|
||||
|
@ -34,7 +34,7 @@ template <typename num1, typename num2, typename num3> constexpr bool inRangeExc
|
|||
}
|
||||
|
||||
/*!
|
||||
* \class ChronoUtilities::DateTime
|
||||
* \class DateTime
|
||||
* \brief Represents an instant in time, typically expressed as a date and time of day.
|
||||
* \remarks
|
||||
* - Time values are measured in 100-nanosecond units called ticks,
|
||||
|
@ -407,3 +407,5 @@ int DateTime::getDatePart(DatePart part) const
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Specifies the output format.
|
||||
|
@ -513,11 +513,11 @@ inline DateTime &DateTime::operator-=(const TimeSpan &timeSpan)
|
|||
m_ticks -= timeSpan.m_ticks;
|
||||
return *this;
|
||||
}
|
||||
} // namespace ChronoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
namespace std {
|
||||
template <> struct hash<ChronoUtilities::DateTime> {
|
||||
inline size_t operator()(const ChronoUtilities::DateTime &dateTime) const
|
||||
template <> struct hash<CppUtilities::DateTime> {
|
||||
inline size_t operator()(const CppUtilities::DateTime &dateTime) const
|
||||
{
|
||||
return hash<decltype(dateTime.totalTicks())>()(dateTime.totalTicks());
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
|
||||
#include <ostream>
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &out, const ChronoUtilities::DateTime &value)
|
||||
inline std::ostream &operator<<(std::ostream &out, const CppUtilities::DateTime &value)
|
||||
{
|
||||
return out << value.toString(ChronoUtilities::DateTimeOutputFormat::DateAndTime, false);
|
||||
return out << value.toString(CppUtilities::DateTimeOutputFormat::DateAndTime, false);
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &out, const ChronoUtilities::TimeSpan &value)
|
||||
inline std::ostream &operator<<(std::ostream &out, const CppUtilities::TimeSpan &value)
|
||||
{
|
||||
return out << value.toString(ChronoUtilities::TimeSpanOutputFormat::Normal, false);
|
||||
return out << value.toString(CppUtilities::TimeSpanOutputFormat::Normal, false);
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &out, const ChronoUtilities::Period &value)
|
||||
inline std::ostream &operator<<(std::ostream &out, const CppUtilities::Period &value)
|
||||
{
|
||||
return out << value.years() << " years, " << value.months() << " months, " << value.days() << " days";
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "./period.h"
|
||||
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class ChronoUtilities::Period
|
||||
* \class Period
|
||||
* \brief Represents a period of time.
|
||||
*
|
||||
* In contrast to the TimeSpan class, a Period represents a duration between a concrete
|
||||
|
@ -78,4 +78,4 @@ DateTime operator+(DateTime begin, Period period)
|
|||
return DateTime::fromDate(year, month, day) + begin.timeOfDay();
|
||||
}
|
||||
|
||||
} // namespace ChronoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "./datetime.h"
|
||||
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT Period {
|
||||
public:
|
||||
|
@ -52,6 +52,6 @@ constexpr int Period::days() const
|
|||
|
||||
DateTime CPP_UTILITIES_EXPORT operator+(DateTime begin, Period period);
|
||||
|
||||
} // namespace ChronoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CHRONO_UTILITIES_PERIOD_H
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class ChronoUtilities::TimeSpan
|
||||
* \class TimeSpan
|
||||
* \brief Represents a time interval.
|
||||
*
|
||||
* Note that the TimeSpan class is meant to express a time interval independently of the
|
||||
|
@ -181,3 +181,5 @@ void TimeSpan::toString(string &result, TimeSpanOutputFormat format, bool fullSe
|
|||
}
|
||||
result = s.str();
|
||||
}
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -8,10 +8,7 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
/*!
|
||||
* \brief Contains classes providing a means for handling date and time information.
|
||||
*/
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class DateTime;
|
||||
|
||||
|
@ -409,11 +406,11 @@ constexpr inline bool TimeSpan::isInfinity() const
|
|||
{
|
||||
return m_ticks == std::numeric_limits<decltype(m_ticks)>::max();
|
||||
}
|
||||
} // namespace ChronoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
namespace std {
|
||||
template <> struct hash<ChronoUtilities::TimeSpan> {
|
||||
inline size_t operator()(const ChronoUtilities::TimeSpan &timeSpan) const
|
||||
template <> struct hash<CppUtilities::TimeSpan> {
|
||||
inline size_t operator()(const CppUtilities::TimeSpan &timeSpan) const
|
||||
{
|
||||
return hash<decltype(timeSpan.totalTicks())>()(timeSpan.totalTicks());
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
#error "Middle endian byte order is not supported!"
|
||||
#endif
|
||||
|
||||
namespace ConversionUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Encapsulates binary conversion functions using the big endian byte order.
|
||||
|
@ -173,6 +173,6 @@ CPP_UTILITIES_EXPORT constexpr std::uint64_t swapOrder(std::uint64_t value)
|
|||
| ((value & 0x000000FF00000000) >> (1 * 8)) | ((value & 0x00000000FF000000) << (1 * 8)) | ((value & 0x0000000000FF0000) << (3 * 8))
|
||||
| ((value & 0x000000000000FF00) << (5 * 8)) | ((value) << (7 * 8));
|
||||
}
|
||||
} // namespace ConversionUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CONVERSION_UTILITIES_BINARY_CONVERSION_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "./conversionexception.h"
|
||||
|
||||
namespace ConversionUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Destroys the ConversionException.
|
||||
|
@ -9,4 +9,4 @@ ConversionException::~ConversionException()
|
|||
{
|
||||
}
|
||||
|
||||
} // namespace ConversionUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ConversionUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT ConversionException : public std::runtime_error {
|
||||
public:
|
||||
|
@ -48,6 +48,6 @@ inline ConversionException::ConversionException(const char *what) noexcept
|
|||
{
|
||||
}
|
||||
|
||||
} // namespace ConversionUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CONVERSION_UTILITIES_CONVERSIONEXCEPTION_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
namespace ConversionUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/// \cond
|
||||
namespace Helper {
|
||||
|
@ -259,6 +259,6 @@ inline std::string operator+(const Tuple &lhs, IntegralType rhs)
|
|||
{
|
||||
return tupleToString(std::tuple_cat(lhs, std::make_tuple(rhs)));
|
||||
}
|
||||
} // namespace ConversionUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CONVERSION_UTILITIES_STRINGBUILDER_H
|
||||
|
|
|
@ -22,14 +22,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
/*!
|
||||
* \namespace ConversionUtilities
|
||||
* \brief Contains several functions providing conversions between different data types.
|
||||
*
|
||||
* binaryconversion.h declares functions which convert base data types to an array of bytes and vice versa.
|
||||
* stringconversion.h declares different functions around string conversion such as converting a number to a string and vice versa.
|
||||
*/
|
||||
namespace ConversionUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/// \cond
|
||||
|
||||
|
@ -414,4 +407,4 @@ pair<unique_ptr<std::uint8_t[]>, std::uint32_t> decodeBase64(const char *encoded
|
|||
}
|
||||
return make_pair(move(buffer), decodedSize);
|
||||
}
|
||||
} // namespace ConversionUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ConversionUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief The StringDataDeleter struct deletes the data of a StringData instance.
|
||||
|
@ -298,7 +298,7 @@ template <typename CharType> constexpr CharType digitToChar(CharType digit)
|
|||
* \sa stringToNumber()
|
||||
*/
|
||||
template <typename IntegralType, class StringType = std::string,
|
||||
Traits::EnableIf<std::is_integral<IntegralType>, std::is_unsigned<IntegralType>> * = nullptr>
|
||||
CppUtilities::Traits::EnableIf<std::is_integral<IntegralType>, std::is_unsigned<IntegralType>> * = nullptr>
|
||||
StringType numberToString(IntegralType number, typename StringType::value_type base = 10)
|
||||
{
|
||||
std::size_t resSize = 0;
|
||||
|
@ -617,7 +617,7 @@ IntegralType bufferToNumber(const CharType *string, std::size_t size, unsigned c
|
|||
template <typename T> std::string interpretIntegerAsString(T integer, int startOffset = 0)
|
||||
{
|
||||
char buffer[sizeof(T)];
|
||||
ConversionUtilities::BE::getBytes(integer, buffer);
|
||||
BE::getBytes(integer, buffer);
|
||||
return std::string(buffer + startOffset, sizeof(T) - startOffset);
|
||||
}
|
||||
|
||||
|
@ -625,6 +625,6 @@ CPP_UTILITIES_EXPORT std::string dataSizeToString(std::uint64_t sizeInByte, bool
|
|||
CPP_UTILITIES_EXPORT std::string bitrateToString(double speedInKbitsPerSecond, bool useByteInsteadOfBits = false);
|
||||
CPP_UTILITIES_EXPORT std::string encodeBase64(const std::uint8_t *data, std::uint32_t dataSize);
|
||||
CPP_UTILITIES_EXPORT std::pair<std::unique_ptr<std::uint8_t[]>, std::uint32_t> decodeBase64(const char *encodedStr, const std::uint32_t strSize);
|
||||
} // namespace ConversionUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CONVERSION_UTILITIES_STRINGCONVERSION_H
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "./ansiescapecodes.h"
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Encapsulates functions for formatted terminal output using ANSI escape codes.
|
||||
*/
|
||||
|
@ -107,3 +109,5 @@ std::ostream &operator<<(std::ostream &stream, Phrases phrase)
|
|||
}
|
||||
|
||||
} // namespace EscapeCodes
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <ostream>
|
||||
#include <tuple>
|
||||
|
||||
namespace CppUtilities {
|
||||
namespace EscapeCodes {
|
||||
|
||||
extern CPP_UTILITIES_EXPORT bool enabled;
|
||||
|
@ -150,5 +151,6 @@ enum class Phrases {
|
|||
CPP_UTILITIES_EXPORT std::ostream &operator<<(std::ostream &stream, Phrases phrase);
|
||||
|
||||
} // namespace EscapeCodes
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_ANSIESCAPECODES
|
||||
|
|
|
@ -7,16 +7,11 @@
|
|||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace IoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \namespace IoUtilities
|
||||
* \brief Contains utility classes helping to read and write streams.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \class IoUtilities::BinaryReader
|
||||
* \class BinaryReader
|
||||
* \brief Reads primitive data types from a std::istream.
|
||||
* \remarks Supports both, little endian and big endian.
|
||||
* \sa For automatic serialization of structs, see https://github.com/Martchus/reflective-rapidjson.
|
||||
|
@ -192,3 +187,5 @@ const std::uint32_t BinaryReader::crc32Table[] = { 0x00000000, 0x04c11db7, 0x098
|
|||
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
|
||||
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
||||
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 };
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
class CPP_UTILITIES_EXPORT BinaryReader {
|
||||
|
||||
public:
|
||||
|
@ -242,7 +242,7 @@ inline void BinaryReader::read(std::vector<char> &buffer, std::streamsize length
|
|||
inline std::int16_t BinaryReader::readInt16BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::int16_t));
|
||||
return ConversionUtilities::BE::toInt16(m_buffer);
|
||||
return BE::toInt16(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -251,7 +251,7 @@ inline std::int16_t BinaryReader::readInt16BE()
|
|||
inline std::uint16_t BinaryReader::readUInt16BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::uint16_t));
|
||||
return ConversionUtilities::BE::toUInt16(m_buffer);
|
||||
return BE::toUInt16(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -261,7 +261,7 @@ inline std::int32_t BinaryReader::readInt24BE()
|
|||
{
|
||||
*m_buffer = 0;
|
||||
m_stream->read(m_buffer + 1, 3);
|
||||
auto val = ConversionUtilities::BE::toInt32(m_buffer);
|
||||
auto val = BE::toInt32(m_buffer);
|
||||
if (val >= 0x800000) {
|
||||
val = -(0x1000000 - val);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ inline std::uint32_t BinaryReader::readUInt24BE()
|
|||
{
|
||||
*m_buffer = 0;
|
||||
m_stream->read(m_buffer + 1, 3);
|
||||
return ConversionUtilities::BE::toUInt32(m_buffer);
|
||||
return BE::toUInt32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -284,7 +284,7 @@ inline std::uint32_t BinaryReader::readUInt24BE()
|
|||
inline std::int32_t BinaryReader::readInt32BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::int32_t));
|
||||
return ConversionUtilities::BE::toInt32(m_buffer);
|
||||
return BE::toInt32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -293,7 +293,7 @@ inline std::int32_t BinaryReader::readInt32BE()
|
|||
inline std::uint32_t BinaryReader::readUInt32BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::uint32_t));
|
||||
return ConversionUtilities::BE::toUInt32(m_buffer);
|
||||
return BE::toUInt32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -303,7 +303,7 @@ inline std::int64_t BinaryReader::readInt40BE()
|
|||
{
|
||||
*m_buffer = *(m_buffer + 1) = *(m_buffer + 2) = 0;
|
||||
m_stream->read(m_buffer + 3, 5);
|
||||
auto val = ConversionUtilities::BE::toInt64(m_buffer);
|
||||
auto val = BE::toInt64(m_buffer);
|
||||
if (val >= 0x8000000000) {
|
||||
val = -(0x10000000000 - val);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ inline std::uint64_t BinaryReader::readUInt40BE()
|
|||
{
|
||||
*m_buffer = *(m_buffer + 1) = *(m_buffer + 2) = 0;
|
||||
m_stream->read(m_buffer + 3, 5);
|
||||
return ConversionUtilities::BE::toUInt64(m_buffer);
|
||||
return BE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -327,7 +327,7 @@ inline std::int64_t BinaryReader::readInt56BE()
|
|||
{
|
||||
*m_buffer = 0;
|
||||
m_stream->read(m_buffer + 1, 7);
|
||||
auto val = ConversionUtilities::BE::toInt64(m_buffer);
|
||||
auto val = BE::toInt64(m_buffer);
|
||||
if (val >= 0x80000000000000) {
|
||||
val = -(0x100000000000000 - val);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ inline std::uint64_t BinaryReader::readUInt56BE()
|
|||
{
|
||||
*m_buffer = 0;
|
||||
m_stream->read(m_buffer + 1, 7);
|
||||
return ConversionUtilities::BE::toUInt64(m_buffer);
|
||||
return BE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -350,7 +350,7 @@ inline std::uint64_t BinaryReader::readUInt56BE()
|
|||
inline std::int64_t BinaryReader::readInt64BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::int64_t));
|
||||
return ConversionUtilities::BE::toInt64(m_buffer);
|
||||
return BE::toInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -359,7 +359,7 @@ inline std::int64_t BinaryReader::readInt64BE()
|
|||
inline std::uint64_t BinaryReader::readUInt64BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::uint64_t));
|
||||
return ConversionUtilities::BE::toUInt64(m_buffer);
|
||||
return BE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -369,7 +369,7 @@ inline std::uint64_t BinaryReader::readUInt64BE()
|
|||
inline std::uint64_t BinaryReader::readVariableLengthUIntBE()
|
||||
{
|
||||
bufferVariableLengthInteger();
|
||||
return ConversionUtilities::BE::toUInt64(m_buffer);
|
||||
return BE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -378,7 +378,7 @@ inline std::uint64_t BinaryReader::readVariableLengthUIntBE()
|
|||
inline float BinaryReader::readFloat32BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(float));
|
||||
return ConversionUtilities::BE::toFloat32(m_buffer);
|
||||
return BE::toFloat32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -387,7 +387,7 @@ inline float BinaryReader::readFloat32BE()
|
|||
inline double BinaryReader::readFloat64BE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(double));
|
||||
return ConversionUtilities::BE::toFloat64(m_buffer);
|
||||
return BE::toFloat64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -396,7 +396,7 @@ inline double BinaryReader::readFloat64BE()
|
|||
inline std::int16_t BinaryReader::readInt16LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::int16_t));
|
||||
return ConversionUtilities::LE::toInt16(m_buffer);
|
||||
return LE::toInt16(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -405,7 +405,7 @@ inline std::int16_t BinaryReader::readInt16LE()
|
|||
inline std::uint16_t BinaryReader::readUInt16LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::uint16_t));
|
||||
return ConversionUtilities::LE::toUInt16(m_buffer);
|
||||
return LE::toUInt16(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -415,7 +415,7 @@ inline std::int32_t BinaryReader::readInt24LE()
|
|||
{
|
||||
*(m_buffer + 3) = 0;
|
||||
m_stream->read(m_buffer, 3);
|
||||
auto val = ConversionUtilities::LE::toInt32(m_buffer);
|
||||
auto val = LE::toInt32(m_buffer);
|
||||
if (val >= 0x800000) {
|
||||
val = -(0x1000000 - val);
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ inline std::uint32_t BinaryReader::readUInt24LE()
|
|||
{
|
||||
*(m_buffer + 3) = 0;
|
||||
m_stream->read(m_buffer, 3);
|
||||
return ConversionUtilities::LE::toUInt32(m_buffer);
|
||||
return LE::toUInt32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -438,7 +438,7 @@ inline std::uint32_t BinaryReader::readUInt24LE()
|
|||
inline std::int32_t BinaryReader::readInt32LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::int32_t));
|
||||
return ConversionUtilities::LE::toInt32(m_buffer);
|
||||
return LE::toInt32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -447,7 +447,7 @@ inline std::int32_t BinaryReader::readInt32LE()
|
|||
inline std::uint32_t BinaryReader::readUInt32LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::uint32_t));
|
||||
return ConversionUtilities::LE::toUInt32(m_buffer);
|
||||
return LE::toUInt32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -457,7 +457,7 @@ inline std::int64_t BinaryReader::readInt40LE()
|
|||
{
|
||||
*(m_buffer + 5) = *(m_buffer + 6) = *(m_buffer + 7) = 0;
|
||||
m_stream->read(m_buffer, 5);
|
||||
auto val = ConversionUtilities::LE::toInt64(m_buffer);
|
||||
auto val = LE::toInt64(m_buffer);
|
||||
if (val >= 0x8000000000) {
|
||||
val = -(0x10000000000 - val);
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ inline std::uint64_t BinaryReader::readUInt40LE()
|
|||
{
|
||||
*(m_buffer + 5) = *(m_buffer + 6) = *(m_buffer + 7) = 0;
|
||||
m_stream->read(m_buffer, 5);
|
||||
return ConversionUtilities::LE::toUInt64(m_buffer);
|
||||
return LE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -481,7 +481,7 @@ inline std::int64_t BinaryReader::readInt56LE()
|
|||
{
|
||||
*(m_buffer + 7) = 0;
|
||||
m_stream->read(m_buffer, 7);
|
||||
auto val = ConversionUtilities::LE::toInt64(m_buffer);
|
||||
auto val = LE::toInt64(m_buffer);
|
||||
if (val >= 0x80000000000000) {
|
||||
val = -(0x100000000000000 - val);
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ inline std::uint64_t BinaryReader::readUInt56LE()
|
|||
{
|
||||
*(m_buffer + 7) = 0;
|
||||
m_stream->read(m_buffer, 7);
|
||||
return ConversionUtilities::LE::toUInt64(m_buffer);
|
||||
return LE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -504,7 +504,7 @@ inline std::uint64_t BinaryReader::readUInt56LE()
|
|||
inline std::int64_t BinaryReader::readInt64LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::int64_t));
|
||||
return ConversionUtilities::LE::toInt64(m_buffer);
|
||||
return LE::toInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -513,7 +513,7 @@ inline std::int64_t BinaryReader::readInt64LE()
|
|||
inline std::uint64_t BinaryReader::readUInt64LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(std::uint64_t));
|
||||
return ConversionUtilities::LE::toUInt64(m_buffer);
|
||||
return LE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -523,7 +523,7 @@ inline std::uint64_t BinaryReader::readUInt64LE()
|
|||
inline std::uint64_t BinaryReader::readVariableLengthUIntLE()
|
||||
{
|
||||
bufferVariableLengthInteger();
|
||||
return ConversionUtilities::LE::toUInt64(m_buffer);
|
||||
return LE::toUInt64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -532,7 +532,7 @@ inline std::uint64_t BinaryReader::readVariableLengthUIntLE()
|
|||
inline float BinaryReader::readFloat32LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(float));
|
||||
return ConversionUtilities::LE::toFloat32(m_buffer);
|
||||
return LE::toFloat32(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -541,7 +541,7 @@ inline float BinaryReader::readFloat32LE()
|
|||
inline double BinaryReader::readFloat64LE()
|
||||
{
|
||||
m_stream->read(m_buffer, sizeof(double));
|
||||
return ConversionUtilities::LE::toFloat64(m_buffer);
|
||||
return LE::toFloat64(m_buffer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -588,7 +588,7 @@ inline std::string BinaryReader::readLengthPrefixedString()
|
|||
*/
|
||||
inline std::uint32_t BinaryReader::readSynchsafeUInt32BE()
|
||||
{
|
||||
return ConversionUtilities::toNormalInt(readUInt32BE());
|
||||
return toNormalInt(readUInt32BE());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -596,7 +596,7 @@ inline std::uint32_t BinaryReader::readSynchsafeUInt32BE()
|
|||
*/
|
||||
inline float BinaryReader::readFixed8BE()
|
||||
{
|
||||
return ConversionUtilities::toFloat32(readUInt16BE());
|
||||
return toFloat32(readUInt16BE());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -604,7 +604,7 @@ inline float BinaryReader::readFixed8BE()
|
|||
*/
|
||||
inline float BinaryReader::readFixed16BE()
|
||||
{
|
||||
return ConversionUtilities::toFloat32(readUInt32BE());
|
||||
return toFloat32(readUInt32BE());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -614,7 +614,7 @@ inline float BinaryReader::readFixed16BE()
|
|||
*/
|
||||
inline std::uint32_t BinaryReader::readSynchsafeUInt32LE()
|
||||
{
|
||||
return ConversionUtilities::toNormalInt(readUInt32LE());
|
||||
return toNormalInt(readUInt32LE());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -622,7 +622,7 @@ inline std::uint32_t BinaryReader::readSynchsafeUInt32LE()
|
|||
*/
|
||||
inline float BinaryReader::readFixed8LE()
|
||||
{
|
||||
return ConversionUtilities::toFloat32(readUInt16LE());
|
||||
return toFloat32(readUInt16LE());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -630,7 +630,7 @@ inline float BinaryReader::readFixed8LE()
|
|||
*/
|
||||
inline float BinaryReader::readFixed16LE()
|
||||
{
|
||||
return ConversionUtilities::toFloat32(readUInt32LE());
|
||||
return toFloat32(readUInt32LE());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -732,6 +732,6 @@ inline void BinaryReader::read(double &one64BitFloat)
|
|||
{
|
||||
one64BitFloat = readFloat64BE();
|
||||
}
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_BINERYREADER_H
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace IoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class IoUtilities::BinaryWriter
|
||||
* \class BinaryWriter
|
||||
* \brief Writes primitive data types to a std::ostream.
|
||||
* \remarks Supports both, little endian and big endian.
|
||||
* \sa For automatic deserialization of structs, see https://github.com/Martchus/reflective-rapidjson.
|
||||
|
@ -59,3 +59,5 @@ void BinaryWriter::writeVariableLengthInteger(std::uint64_t value, void (*getByt
|
|||
}
|
||||
m_stream->write(m_buffer + 8 - prefixLength, prefixLength);
|
||||
}
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT BinaryWriter {
|
||||
public:
|
||||
|
@ -248,7 +248,7 @@ inline void BinaryWriter::writeBool(bool value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt16BE(std::int16_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::int16_t));
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ inline void BinaryWriter::writeInt16BE(std::int16_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt16BE(std::uint16_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::uint16_t));
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ inline void BinaryWriter::writeUInt16BE(std::uint16_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt24BE(std::int32_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer + 1, 3);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ inline void BinaryWriter::writeInt24BE(std::int32_t value)
|
|||
inline void BinaryWriter::writeUInt24BE(std::uint32_t value)
|
||||
{
|
||||
// discard most significant byte
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer + 1, 3);
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ inline void BinaryWriter::writeUInt24BE(std::uint32_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt32BE(std::int32_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::int32_t));
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ inline void BinaryWriter::writeInt32BE(std::int32_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt32BE(std::uint32_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::uint32_t));
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ inline void BinaryWriter::writeUInt32BE(std::uint32_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt40BE(std::int64_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer + 3, 5);
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ inline void BinaryWriter::writeInt40BE(std::int64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt40BE(std::uint64_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer + 3, 5);
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ inline void BinaryWriter::writeUInt40BE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt56BE(std::int64_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer + 1, 7);
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ inline void BinaryWriter::writeInt56BE(std::int64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt56BE(std::uint64_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer + 1, 7);
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ inline void BinaryWriter::writeUInt56BE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt64BE(std::int64_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::int64_t));
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ inline void BinaryWriter::writeInt64BE(std::int64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt64BE(std::uint64_t value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::uint64_t));
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ inline void BinaryWriter::writeUInt64BE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeVariableLengthUIntBE(std::uint64_t value)
|
||||
{
|
||||
writeVariableLengthInteger(value, static_cast<void (*)(std::uint64_t, char *)>(&ConversionUtilities::BE::getBytes));
|
||||
writeVariableLengthInteger(value, static_cast<void (*)(std::uint64_t, char *)>(&BE::getBytes));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -372,7 +372,7 @@ inline void BinaryWriter::writeVariableLengthUIntBE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeFloat32BE(float value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(float));
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ inline void BinaryWriter::writeFloat32BE(float value)
|
|||
*/
|
||||
inline void BinaryWriter::writeFloat64BE(double value)
|
||||
{
|
||||
ConversionUtilities::BE::getBytes(value, m_buffer);
|
||||
BE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(double));
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ inline void BinaryWriter::writeFloat64BE(double value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt16LE(std::int16_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::int16_t));
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ inline void BinaryWriter::writeInt16LE(std::int16_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt16LE(std::uint16_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::uint16_t));
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ inline void BinaryWriter::writeUInt16LE(std::uint16_t value)
|
|||
inline void BinaryWriter::writeInt24LE(std::int32_t value)
|
||||
{
|
||||
// discard most significant byte
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, 3);
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ inline void BinaryWriter::writeInt24LE(std::int32_t value)
|
|||
inline void BinaryWriter::writeUInt24LE(std::uint32_t value)
|
||||
{
|
||||
// discard most significant byte
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, 3);
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,7 @@ inline void BinaryWriter::writeUInt24LE(std::uint32_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt32LE(std::int32_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::int32_t));
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ inline void BinaryWriter::writeInt32LE(std::int32_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt32LE(std::uint32_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::uint32_t));
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ inline void BinaryWriter::writeUInt32LE(std::uint32_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt40LE(std::int64_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, 5);
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ inline void BinaryWriter::writeInt40LE(std::int64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt40LE(std::uint64_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, 5);
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ inline void BinaryWriter::writeUInt40LE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt56LE(std::int64_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, 7);
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ inline void BinaryWriter::writeInt56LE(std::int64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt56LE(std::uint64_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, 7);
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ inline void BinaryWriter::writeUInt56LE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeInt64LE(std::int64_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::int64_t));
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ inline void BinaryWriter::writeInt64LE(std::int64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeUInt64LE(std::uint64_t value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(std::uint64_t));
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ inline void BinaryWriter::writeUInt64LE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeVariableLengthUIntLE(std::uint64_t value)
|
||||
{
|
||||
writeVariableLengthInteger(value, static_cast<void (*)(std::uint64_t, char *)>(&ConversionUtilities::LE::getBytes));
|
||||
writeVariableLengthInteger(value, static_cast<void (*)(std::uint64_t, char *)>(&LE::getBytes));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -515,7 +515,7 @@ inline void BinaryWriter::writeVariableLengthUIntLE(std::uint64_t value)
|
|||
*/
|
||||
inline void BinaryWriter::writeFloat32LE(float value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(float));
|
||||
}
|
||||
|
||||
|
@ -524,7 +524,7 @@ inline void BinaryWriter::writeFloat32LE(float value)
|
|||
*/
|
||||
inline void BinaryWriter::writeFloat64LE(double value)
|
||||
{
|
||||
ConversionUtilities::LE::getBytes(value, m_buffer);
|
||||
LE::getBytes(value, m_buffer);
|
||||
m_stream->write(m_buffer, sizeof(double));
|
||||
}
|
||||
|
||||
|
@ -577,7 +577,7 @@ inline void BinaryWriter::writeLengthPrefixedCString(const char *value, std::siz
|
|||
*/
|
||||
inline void BinaryWriter::writeSynchsafeUInt32BE(std::uint32_t valueToConvertAndWrite)
|
||||
{
|
||||
writeUInt32BE(ConversionUtilities::toSynchsafeInt(valueToConvertAndWrite));
|
||||
writeUInt32BE(toSynchsafeInt(valueToConvertAndWrite));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -585,7 +585,7 @@ inline void BinaryWriter::writeSynchsafeUInt32BE(std::uint32_t valueToConvertAnd
|
|||
*/
|
||||
inline void BinaryWriter::writeFixed8BE(float valueToConvertAndWrite)
|
||||
{
|
||||
writeUInt16BE(ConversionUtilities::toFixed8(valueToConvertAndWrite));
|
||||
writeUInt16BE(toFixed8(valueToConvertAndWrite));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -593,7 +593,7 @@ inline void BinaryWriter::writeFixed8BE(float valueToConvertAndWrite)
|
|||
*/
|
||||
inline void BinaryWriter::writeFixed16BE(float valueToConvertAndWrite)
|
||||
{
|
||||
writeUInt32BE(ConversionUtilities::toFixed16(valueToConvertAndWrite));
|
||||
writeUInt32BE(toFixed16(valueToConvertAndWrite));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -603,7 +603,7 @@ inline void BinaryWriter::writeFixed16BE(float valueToConvertAndWrite)
|
|||
*/
|
||||
inline void BinaryWriter::writeSynchsafeUInt32LE(std::uint32_t valueToConvertAndWrite)
|
||||
{
|
||||
writeUInt32LE(ConversionUtilities::toSynchsafeInt(valueToConvertAndWrite));
|
||||
writeUInt32LE(toSynchsafeInt(valueToConvertAndWrite));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -611,7 +611,7 @@ inline void BinaryWriter::writeSynchsafeUInt32LE(std::uint32_t valueToConvertAnd
|
|||
*/
|
||||
inline void BinaryWriter::writeFixed8LE(float valueToConvertAndWrite)
|
||||
{
|
||||
writeUInt16LE(ConversionUtilities::toFixed8(valueToConvertAndWrite));
|
||||
writeUInt16LE(toFixed8(valueToConvertAndWrite));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -619,7 +619,7 @@ inline void BinaryWriter::writeFixed8LE(float valueToConvertAndWrite)
|
|||
*/
|
||||
inline void BinaryWriter::writeFixed16LE(float valueToConvertAndWrite)
|
||||
{
|
||||
writeUInt32LE(ConversionUtilities::toFixed16(valueToConvertAndWrite));
|
||||
writeUInt32LE(toFixed16(valueToConvertAndWrite));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -729,6 +729,6 @@ inline void BinaryWriter::write(double one64BitFloat)
|
|||
{
|
||||
writeFloat64BE(one64BitFloat);
|
||||
}
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IO_UTILITIES_BINARYWRITER_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class IoUtilities::BitReader
|
||||
|
@ -27,4 +27,4 @@ void BitReader::skipBits(std::size_t bitCount)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <iostream>
|
||||
#include <type_traits>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT BitReader {
|
||||
public:
|
||||
|
@ -172,6 +172,6 @@ inline void BitReader::align()
|
|||
skipBits(m_bitsAvail);
|
||||
}
|
||||
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_BITREADER_H
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class IoUtilities::CopyHelper
|
||||
|
@ -84,6 +84,6 @@ template <std::size_t bufferSize> char *CopyHelper<bufferSize>::buffer()
|
|||
{
|
||||
return m_buffer;
|
||||
}
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_COPY_H
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class IniFile
|
||||
|
@ -160,4 +160,4 @@ void IniFile::make(ostream &outputStream)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT IniFile {
|
||||
public:
|
||||
|
@ -49,6 +49,6 @@ inline const std::vector<std::pair<std::string, std::multimap<std::string, std::
|
|||
return m_data;
|
||||
}
|
||||
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_INIFILE_H
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Reads all contents of the specified file in a single call.
|
||||
|
@ -28,4 +28,4 @@ std::string readFile(const std::string &path, std::string::size_type maxSize)
|
|||
res.assign((istreambuf_iterator<char>(file)), istreambuf_iterator<char>());
|
||||
return res;
|
||||
}
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
CPP_UTILITIES_EXPORT std::string readFile(const std::string &path, std::string::size_type maxSize = std::string::npos);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
#ifdef CPP_UTILITIES_USE_NATIVE_FILE_BUFFER
|
||||
|
||||
|
@ -308,4 +308,4 @@ std::unique_ptr<wchar_t[]> NativeFileStream::makeWidePath(const std::string &pat
|
|||
// std::fstream is used
|
||||
|
||||
#endif
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#endif
|
||||
#include <fstream>
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
#ifdef CPP_UTILITIES_USE_NATIVE_FILE_BUFFER
|
||||
|
||||
|
@ -58,6 +58,6 @@ using NativeFileStream = std::fstream;
|
|||
|
||||
#endif
|
||||
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_NATIVE_FILE_STREAM
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Returns the file name and extension of the specified \a path string.
|
||||
|
@ -67,4 +67,4 @@ void removeInvalidChars(std::string &fileName)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#define SEARCH_PATH_SEP_STR ":"
|
||||
#endif
|
||||
|
||||
namespace IoUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
CPP_UTILITIES_EXPORT std::string fileName(const std::string &path);
|
||||
CPP_UTILITIES_EXPORT std::string directory(const std::string &path);
|
||||
CPP_UTILITIES_EXPORT void removeInvalidChars(std::string &fileName);
|
||||
} // namespace IoUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // IOUTILITIES_PATHHELPER_H
|
||||
|
|
|
@ -9,12 +9,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
/*!
|
||||
* \namespace MiscUtilities
|
||||
* \brief Contains various utilities such as computing Damerau–Levenshtein distance
|
||||
* and *N*-dimensional arrays.
|
||||
*/
|
||||
namespace MiscUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/// \cond
|
||||
|
||||
|
@ -63,7 +58,7 @@ size_t performDamerauLevenshteinAlgorithm(
|
|||
dist2 = index2;
|
||||
}
|
||||
// clang-format off
|
||||
distanceArray.at(index1 + 1, index2 + 1) = MathUtilities::min(
|
||||
distanceArray.at(index1 + 1, index2 + 1) = CppUtilities::min(
|
||||
distanceArray.at(index1, index2) + substitution, // substitution
|
||||
distanceArray.at(index1 + 1, index2) + 1, // insertion
|
||||
distanceArray.at(index1, index2 + 1) + 1, // deletion
|
||||
|
@ -130,4 +125,4 @@ std::size_t computeDamerauLevenshteinDistance(const char *const str1, const size
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace MiscUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
namespace MiscUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
CPP_UTILITIES_EXPORT std::size_t computeDamerauLevenshteinDistance(const char *str1, std::size_t size1, const char *str2, std::size_t size2);
|
||||
|
||||
|
@ -20,6 +20,6 @@ inline std::size_t computeDamerauLevenshteinDistance(const char *str1, const cha
|
|||
return computeDamerauLevenshteinDistance(str1, std::strlen(str1), str2, std::strlen(str2));
|
||||
}
|
||||
|
||||
} // namespace MiscUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CPP_UTILITIES_LEVENSHTEIN_H
|
||||
|
|
|
@ -1,13 +1 @@
|
|||
#include "./math.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
|
||||
/*!
|
||||
* \namespace MathUtilities
|
||||
* \brief Contains various mathematical functions.
|
||||
*/
|
||||
|
||||
namespace MathUtilities {
|
||||
|
||||
} // namespace MathUtilities
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
namespace MathUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Returns the digitsum of the given \a number using the specified \a base.
|
||||
|
@ -108,6 +108,6 @@ template <typename T1, typename... T2> constexpr T1 max(T1 first, T1 second, T2.
|
|||
return first > second ? max(first, remaining...) : max(second, remaining...);
|
||||
}
|
||||
|
||||
} // namespace MathUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // MATHUTILITIES_H
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
namespace MiscUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/// \cond
|
||||
namespace Detail {
|
||||
|
@ -184,6 +184,6 @@ template <typename ValueType, typename... DimensionSizes> inline auto makeNoneOw
|
|||
return MultiArray<ValueType, NoneOwningMultiArray, DimensionSizes...>(dimensionSizes...);
|
||||
}
|
||||
|
||||
} // namespace MiscUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CPP_UTILITIES_MULTI_ARRAY_H
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \class ApplicationUtilities::ParseError
|
||||
|
@ -31,4 +31,4 @@ std::ostream &operator<<(std::ostream &o, const ParseError &failure)
|
|||
<< endl;
|
||||
}
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <iosfwd>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
class CPP_UTILITIES_EXPORT ParseError : public std::runtime_error {
|
||||
public:
|
||||
|
@ -33,6 +33,6 @@ inline ParseError::ParseError(const std::string &what)
|
|||
|
||||
CPP_UTILITIES_EXPORT std::ostream &operator<<(std::ostream &o, const ParseError &failure);
|
||||
|
||||
} // namespace ApplicationUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // APPLICATION_UTILITIES_PARSE_ERROR_H
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
namespace CppUtilities {
|
||||
|
||||
/// \brief Contains traits for conveniently exploiting SFINAE.
|
||||
namespace Traits {
|
||||
|
||||
|
@ -120,8 +122,8 @@ template <typename T> struct IsComplete<T, decltype(void(sizeof(T)))> : Bool<tru
|
|||
*/
|
||||
#define CPP_UTILITIES_TRAITS_DEFINE_TYPE_CHECK(CheckName, CheckCode) \
|
||||
namespace Detail { \
|
||||
template <typename T> auto CheckName(int) -> decltype(CheckCode, ::Traits::Bool<true>{}); \
|
||||
template <typename T>::Traits::Bool<false> CheckName(...); \
|
||||
template <typename T> auto CheckName(int) -> decltype(CheckCode, ::CppUtilities::Traits::Bool<true>{}); \
|
||||
template <typename T>::CppUtilities::Traits::Bool<false> CheckName(...); \
|
||||
} \
|
||||
template <typename T> using CheckName = decltype(Detail::CheckName<T>(0))
|
||||
|
||||
|
@ -178,4 +180,6 @@ template <typename T, DisableIf<IsDereferencable<T>> * = nullptr> constexpr cons
|
|||
|
||||
} // namespace Traits
|
||||
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // CPP_UTILITIES_TRAITS_H
|
||||
|
|
|
@ -27,11 +27,8 @@
|
|||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace IoUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
@ -655,9 +652,9 @@ void ArgumentParserTests::testBashCompletion()
|
|||
}
|
||||
|
||||
// file names
|
||||
string iniFilePath = TestUtilities::testFilePath("test.ini");
|
||||
string iniFilePath = CppUtilities::testFilePath("test.ini");
|
||||
iniFilePath.resize(iniFilePath.size() - 4);
|
||||
string mkvFilePath = TestUtilities::testFilePath("test 'with quote'.mkv");
|
||||
string mkvFilePath = CppUtilities::testFilePath("test 'with quote'.mkv");
|
||||
mkvFilePath.resize(mkvFilePath.size() - 17);
|
||||
parser.resetArgs();
|
||||
const char *const argv5[] = { "get", "--files", iniFilePath.c_str() };
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "../conversion/stringconversion.h"
|
||||
#include "../tests/testutils.h"
|
||||
|
||||
using namespace TestUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
@ -14,7 +14,6 @@ using namespace TestUtilities;
|
|||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace TestUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
/*!
|
||||
|
|
|
@ -31,11 +31,8 @@
|
|||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace IoUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
/*!
|
||||
|
@ -91,7 +88,7 @@ void IoTests::testBinaryReader()
|
|||
// read test file
|
||||
fstream testFile;
|
||||
testFile.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
testFile.open(TestUtilities::testFilePath("some_data"), ios_base::in | ios_base::binary);
|
||||
testFile.open(testFilePath("some_data"), ios_base::in | ios_base::binary);
|
||||
BinaryReader reader(&testFile);
|
||||
CPPUNIT_ASSERT_EQUAL(reader.readStreamsize(), static_cast<istream::pos_type>(398));
|
||||
CPPUNIT_ASSERT(reader.readUInt16LE() == 0x0102u);
|
||||
|
@ -156,7 +153,7 @@ void IoTests::testBinaryWriter()
|
|||
// prepare reading expected data
|
||||
fstream testFile;
|
||||
testFile.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
testFile.open(TestUtilities::testFilePath("some_data"), ios_base::in | ios_base::binary);
|
||||
testFile.open(testFilePath("some_data"), ios_base::in | ios_base::binary);
|
||||
|
||||
// prepare output stream
|
||||
stringstream outputStream(ios_base::in | ios_base::out | ios_base::binary);
|
||||
|
@ -282,7 +279,7 @@ void IoTests::testIniFile()
|
|||
// prepare reading test file
|
||||
fstream inputFile;
|
||||
inputFile.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
inputFile.open(TestUtilities::testFilePath("test.ini"), ios_base::in);
|
||||
inputFile.open(testFilePath("test.ini"), ios_base::in);
|
||||
|
||||
IniFile ini;
|
||||
ini.parse(inputFile);
|
||||
|
@ -323,7 +320,7 @@ void IoTests::testCopy()
|
|||
// prepare streams
|
||||
fstream testFile;
|
||||
testFile.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
testFile.open(TestUtilities::testFilePath("some_data"), ios_base::in | ios_base::binary);
|
||||
testFile.open(testFilePath("some_data"), ios_base::in | ios_base::binary);
|
||||
stringstream outputStream(ios_base::in | ios_base::out | ios_base::binary);
|
||||
outputStream.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace MathUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
namespace MathUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
static_assert(min(1, 2, 3) == 1, "min");
|
||||
static_assert(min(3, 2, 1) == 1, "min");
|
||||
|
@ -21,7 +21,7 @@ static_assert(max(3, 2, 1) == 3, "max");
|
|||
static_assert(max(3, 4, 2, 1) == 4, "max");
|
||||
static_assert(max(3, -2, 4, 2, 1) == 4, "max");
|
||||
|
||||
} // namespace MathUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
/*!
|
||||
* \brief The MathTests class tests functions of the MathUtilities namespace.
|
||||
|
|
|
@ -14,12 +14,8 @@
|
|||
#include <regex>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace IoUtilities;
|
||||
using namespace MiscUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
/*!
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief The StandardOutputCheck class asserts whether the (standard) output written in the enclosing code block
|
||||
|
@ -83,11 +83,11 @@ inline OutputCheck::~OutputCheck() noexcept(false)
|
|||
return;
|
||||
}
|
||||
if (m_expectedOutput != actualOutput && m_alternativeOutput != actualOutput) {
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
CPPUNIT_FAIL("Output is not either \"" % m_expectedOutput % "\" or \"" % m_alternativeOutput % "\". Got instead:\n" + actualOutput);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // TESTUTILS_OUTPUTCHECK_H
|
||||
|
|
|
@ -28,15 +28,12 @@
|
|||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace EscapeCodes;
|
||||
using namespace IoUtilities;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
|
||||
/*!
|
||||
* \brief Contains classes and functions utilizing creating of test applications.
|
||||
*/
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
bool fileSystemItemExists(const string &path)
|
||||
{
|
||||
|
@ -569,4 +566,4 @@ string TestApplication::readTestfilePathFromSrcRef()
|
|||
}
|
||||
return string();
|
||||
}
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPath().
|
||||
|
@ -50,11 +50,11 @@ private:
|
|||
static std::string readTestfilePathFromEnv();
|
||||
static std::string readTestfilePathFromSrcRef();
|
||||
|
||||
ApplicationUtilities::ArgumentParser m_parser;
|
||||
ApplicationUtilities::Argument m_testFilesPathArg;
|
||||
ApplicationUtilities::Argument m_applicationPathArg;
|
||||
ApplicationUtilities::Argument m_workingDirArg;
|
||||
ApplicationUtilities::Argument m_unitsArg;
|
||||
ArgumentParser m_parser;
|
||||
Argument m_testFilesPathArg;
|
||||
Argument m_applicationPathArg;
|
||||
Argument m_workingDirArg;
|
||||
Argument m_unitsArg;
|
||||
std::vector<std::string> m_testFilesPaths;
|
||||
std::string m_workingDir;
|
||||
bool m_valid;
|
||||
|
@ -243,8 +243,7 @@ template <typename T, Traits::DisableIf<std::is_integral<T>> * = nullptr> const
|
|||
{ \
|
||||
const auto returnCode = execApp(args, stdout, stderr); \
|
||||
if (returnCode != 0) { \
|
||||
CPPUNIT_FAIL( \
|
||||
::ConversionUtilities::argsToString("app failed with return code ", returnCode, "\nstdout: ", stdout, "\nstderr: ", stderr)); \
|
||||
CPPUNIT_FAIL(::CppUtilities::argsToString("app failed with return code ", returnCode, "\nstdout: ", stdout, "\nstderr: ", stderr)); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -254,14 +253,14 @@ template <typename T, Traits::DisableIf<std::is_integral<T>> * = nullptr> const
|
|||
*/
|
||||
#define TESTUTILS_ASSERT_LIKE(message, expectedRegex, actualString) \
|
||||
(CPPUNIT_NS::Asserter::failIf(!(std::regex_match(actualString, std::regex(expectedRegex))), \
|
||||
CPPUNIT_NS::Message(ConversionUtilities::argsToString('\"', actualString, "\"\n not like\n\"", expectedRegex, '\"'), \
|
||||
"Expression: " #actualString, message), \
|
||||
CPPUNIT_NS::Message( \
|
||||
CppUtilities::argsToString('\"', actualString, "\"\n not like\n\"", expectedRegex, '\"'), "Expression: " #actualString, message), \
|
||||
CPPUNIT_SOURCELINE()))
|
||||
|
||||
/*!
|
||||
* \brief Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL.
|
||||
*/
|
||||
template <typename Pair, Traits::EnableIf<Traits::IsSpecializationOf<Pair, std::pair>> * = nullptr>
|
||||
template <typename Pair, CppUtilities::Traits::EnableIf<CppUtilities::Traits::IsSpecializationOf<Pair, std::pair>> * = nullptr>
|
||||
inline std::ostream &operator<<(std::ostream &out, const Pair &pair)
|
||||
{
|
||||
return out << "key: " << pair.first << "; value: " << pair.second << '\n';
|
||||
|
@ -313,6 +312,6 @@ constexpr std::int64_t operator"" _int64(unsigned long long size)
|
|||
return static_cast<std::int64_t>(size);
|
||||
}
|
||||
} // namespace Literals
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // TESTUTILS_H
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace Traits;
|
||||
using namespace CppUtilities::Traits;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue