Browse Source

minor adjustments

experiment/meta_header
Martchus 6 years ago
parent
commit
a8f7644350
  1. 1
      CMakeLists.txt
  2. 5
      README.md
  3. 1
      c++utilities.pro
  4. 27
      chrono/datetime.cpp
  5. 97
      chrono/datetime.h
  6. 3
      chrono/period.cpp
  7. 6
      chrono/period.h
  8. 12
      chrono/timespan.cpp
  9. 102
      chrono/timespan.h
  10. 46
      conversion/binaryconversion.cpp
  11. 2
      conversion/binaryconversionprivate.h
  12. 8
      conversion/conversionexception.cpp
  13. 2
      conversion/stringconversion.cpp
  14. 25
      conversion/widen.h
  15. 6
      io/binaryreader.cpp
  16. 17
      io/binarywriter.cpp
  17. 2
      io/bitreader.cpp
  18. 15
      io/copy.h
  19. 8
      io/inifile.h
  20. 6
      io/path.cpp
  21. 2
      math/math.h
  22. 4
      misc/random.cpp

1
CMakeLists.txt

@ -35,7 +35,6 @@ set(SRC_FILES
chrono/datetime.cpp
chrono/period.cpp
chrono/timespan.cpp
conversion/binaryconversion.cpp
conversion/conversionexception.cpp
conversion/stringconversion.cpp
io/ansiescapecodes.cpp

5
README.md

@ -18,3 +18,8 @@ make && make install
In any case, the make option *-j* might be used to compile multiple files in parallel.
The repository PKGBUILDs (also on GitHub) contains files for building Arch Linux packages. A PKGBUILD file to build for Windows using the Mingw-w64 compiler is also included.
## TODO
- provide unit tests
- rewrite argument parser
- remove unused features

1
c++utilities.pro

@ -52,7 +52,6 @@ SOURCES += \
chrono/datetime.cpp \
chrono/period.cpp \
chrono/timespan.cpp \
conversion/binaryconversion.cpp \
conversion/conversionexception.cpp \
conversion/stringconversion.cpp \
io/ansiescapecodes.cpp \

27
chrono/datetime.cpp

@ -4,7 +4,6 @@
#include <sstream>
#include <iomanip>
#include <ctime>
#include <stdexcept>
using namespace std;
@ -59,7 +58,7 @@ DateTime DateTime::fromTimeStamp(time_t timeStamp)
}
/*!
* Parses the given std::string \a str as DateTime.
* \brief Parses the given std::string \a str as DateTime.
*/
DateTime DateTime::fromString(const string &str)
{
@ -79,8 +78,8 @@ DateTime DateTime::fromString(const string &str)
}
/*!
* Converts the value of the current DateTime object to its equivalent std::string representation
* according the given \a format.
* \brief Converts the value of the current DateTime object to its equivalent std::string representation
* according the given \a format.
*
* If \a noMilliseconds is true the date will be rounded to full seconds.
*/
@ -92,8 +91,8 @@ string DateTime::toString(DateTimeOutputFormat format, bool noMilliseconds) cons
}
/*!
* Converts the value of the current DateTime object to its equivalent std::string representation
* according the given \a format.
* \brief Converts the value of the current DateTime object to its equivalent std::string representation
* according the given \a format.
*
* If \a noMilliseconds is true the date will be rounded to full seconds.
*/
@ -127,7 +126,7 @@ void DateTime::toString(string &result, DateTimeOutputFormat format, bool noMill
}
/*!
* Returns the string representation as C-style string for the given day of week.
* \brief Returns the string representation as C-style string for the given day of week.
*
* If \a abbreviation is true, only the first three letters of the string will
* be returned.
@ -174,15 +173,7 @@ const char *DateTime::printDayOfWeek(DayOfWeek dayOfWeek, bool abbreviation)
}
/*!
* Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
*/
DateTime DateTime::now()
{
return DateTime::fromTimeStamp(time(nullptr));
}
/*!
* Converts the given date expressed in \a year, \a month and \a day to ticks.
* \brief Converts the given date expressed in \a year, \a month and \a day to ticks.
*/
uint64 DateTime::dateToTicks(int year, int month, int day)
{
@ -207,7 +198,7 @@ uint64 DateTime::dateToTicks(int year, int month, int day)
}
/*!
* Converts the given time expressed in \a hour, \a minute, \a second and \a millisecond to ticks.
* \brief Converts the given time expressed in \a hour, \a minute, \a second and \a millisecond to ticks.
*/
uint64 DateTime::timeToTicks(int hour, int minute, int second, double millisecond)
{
@ -227,7 +218,7 @@ uint64 DateTime::timeToTicks(int hour, int minute, int second, double millisecon
}
/*!
* Returns the specified date part.
* \brief Returns the specified date part.
* \sa DatePart
*/
int DateTime::getDatePart(DatePart part) const

97
chrono/datetime.h

@ -6,13 +6,14 @@
#include "../conversion/types.h"
#include <string>
#include <ctime>
#include <limits>
namespace ChronoUtilities
{
/*!
* \brief Specifies the output format.
*
* \sa DateTime::toString()
*/
enum class DateTimeOutputFormat
@ -26,7 +27,6 @@ enum class DateTimeOutputFormat
/*!
* \brief Specifies the day of the week.
*
* \sa DateTime::dayOfWeek()
*/
enum class DayOfWeek
@ -42,7 +42,6 @@ enum class DayOfWeek
/*!
* \brief Specifies the date part.
*
* \sa DateTime::getDatePart()
*/
enum class DatePart
@ -77,11 +76,13 @@ public:
constexpr bool isNull() const;
constexpr TimeSpan timeOfDay() const;
bool isLeapYear() const;
constexpr bool isEternity() const;
constexpr bool isSameDay(const DateTime &other) const;
std::string toString(DateTimeOutputFormat format = DateTimeOutputFormat::DateAndTime, bool noMilliseconds = false) const;
void toString(std::string &result, DateTimeOutputFormat format = DateTimeOutputFormat::DateAndTime, bool noMilliseconds = false) const;
static const char *printDayOfWeek(DayOfWeek dayOfWeek, bool abbreviation = false);
static constexpr DateTime eternity();
static DateTime now();
constexpr static bool isLeapYear(int year);
static int daysInMonth(int year, int month);
@ -119,21 +120,21 @@ private:
};
/*!
* Constructs a DateTime.
* \brief Constructs a DateTime.
*/
constexpr inline DateTime::DateTime() :
m_ticks(0)
{}
/*!
* Constructs a DateTime with the specified number of \a ticks.
* \brief Constructs a DateTime with the specified number of \a ticks.
*/
constexpr inline DateTime::DateTime(uint64 ticks) :
m_ticks(ticks)
{}
/*!
* Constructs a DateTime to the specified \a year, \a month, and \a day.
* \brief Constructs a DateTime to the specified \a year, \a month, and \a day.
*/
inline DateTime DateTime::fromDate(int year, int month, int day)
{
@ -141,7 +142,7 @@ inline DateTime DateTime::fromDate(int year, int month, int day)
}
/*!
* Constructs a DateTime to the specified \a hour, \a minute, \a second and \a millisecond.
* \brief Constructs a DateTime to the specified \a hour, \a minute, \a second and \a millisecond.
*/
inline DateTime DateTime::fromTime(int hour, int minute, int second, double millisecond)
{
@ -149,7 +150,7 @@ inline DateTime DateTime::fromTime(int hour, int minute, int second, double mill
}
/*!
* Constructs a DateTime to the specified \a year, \a month, \a day, \a hour, \a minute, \a second and \a millisecond.
* \brief Constructs a DateTime to the specified \a year, \a month, \a day, \a hour, \a minute, \a second and \a millisecond.
*/
inline DateTime DateTime::fromDateAndTime(int year, int month, int day, int hour, int minute, int second, double millisecond)
{
@ -160,7 +161,7 @@ inline DateTime DateTime::fromDateAndTime(int year, int month, int day, int hour
}
/*!
* Gets the number of ticks which represent the value of the current instance.
* \brief Gets the number of ticks which represent the value of the current instance.
*/
constexpr inline uint64 DateTime::totalTicks() const
{
@ -168,7 +169,7 @@ constexpr inline uint64 DateTime::totalTicks() const
}
/*!
* Gets the year component of the date represented by this instance.
* \brief Gets the year component of the date represented by this instance.
*/
inline int DateTime::year() const
{
@ -176,7 +177,7 @@ inline int DateTime::year() const
}
/*!
* Gets the month component of the date represented by this instance.
* \brief Gets the month component of the date represented by this instance.
*/
inline int DateTime::month() const
{
@ -184,7 +185,7 @@ inline int DateTime::month() const
}
/*!
* Gets the day component of the date represented by this instance.
* \brief Gets the day component of the date represented by this instance.
*/
inline int DateTime::day() const
{
@ -192,7 +193,7 @@ inline int DateTime::day() const
}
/*!
* Gets the day of the year represented by this instance.
* \brief Gets the day of the year represented by this instance.
*/
inline int DateTime::dayOfYear() const
{
@ -200,7 +201,7 @@ inline int DateTime::dayOfYear() const
}
/*!
* Gets the day of the week represented by this instance.
* \brief Gets the day of the week represented by this instance.
* \sa DayOfWeek
*/
constexpr inline DayOfWeek DateTime::dayOfWeek() const
@ -209,7 +210,7 @@ constexpr inline DayOfWeek DateTime::dayOfWeek() const
}
/*!
* Gets the hour component of the date represented by this instance.
* \brief Gets the hour component of the date represented by this instance.
*/
constexpr inline int DateTime::hour() const
{
@ -217,7 +218,7 @@ constexpr inline int DateTime::hour() const
}
/*!
* Gets the minute component of the date represented by this instance.
*\brief Gets the minute component of the date represented by this instance.
*/
constexpr inline int DateTime::minute() const
{
@ -225,7 +226,7 @@ constexpr inline int DateTime::minute() const
}
/*!
* Gets the second component of the date represented by this instance.
* \brief Gets the second component of the date represented by this instance.
*/
constexpr inline int DateTime::second() const
{
@ -233,7 +234,7 @@ constexpr inline int DateTime::second() const
}
/*!
* Gets the millisecond component of the date represented by this instance.
* \brief Gets the millisecond component of the date represented by this instance.
*/
constexpr inline int DateTime::millisecond() const
{
@ -241,7 +242,7 @@ constexpr inline int DateTime::millisecond() const
}
/*!
* Returns ture if the date represented by the current DateTime class is null.
* \brief Returns ture if the date represented by the current DateTime class is null.
* \sa DateTime
*/
constexpr inline bool DateTime::isNull() const
@ -250,7 +251,7 @@ constexpr inline bool DateTime::isNull() const
}
/*!
* Gets the time of day as TimeSpan for this instance.
* \brief Gets the time of day as TimeSpan for this instance.
*/
constexpr inline TimeSpan DateTime::timeOfDay() const
{
@ -258,7 +259,7 @@ constexpr inline TimeSpan DateTime::timeOfDay() const
}
/*!
* Returns an indication whether the year of the dae represented by this instance is a leap year.
* \brief Returns an indication whether the year of the dae represented by this instance is a leap year.
*/
inline bool DateTime::isLeapYear() const
{
@ -266,7 +267,15 @@ inline bool DateTime::isLeapYear() const
}
/*!
* Returns an indication whether the specified \a year is a leap year.
* \brief Returns whether the instance has the maximal number of ticks.
*/
constexpr inline bool DateTime::isEternity() const
{
return m_ticks == std::numeric_limits<decltype(m_ticks)>::max();
}
/*!
* \brief Returns an indication whether the specified \a year is a leap year.
*/
constexpr inline bool DateTime::isLeapYear(int year)
{
@ -278,7 +287,7 @@ constexpr inline bool DateTime::isLeapYear(int year)
}
/*!
* Returns the number of days in the specified \a month and \a year.
* \brief Returns the number of days in the specified \a month and \a year.
*/
inline int DateTime::daysInMonth(int year, int month)
{
@ -290,7 +299,7 @@ inline int DateTime::daysInMonth(int year, int month)
}
/*!
* Returns and indication whether two DateTime instances represent the same day.
* \brief Returns and indication whether two DateTime instances represent the same day.
*/
constexpr inline bool DateTime::isSameDay(const DateTime &other) const
{
@ -298,7 +307,23 @@ constexpr inline bool DateTime::isSameDay(const DateTime &other) const
}
/*!
* Indicates whether two DateTime instances are equal.
* \brief Constructs a new instance of the DateTime class with the maximal number of ticks.
*/
constexpr inline DateTime DateTime::eternity()
{
return DateTime(std::numeric_limits<decltype(m_ticks)>::max());
}
/*!
* \brief Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
*/
inline DateTime DateTime::now()
{
return DateTime::fromTimeStamp(time(nullptr));
}
/*!
* \brief Indicates whether two DateTime instances are equal.
*/
constexpr inline bool DateTime::operator ==(const DateTime &other) const
{
@ -306,7 +331,7 @@ constexpr inline bool DateTime::operator ==(const DateTime &other) const
}
/*!
* Indicates whether two DateTime instances are not equal.
* \brief Indicates whether two DateTime instances are not equal.
*/
constexpr inline bool DateTime::operator !=(const DateTime &other) const
{
@ -314,7 +339,7 @@ constexpr inline bool DateTime::operator !=(const DateTime &other) const
}
/*!
* Indicates whether a specified DateTime is less than another specified DateTime.
* \brief Indicates whether a specified DateTime is less than another specified DateTime.
*/
constexpr inline bool DateTime::operator <(const DateTime &other) const
{
@ -322,7 +347,7 @@ constexpr inline bool DateTime::operator <(const DateTime &other) const
}
/*!
* Indicates whether a specified DateTime is greater than another specified DateTime.
* \brief Indicates whether a specified DateTime is greater than another specified DateTime.
*/
constexpr inline bool DateTime::operator >(const DateTime &other) const
{
@ -330,7 +355,7 @@ constexpr inline bool DateTime::operator >(const DateTime &other) const
}
/*!
* Indicates whether a specified DateTime is less or equal than another specified DateTime.
* \brief Indicates whether a specified DateTime is less or equal than another specified DateTime.
*/
constexpr inline bool DateTime::operator <=(const DateTime &other) const
{
@ -338,7 +363,7 @@ constexpr inline bool DateTime::operator <=(const DateTime &other) const
}
/*!
* Indicates whether a specified DateTime is greater or equal than another specified DateTime.
* \brief Indicates whether a specified DateTime is greater or equal than another specified DateTime.
*/
constexpr inline bool DateTime::operator >=(const DateTime &other) const
{
@ -346,7 +371,7 @@ constexpr inline bool DateTime::operator >=(const DateTime &other) const
}
/*!
* Adds a TimeSpan.
* \brief Adds another instance.
* \returns The result is another DateTime.
*/
constexpr inline DateTime DateTime::operator +(const TimeSpan &timeSpan) const
@ -355,7 +380,7 @@ constexpr inline DateTime DateTime::operator +(const TimeSpan &timeSpan) const
}
/*!
* Substracts a TimeSpan.
* \brief Substracts another instance.
* \returns The result is another DateTime.
*/
constexpr inline DateTime DateTime::operator -(const TimeSpan &timeSpan) const
@ -364,7 +389,7 @@ constexpr inline DateTime DateTime::operator -(const TimeSpan &timeSpan) const
}
/*!
* Adds two DateTime instances.
* \brief Adds two instances.
* \returns The result is a TimeSpan.
*/
constexpr inline TimeSpan DateTime::operator +(const DateTime &other) const
@ -373,7 +398,7 @@ constexpr inline TimeSpan DateTime::operator +(const DateTime &other) const
}
/*!
* Substracts two DateTime instances.
* \brief Substracts two DateTime instances.
* \returns The result is a TimeSpan.
*/
constexpr inline TimeSpan DateTime::operator -(const DateTime &other) const
@ -382,7 +407,7 @@ constexpr inline TimeSpan DateTime::operator -(const DateTime &other) const
}
/*!
* Adds a TimeSpan to the current instance.
* \brief Adds a TimeSpan to the current instance.
*/
inline DateTime &DateTime::operator +=(const TimeSpan &timeSpan)
{
@ -391,7 +416,7 @@ inline DateTime &DateTime::operator +=(const TimeSpan &timeSpan)
}
/*!
* Substracts a TimeSpan from the current instance.
* \brief Substracts a TimeSpan from the current instance.
*/
inline DateTime &DateTime::operator -=(const TimeSpan &timeSpan)
{

3
chrono/period.cpp

@ -8,8 +8,7 @@ namespace ChronoUtilities {
*/
/*!
* Constructs a new Period defined by a start DateTime and
* an end DateTime.
* \brief Constructs a new Period defined by a start DateTime and an end DateTime.
*/
Period::Period(const DateTime &beg, const DateTime &end)
{

6
chrono/period.h

@ -21,7 +21,7 @@ private:
};
/*!
* Gets the years component of the period represented by the current instance.
* \brief Gets the years component of the period represented by the current instance.
*/
inline int Period::years() const
{
@ -29,7 +29,7 @@ inline int Period::years() const
}
/*!
* Gets the months component of the period represented by the current instance.
* \brief Gets the months component of the period represented by the current instance.
*/
inline int Period::months() const
{
@ -37,7 +37,7 @@ inline int Period::months() const
}
/*!
* Gets the days component of the period represented by the current instance.
* \brief Gets the days component of the period represented by the current instance.
*/
inline int Period::days() const
{

12
chrono/timespan.cpp

@ -18,7 +18,7 @@ using namespace ConversionUtilities;
*/
/*!
* Parses the given std::string \a str as TimeSpan.
* \brief Parses the given std::string \a str as TimeSpan.
*/
TimeSpan TimeSpan::fromString(const string &str)
{
@ -26,7 +26,7 @@ TimeSpan TimeSpan::fromString(const string &str)
}
/*!
* Parses the given std::string \a str as TimeSpan.
* \brief Parses the given std::string \a str as TimeSpan.
*/
TimeSpan TimeSpan::fromString(const string &str, char separator)
{
@ -57,8 +57,8 @@ TimeSpan TimeSpan::fromString(const string &str, char separator)
}
/*!
* Converts the value of the current TimeSpan object to its equivalent std::string representation
* according the given \a format.
* \brief Converts the value of the current TimeSpan object to its equivalent std::string representation
* according the given \a format.
*
* If \a noMilliseconds is true the time interval will be rounded to full seconds.
*/
@ -70,8 +70,8 @@ string TimeSpan::toString(TimeSpanOutputFormat format, bool noMilliseconds) cons
}
/*!
* Converts the value of the current TimeSpan object to its equivalent std::string representation
* according the given \a format.
* \brief Converts the value of the current TimeSpan object to its equivalent std::string representation
* according the given \a format.
*
* If \a noMilliseconds is true the time interval will be rounded to full seconds.
*

102
chrono/timespan.h

@ -5,6 +5,7 @@
#include "../conversion/types.h"
#include <string>
#include <limits>
/*!
* \brief Contains classes providing a means for handling date and time information.
@ -38,6 +39,8 @@ public:
static constexpr TimeSpan fromDays(double days);
static TimeSpan fromString(const std::string &str);
static TimeSpan fromString(const std::string &str, char separator);
static constexpr TimeSpan negativeInfinity();
static constexpr TimeSpan infinity();
constexpr int64 totalTicks() const;
constexpr double totalMilliseconds() const;
@ -67,6 +70,8 @@ public:
void toString(std::string &result, TimeSpanOutputFormat format = TimeSpanOutputFormat::Normal, bool noMilliseconds = false) const;
constexpr bool isNull() const;
constexpr bool isNegative() const;
constexpr bool isNegativeInfinity() const;
constexpr bool isInfinity() const;
private:
int64 m_ticks;
@ -78,44 +83,75 @@ private:
};
/*!
* Constructs a new instance of the TimeSpan class with zero ticks.
* \brief Constructs a new instance of the TimeSpan class with zero ticks.
*/
constexpr inline TimeSpan::TimeSpan() : m_ticks(0)
{}
/*!
* Constructs a new instance of the TimeSpan class with the specified number of ticks.
* \brief Constructs a new instance of the TimeSpan class with the specified number of ticks.
*/
constexpr inline TimeSpan::TimeSpan(int64 ticks) : m_ticks(ticks)
{}
/*!
* \brief Constructs a new instance of the TimeSpan class with the specified number of miliseconds.
*/
constexpr inline TimeSpan TimeSpan::fromMilliseconds(double milliseconds)
{
return TimeSpan(static_cast<int64>(milliseconds * static_cast<double>(m_ticksPerMillisecond)));
}
/*!
* \brief Constructs a new instance of the TimeSpan class with the specified number of seconds.
*/
constexpr inline TimeSpan TimeSpan::fromSeconds(double seconds)
{
return TimeSpan(static_cast<int64>(seconds * static_cast<double>(m_ticksPerSecond)));
}
/*!
* \brief Constructs a new instance of the TimeSpan class with the specified number of minutes.
*/
constexpr inline TimeSpan TimeSpan::fromMinutes(double minutes)
{
return TimeSpan(static_cast<int64>(minutes * static_cast<double>(m_ticksPerMinute)));
}
/*!
* \brief Constructs a new instance of the TimeSpan class with the specified number of hours.
*/
constexpr inline TimeSpan TimeSpan::fromHours(double hours)
{
return TimeSpan(static_cast<int64>(hours * static_cast<double>(m_ticksPerHour)));
}
/*!
* \brief Constructs a new instance of the TimeSpan class with the specified number of days.
*/
constexpr inline TimeSpan TimeSpan::fromDays(double days)
{
return TimeSpan(static_cast<int64>(days * static_cast<double>(m_ticksPerDay)));
}
/*!
* Gets the number of ticks that represent the value of the current TimeSpan class.
* \brief Constructs a new instace of the TimeSpan class with the minimal number of ticks.
*/
constexpr inline TimeSpan TimeSpan::negativeInfinity()
{
return TimeSpan(std::numeric_limits<decltype(m_ticks)>::min());
}
/*!
* \brief Constructs a new instace of the TimeSpan class with the maximal number of ticks.
*/
constexpr inline TimeSpan TimeSpan::infinity()
{
return TimeSpan(std::numeric_limits<decltype(m_ticks)>::max());
}
/*!
* \brief Gets the number of ticks that represent the value of the current TimeSpan class.
*/
constexpr inline int64 TimeSpan::totalTicks() const
{
@ -123,7 +159,7 @@ constexpr inline int64 TimeSpan::totalTicks() const
}
/*!
* Gets the value of the current TimeSpan class expressed in whole and fractional milliseconds.
* \brief Gets the value of the current TimeSpan class expressed in whole and fractional milliseconds.
*/
constexpr inline double TimeSpan::totalMilliseconds() const
{
@ -131,7 +167,7 @@ constexpr inline double TimeSpan::totalMilliseconds() const
}
/*!
* Gets the value of the current TimeSpan class expressed in whole and fractional seconds.
* \brief Gets the value of the current TimeSpan class expressed in whole and fractional seconds.
*/
constexpr inline double TimeSpan::totalSeconds() const
{
@ -139,7 +175,7 @@ constexpr inline double TimeSpan::totalSeconds() const
}
/*!
* Gets the value of the current TimeSpan class expressed in whole and fractional minutes.
* \brief Gets the value of the current TimeSpan class expressed in whole and fractional minutes.
*/
constexpr inline double TimeSpan::totalMinutes() const
{
@ -147,7 +183,7 @@ constexpr inline double TimeSpan::totalMinutes() const
}
/*!
* Gets the value of the current TimeSpan class expressed in whole and fractional hours.
* \brief Gets the value of the current TimeSpan class expressed in whole and fractional hours.
*/
constexpr inline double TimeSpan::totalHours() const
{
@ -155,7 +191,7 @@ constexpr inline double TimeSpan::totalHours() const
}
/*!
* Gets the value of the current TimeSpan class expressed in whole and fractional days.
* \brief Gets the value of the current TimeSpan class expressed in whole and fractional days.
*/
constexpr inline double TimeSpan::totalDays() const
{
@ -163,7 +199,7 @@ constexpr inline double TimeSpan::totalDays() const
}
/*!
* Gets the miliseconds component of the time interval represented by the current TimeSpan class.
* \brief Gets the miliseconds component of the time interval represented by the current TimeSpan class.
*/
constexpr inline int TimeSpan::milliseconds() const
{
@ -171,7 +207,7 @@ constexpr inline int TimeSpan::milliseconds() const
}
/*!
* Gets the seconds component of the time interval represented by the current TimeSpan class.
* \brief Gets the seconds component of the time interval represented by the current TimeSpan class.
*/
constexpr inline int TimeSpan::seconds() const
{
@ -179,7 +215,7 @@ constexpr inline int TimeSpan::seconds() const
}
/*!
* Gets the minutes component of the time interval represented by the current TimeSpan class.
* \brief Gets the minutes component of the time interval represented by the current TimeSpan class.
*/
constexpr inline int TimeSpan::minutes() const
{
@ -187,7 +223,7 @@ constexpr inline int TimeSpan::minutes() const
}
/*!
* Gets the hours component of the time interval represented by the current TimeSpan class.
* \brief Gets the hours component of the time interval represented by the current TimeSpan class.
*/
constexpr inline int TimeSpan::hours() const
{
@ -195,7 +231,7 @@ constexpr inline int TimeSpan::hours() const
}
/*!
* Gets the days component of the time interval represented by the current TimeSpan class.
* \brief Gets the days component of the time interval represented by the current TimeSpan class.
*/
constexpr inline int TimeSpan::days() const
{
@ -203,7 +239,7 @@ constexpr inline int TimeSpan::days() const
}
/*!
* Indicates whether two TimeSpan instances are equal.
* \brief Indicates whether two TimeSpan instances are equal.
*/
constexpr inline bool TimeSpan::operator ==(const TimeSpan &other) const
{
@ -211,7 +247,7 @@ constexpr inline bool TimeSpan::operator ==(const TimeSpan &other) const
}
/*!
* Indicates whether two TimeSpan instances are not equal.
* \brief Indicates whether two TimeSpan instances are not equal.
*/
constexpr inline bool TimeSpan::operator !=(const TimeSpan &other) const
{
@ -219,7 +255,7 @@ constexpr inline bool TimeSpan::operator !=(const TimeSpan &other) const
}
/*!
* Indicates whether a specified TimeSpan is less than another specified TimeSpan.
* \brief Indicates whether a specified TimeSpan is less than another specified TimeSpan.
*/
constexpr inline bool TimeSpan::operator <(const TimeSpan &other) const
{
@ -227,7 +263,7 @@ constexpr inline bool TimeSpan::operator <(const TimeSpan &other) const
}
/*!
* Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
* \brief Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
*/
constexpr inline bool TimeSpan::operator >(const TimeSpan &other) const
{
@ -235,7 +271,7 @@ constexpr inline bool TimeSpan::operator >(const TimeSpan &other) const
}
/*!
* Indicates whether a specified TimeSpan is less or equal than another specified TimeSpan.
* \brief Indicates whether a specified TimeSpan is less or equal than another specified TimeSpan.
*/
constexpr inline bool TimeSpan::operator <=(const TimeSpan &other) const
{
@ -243,7 +279,7 @@ constexpr inline bool TimeSpan::operator <=(const TimeSpan &other) const
}
/*!
* Indicates whether a specified TimeSpan is greater or equal than another specified TimeSpan.
* \brief Indicates whether a specified TimeSpan is greater or equal than another specified TimeSpan.
*/
constexpr inline bool TimeSpan::operator >=(const TimeSpan &other) const
{
@ -251,7 +287,7 @@ constexpr inline bool TimeSpan::operator >=(const TimeSpan &other) const
}
/*!
* Adds two TimeSpan instances.
* \brief Adds two TimeSpan instances.
*/
constexpr inline TimeSpan TimeSpan::operator +(const TimeSpan &other) const
{
@ -259,7 +295,7 @@ constexpr inline TimeSpan TimeSpan::operator +(const TimeSpan &other) const
}
/*!
* Substracts two TimeSpan instances.
* \brief Substracts two TimeSpan instances.
*/
constexpr inline TimeSpan TimeSpan::operator -(const TimeSpan &other) const
{
@ -267,7 +303,7 @@ constexpr inline TimeSpan TimeSpan::operator -(const TimeSpan &other) const
}
/*!
* Adds another TimeSpan to the current instance.
* \brief Adds another TimeSpan to the current instance.
*/
inline TimeSpan &TimeSpan::operator +=(const TimeSpan &other)
{
@ -276,7 +312,7 @@ inline TimeSpan &TimeSpan::operator +=(const TimeSpan &other)
}
/*!
* Substracts another TimeSpan from the current instance.
* \brief Substracts another TimeSpan from the current instance.
*/
inline TimeSpan &TimeSpan::operator -=(const TimeSpan &other)
{
@ -285,7 +321,7 @@ inline TimeSpan &TimeSpan::operator -=(const TimeSpan &other)
}
/*!
* Returns ture if the time interval represented by the current TimeSpan class is null.
* \brief Returns ture if the time interval represented by the current TimeSpan class is null.
*/
constexpr inline bool TimeSpan::isNull() const
{
@ -293,13 +329,29 @@ constexpr inline bool TimeSpan::isNull() const
}
/*!
* Returns ture if the time interval represented by the current TimeSpan class is negative.
* \brief Returns ture if the time interval represented by the current TimeSpan class is negative.
*/
constexpr inline bool TimeSpan::isNegative() const
{
return m_ticks < 0;
}
/*!
* \brief Returns whether the time inverval represented by the current instance is the smallest representable TimeSpan.
*/
constexpr inline bool TimeSpan::isNegativeInfinity() const
{
return m_ticks == std::numeric_limits<decltype(m_ticks)>::min();
}
/*!
* \brief Returns whether the time inverval represented by the current instance is the longest representable TimeSpan.
*/
constexpr inline bool TimeSpan::isInfinity() const
{
return m_ticks == std::numeric_limits<decltype(m_ticks)>::max();
}
}
#endif // TIMESPAN_H

46
conversion/binaryconversion.cpp

@ -1,46 +0,0 @@
#include "binaryconversion.h"
#include "conversionexception.h"
#include <iostream>
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
# define BYTE_ORDER_1 ByteOrder::BigEndian
# define BYTE_ORDER_2 ByteOrder::LittleEndian
#elif defined(CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN)
# define BYTE_ORDER_2 ByteOrder::BigEndian
# define BYTE_ORDER_1 ByteOrder::LittleEndian
#elif defined(CONVERSION_UTILITIES_BYTE_ORDER_MIDDLE_ENDIAN)
# error "Middle endian byte order is not supported!"
#else
# error "Byte order not determined!"
#endif
#if defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_LITTLE_ENDIAN)
# define FLOAT_BYTE_ORDER_1 ByteOrder::BigEndian
# define FLOAT_BYTE_ORDER_2 ByteOrder::LittleEndian
#elif defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_BIG_ENDIAN)
# define FLOAT_BYTE_ORDER_2 ByteOrder::BigEndian
# define FLOAT_BYTE_ORDER_1 ByteOrder::LittleEndian
#elif defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_MIDDLE_ENDIAN)
# error "Middle endian byte order is not supported!"
#else
# error "Byte order not determined!"
#endif
/*!
* \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 an array of bytes to base data types.
*
* stringconversion.h declares different functions around string conversion such as converting a
* number to a string and vice versa.
*/
namespace ConversionUtilities
{
}

2
conversion/binaryconversionprivate.h

@ -1,7 +1,7 @@
#ifdef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
#ifndef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
#error "Do not include binaryconversionprivate.h directly."
# error "Do not include binaryconversionprivate.h directly."
#endif
#include "./types.h"

8
conversion/conversionexception.cpp

@ -9,22 +9,22 @@ namespace ConversionUtilities {
*/
/*!
* Constructs a new ConversionException.
* \brief Constructs a new ConversionException.
*/
ConversionException::ConversionException() USE_NOTHROW :
runtime_error("unable to convert")
{}
/*!
* Constructs a new ConversionException. \a what is a std::string
* describing the cause of the ConversionException.
* \brief Constructs a new ConversionException. \a what is a std::string
* describing the cause of the ConversionException.
*/
ConversionException::ConversionException(const std::string &what) USE_NOTHROW :
runtime_error(what)
{}
/*!
* Destroys the ConversionException.
* \brief Destroys the ConversionException.
*/
ConversionException::~ConversionException() USE_NOTHROW
{}

2
conversion/stringconversion.cpp

@ -12,7 +12,7 @@ namespace ConversionUtilities
/*!
* \brief Truncates all characters after the first occurrence of the
* specified \a terminationChar and the termination character as well.
* specified \a terminationChar and the termination character as well.
*/
void truncateString(string &str, char terminationChar)
{

25
conversion/widen.h

@ -13,34 +13,27 @@ namespace ConversionUtilities
{
/*!
* Converts a std::string to std::wstring.
* \brief Converts a std::string to a wide string using the specified locale.
*/
template<class E, class T = std::char_traits<E>, class A = std::allocator<E> >
class LIB_EXPORT Widen : public std::unary_function<
const std::string&, std::basic_string<E, T, A> >
class LIB_EXPORT Widen : public std::unary_function<const std::string &, std::basic_string<E, T, A> >
{
public:
/*!
* Constructs a new instance.
* \brief Constructs a new instance with the specified \a locale.
*/
Widen(const std::locale& loc = std::locale()) :
m_loc(loc)
{
#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6.0...
using namespace std;
m_pctype = &_USE(loc, ctype<E> );
#else
m_pctype = &std::use_facet<std::ctype<E> >(loc);
#endif
}
Widen(const std::locale &locale = std::locale()) :
m_loc(locale),
m_pctype(&std::use_facet<std::ctype<E> >(locale))
{}
Widen(const Widen &) = delete;
Widen& operator= (const Widen &) = delete;
/*!
* Performs the conversation for the provided \a string.
* \brief Performs the conversation for the provided \a string.
*/
std::basic_string<E, T, A> operator() (const std::string& string) const
std::basic_string<E, T, A> operator() (const std::string &string) const
{
typename std::basic_string<E, T, A>::size_type srcLen = string.length();
const char *srcBeg = string.c_str();

6
io/binaryreader.cpp

@ -267,10 +267,9 @@ string BinaryReader::readMultibyteTerminatedStringLE(size_t maxBytesToRead, uint
/*!
* \brief Reads \a length bytes from the stream and computes the CRC-32 for that block of data.
*
* \remarks A cyclic redundancy check (CRC) is an error-detecting code commonly used in
* \remarks Cyclic redundancy check (CRC) is an error-detecting code commonly used in
* digital networks and storage devices to detect accidental changes to raw data.
* \remarks NOT TESTED YET
*
* \sa <a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">Cyclic redundancy check - Wikipedia</a>
*/
uint32 BinaryReader::readCrc32(size_t length)
@ -285,10 +284,9 @@ uint32 BinaryReader::readCrc32(size_t length)
/*!
* \brief Reads \a length bytes from the buffer and computes the CRC-32 for that block of data.
*
* \remarks A cyclic redundancy check (CRC) is an error-detecting code commonly used in
* \remarks Cyclic redundancy check (CRC) is an error-detecting code commonly used in
* digital networks and storage devices to detect accidental changes to raw data.
* \remarks NOT TESTED YET
*
* \sa <a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">Cyclic redundancy check - Wikipedia</a>
*/
uint32 BinaryReader::computeCrc32(const char *buffer, size_t length)

17
io/binarywriter.cpp

@ -77,19 +77,18 @@ void BinaryWriter::setStream(ostream *stream, bool giveOwnership)
void BinaryWriter::writeLengthPrefixedString(const string &value)
{
size_t length = value.length();
char buff[4] = {0};
if(length < 0x80) {
buff[0] = 0x80 | length;
m_stream->write(buff, 1);
m_buffer[0] = 0x80 | length;
m_stream->write(m_buffer, 1);
} else if(length < 0x4000) {
BE::getBytes(static_cast<uint16>(0x4000 | length), buff);
m_stream->write(buff, 2);
BE::getBytes(static_cast<uint16>(0x4000 | length), m_buffer);
m_stream->write(m_buffer, 2);
} else if(length < 0x200000) {
BE::getBytes(static_cast<uint32>(0x200000 | length), buff);
m_stream->write(buff + 1, 3);
BE::getBytes(static_cast<uint32>(0x200000 | length), m_buffer);
m_stream->write(m_buffer + 1, 3);
} else if(length < 0x10000000) {
BE::getBytes(static_cast<uint32>(0x10000000 | length), buff);
m_stream->write(buff, 4);
BE::getBytes(static_cast<uint32>(0x10000000 | length), m_buffer);
m_stream->write(m_buffer, 4);
} else {
throw ConversionException("The size of the string exceeds the maximum.");
}

2
io/bitreader.cpp

@ -6,7 +6,7 @@ namespace IoUtilities {
/*!
* \class IoUtilities::BitReader
* \brief The BitReader class allows bitwise reading of buffered data.
* \brief The BitReader class provides bitwise reading of buffered data.
*/
/*!

15
io/copy.h

@ -20,6 +20,7 @@ public:
CopyHelper();
void copy(std::istream &input, std::ostream &output, std::size_t count);
void callbackCopy(std::istream &input, std::ostream &output, std::size_t count, const std::function<bool (void)> &isAborted, const std::function<void (double)> &callback);
char *buffer();
private:
char m_buffer[bufferSize];
};
@ -52,10 +53,9 @@ void CopyHelper<bufferSize>::copy(std::istream &input, std::ostream &output, std
/*!
* \brief Copies \a count bytes from \a input to \a output. The procedure might be abortet. Progress updates will be reportet.
*
* Copying is aborted when \a isAborted returns true. The current progress is reportet by calling the specified \a callback function.
* Copying is aborted when \a isAborted returns true. The current progress is reported by calling the specified \a callback function.
*
* \remarks Set an exception mask using std::ios::exceptions() to get
* a std::ios_base::failure exception when an IO error occurs.
* \remarks Set an exception mask using std::ios::exceptions() to get a std::ios_base::failure exception when an IO error occurs.
*/
template<std::size_t bufferSize>
void CopyHelper<bufferSize>::callbackCopy(std::istream &input, std::ostream &output, std::size_t count, const std::function<bool (void)> &isAborted, const std::function<void (double)> &callback)
@ -75,6 +75,15 @@ void CopyHelper<bufferSize>::callbackCopy(std::istream &input, std::ostream &out
callback(1.0);
}
/*!
* \brief Returns the internal buffer.
*/
template<std::size_t bufferSize>
char *CopyHelper<bufferSize>::buffer()
{
return m_buffer;
}
}
#endif // IOUTILITIES_COPY_H

8
io/inifile.h

@ -32,9 +32,8 @@ inline IniFile::IniFile()
/*!
* \brief Returns the data of the file.
*
* - The keys in the returned map represent the [scope name]s.
* - The values in the returned map are maps representing "key = value"-pairs within the scope.
* - The data might be modified an saved using the make() method.
* - The returned pairs represent the [scope names] and the contained "key = value"-pairs.
* - The data might be modified and then saved using the make() method.
*/
inline std::vector<std::pair<std::string, std::multimap<std::string, std::string> > > &IniFile::data()
{
@ -44,8 +43,7 @@ inline std::vector<std::pair<std::string, std::multimap<std::string, std::string
/*!
* \brief Returns the data of the file.
*
* - The keys in the returned map represent the [scope name]s.
* - The values in the returned map are maps representing "key = value"-pairs within the scope.
* - The returned pairs represent the [scope names] and the contained "key = value"-pairs.
*/
inline const std::vector<std::pair<std::string, std::multimap<std::string, std::string> > > &IniFile::data() const
{

6
io/path.cpp

@ -29,7 +29,7 @@ using namespace IoUtilities;
using namespace ConversionUtilities;
/*!