Skip to content

Commit

Permalink
libcore: API improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent c6b8cab commit 426a1d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doomsday/libs/core/include/de/data/list.h
Expand Up @@ -63,7 +63,10 @@ class List : public std::vector<T>

using Base::begin;
using Base::end;
using Base::cbegin;
using Base::cend;
using Base::push_back;
using Base::emplace_back;
using Base::size;
void pop_front() { removeFirst(); } // slow...
void push_front(const T &v) { prepend(v); } // slow...
Expand Down Expand Up @@ -105,6 +108,7 @@ class List : public std::vector<T>
void removeLast() { Base::erase(Base::begin() + size() - 1); }
void removeAt(size_t pos) { Base::erase(Base::begin() + pos); }
void removeAll(const T &v) { Base::erase(std::remove(begin(), end(), v), end()); }
void remove(size_t pos, size_t count) { Base::erase(cbegin() + pos, cbegin() + pos + count); }
bool removeOne(const T &v)
{
auto found = std::find(begin(), end(), v);
Expand Down
4 changes: 3 additions & 1 deletion doomsday/libs/core/include/de/data/time.h
Expand Up @@ -154,7 +154,7 @@ class DE_PUBLIC Time : public ISerializable
HumanDate, ///< human-entered date (only with Time::fromText)
UnixLsStyleDateTime,
};

using TimePoint = std::chrono::system_clock::time_point;

public:
Expand Down Expand Up @@ -303,6 +303,8 @@ class DE_PUBLIC Time : public ISerializable

static void updateCurrentHighPerformanceTime();

static Span currentHighPerformanceDelta();

/**
* Parses a text string into a Time.
*
Expand Down
7 changes: 6 additions & 1 deletion doomsday/libs/core/src/data/time.cpp
Expand Up @@ -531,7 +531,7 @@ Time Time::parse(const String &text, const char *format) // static
}
if (is.fail()) return Time::invalidTime();
}

// Assume missing date values.
if (year == 0)
{
Expand Down Expand Up @@ -746,6 +746,11 @@ void Time::updateCurrentHighPerformanceTime() // static
currentHighPerfDelta = highPerfTimer().elapsed();
}

Time::Span Time::currentHighPerformanceDelta()
{
return currentHighPerfDelta;
}

std::ostream &operator<<(std::ostream &os, Time const &t)
{
return os << t.asText();
Expand Down

0 comments on commit 426a1d4

Please sign in to comment.