Add namespace to utils::irdya_datetime and utils::wesnoth_epoch
Add documentation for them too.
This commit is contained in:
parent
11b0d711f3
commit
50b5d67567
6 changed files with 33 additions and 12 deletions
|
@ -188,14 +188,14 @@ campaign::campaign(const config& data)
|
|||
, max_players_(1)
|
||||
{
|
||||
if(data.has_attribute("start_year")) {
|
||||
dates_.first = irdya_date::read_date(data["start_year"]);
|
||||
dates_.first = utils::irdya_date::read_date(data["start_year"]);
|
||||
if(data.has_attribute("end_year")) {
|
||||
dates_.second = irdya_date::read_date(data["end_year"]);
|
||||
dates_.second = utils::irdya_date::read_date(data["end_year"]);
|
||||
} else {
|
||||
dates_.second = dates_.first;
|
||||
}
|
||||
} else if(data.has_attribute("year")) {
|
||||
dates_.first = dates_.second = irdya_date::read_date(data["year"]);
|
||||
dates_.first = dates_.second = utils::irdya_date::read_date(data["year"]);
|
||||
}
|
||||
set_metadata();
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ public:
|
|||
return min_players_ <= player_count && max_players_ >= player_count;
|
||||
}
|
||||
|
||||
std::pair<irdya_date, irdya_date> dates() const
|
||||
std::pair<utils::irdya_date, utils::irdya_date> dates() const
|
||||
{
|
||||
return dates_;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ private:
|
|||
std::string image_label_;
|
||||
int min_players_;
|
||||
int max_players_;
|
||||
std::pair<irdya_date, irdya_date> dates_;
|
||||
std::pair<utils::irdya_date, utils::irdya_date> dates_;
|
||||
};
|
||||
|
||||
class create_engine
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include "utils/irdya_datetime.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using irdya_date = utils::irdya_date;
|
||||
using wesnoth_epoch = utils::wesnoth_epoch;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_irdya_datetime)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_irdya_date_parse) {
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include <exception>
|
||||
|
||||
using namespace utils;
|
||||
|
||||
irdya_date irdya_date::read_date(const std::string& date)
|
||||
{
|
||||
irdya_date date_result;
|
||||
|
@ -72,7 +74,7 @@ std::string irdya_date::to_string() const
|
|||
return "";
|
||||
}
|
||||
|
||||
bool operator<(const irdya_date& a, const irdya_date& b)
|
||||
bool utils::operator<(const irdya_date& a, const irdya_date& b)
|
||||
{
|
||||
if(!b.is_valid()) {
|
||||
return a.is_valid();
|
||||
|
@ -98,32 +100,32 @@ bool operator<(const irdya_date& a, const irdya_date& b)
|
|||
}
|
||||
}
|
||||
|
||||
bool operator>(const irdya_date& a, const irdya_date& b)
|
||||
bool utils::operator>(const irdya_date& a, const irdya_date& b)
|
||||
{
|
||||
return b < a;
|
||||
}
|
||||
|
||||
bool operator<=(const irdya_date& a, const irdya_date& b)
|
||||
bool utils::operator<=(const irdya_date& a, const irdya_date& b)
|
||||
{
|
||||
return !(a > b);
|
||||
}
|
||||
|
||||
bool operator>=(const irdya_date& a, const irdya_date& b)
|
||||
bool utils::operator>=(const irdya_date& a, const irdya_date& b)
|
||||
{
|
||||
return !(a < b);
|
||||
}
|
||||
|
||||
bool operator==(const irdya_date& a, const irdya_date& b)
|
||||
bool utils::operator==(const irdya_date& a, const irdya_date& b)
|
||||
{
|
||||
return a.get_year() == b.get_year() && a.get_epoch() == b.get_epoch();
|
||||
}
|
||||
|
||||
bool operator!=(const irdya_date& a, const irdya_date& b)
|
||||
bool utils::operator!=(const irdya_date& a, const irdya_date& b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const irdya_date& d)
|
||||
std::ostream& utils::operator<<(std::ostream& s, const irdya_date& d)
|
||||
{
|
||||
s << d.to_string();
|
||||
return s;
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
|
||||
/**
|
||||
* Calendar for handling and comparing dates using the common epoches of the storyline.
|
||||
*/
|
||||
class irdya_date
|
||||
{
|
||||
public:
|
||||
|
@ -70,3 +76,5 @@ bool operator==(const irdya_date& a, const irdya_date& b);
|
|||
bool operator!=(const irdya_date& a, const irdya_date& b);
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const irdya_date& d);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
|
||||
#include "enum_base.hpp"
|
||||
|
||||
namespace utils
|
||||
{
|
||||
|
||||
/**
|
||||
* Reference points for the dates that define the storyline's calendar.
|
||||
*/
|
||||
struct wesnoth_epoch_defines
|
||||
{
|
||||
static constexpr const char* const before_wesnoth = "BW";
|
||||
|
@ -28,3 +34,5 @@ struct wesnoth_epoch_defines
|
|||
ENUM_AND_ARRAY(before_wesnoth, wesnoth, before_fall, after_fall)
|
||||
};
|
||||
using wesnoth_epoch = string_enums::enum_base<wesnoth_epoch_defines>;
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue