Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

154
common/std/algorithm.h Normal file
View File

@@ -0,0 +1,154 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_ALGORITHM_H
#define COMMON_STD_ALGORITHM_H
#include "common/algorithm.h"
#include "common/util.h"
namespace Std {
template<typename T> inline T abs(T x) {
return ABS(x);
}
template<typename T> inline T min(T a, T b) {
return MIN(a, b);
}
template<typename T> inline T max(T a, T b) {
return MAX(a, b);
}
template<typename T> inline T clip(T v, T amin, T amax) {
return CLIP(v, amin, amax);
}
template<typename T> inline T sqrt(T x) {
return ::sqrt(x);
}
template<typename T> inline void swap(T &a, T &b) {
SWAP(a, b);
}
template<class In, class Value>
In fill(In first, In last, const Value &val) {
return Common::fill(first, last, val);
}
template<typename T, class StrictWeakOrdering>
void sort(T first, T last, StrictWeakOrdering comp) {
Common::sort(first, last, comp);
}
template<typename T>
void sort(T *first, T *last) {
Common::sort(first, last, Common::Less<T>());
}
template<class T>
void sort(T first, T last) {
Common::sort(first, last);
}
template<class In, class T>
In find(In first, In last, const T &v) {
return Common::find(first, last, v);
}
template<class T>
T unique(T first, T last) {
T pos;
for (pos = first + 1; pos < last; ++pos) {
// Check for duplicate
for (T existingPos = first; existingPos < last; ++existingPos) {
if (*pos == *existingPos) {
// Found a match, so shift values over the duplicate
while (pos < (last - 1)) {
T &prior = pos;
++pos;
prior = pos;
}
--last;
break;
}
}
}
return pos;
}
template<class ForwardIt, class T>
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T &value) {
for (ForwardIt it = first; it < last; ++it) {
if (*it >= value)
return it;
}
return last;
}
template<class ForwardIt, class T>
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T &value) {
for (ForwardIt it = first; it < last; ++it) {
if (*it > value)
return it;
}
return last;
}
template<class ForwardIt, class T, class Compare>
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T &value, Compare comp) {
for (ForwardIt it = first; it < last; ++it) {
if (comp(value, *it))
return it;
}
return last;
}
template<class ForwardIt>
ForwardIt next(ForwardIt it, int n = 1) {
ForwardIt it2 = it;
while (n > 0) { ++it2; --n; }
while (n < 0) { --it2; ++n; }
return it2;
}
template<class BidirIt>
BidirIt prev(BidirIt it, int n = 1) {
BidirIt it2 = it;
while (n > 0) { --it2; --n; }
while (n < 0) { ++it2; ++n; }
return it2;
}
} // namespace Std
#endif

50
common/std/array.h Normal file
View File

@@ -0,0 +1,50 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_ARRAY_H
#define COMMON_STD_ARRAY_H
#include "common/array.h"
namespace Std {
template<class T>
class array : public Common::Array<T> {
public:
array() : Common::Array<T>() {
}
array(size_t size) : Common::Array<T>() {
Common::Array<T>::resize(size);
}
};
} // namespace Std
#endif

109
common/std/chrono.h Normal file
View File

@@ -0,0 +1,109 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_CHRONO_H
#define COMMON_STD_CHRONO_H
#include "common/system.h"
namespace Std {
namespace chrono {
class duration {
private:
uint32 _value;
public:
duration() : _value(0) {
}
duration(uint32 value) : _value(value) {
}
size_t count() const {
// durations for ScummVM are hardcoded to be in milliseconds
return 1000;
}
operator uint32() const {
return _value;
}
inline bool operator>=(const duration &rhs) const {
return _value >= rhs._value;
}
};
class milliseconds : public duration {
public:
milliseconds() : duration(0) {}
milliseconds(uint32 val) : duration(val) {}
static milliseconds zero() {
return milliseconds();
}
};
class microseconds : public duration {
public:
microseconds() : duration(0) {}
microseconds(long val) : duration(val / 1000) {}
};
struct system_clock {
};
struct steady_clock { // wraps QueryPerformanceCounter
using rep = uint32;
using period = milliseconds;
using duration = milliseconds;
using time_point = uint32;
static constexpr bool is_steady = true;
static time_point now() { // get current time
return g_system->getMillis();
}
};
using high_resolution_clock = steady_clock;
template<class T>
duration duration_cast(T param);
template<class T>
duration duration_cast(T param) {
return duration(param);
}
} // namespace chrono
} // namespace Std
#endif

67
common/std/functional.h Normal file
View File

@@ -0,0 +1,67 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_FUNCTIONAL_H
#define COMMON_STD_FUNCTIONAL_H
namespace Std {
template <class _Arg, class _Result>
struct unary_function { // base class for unary functions
using argument_type = _Arg;
using result_type = _Result;
};
template <class _Arg1, class _Arg2, class _Result>
struct binary_function { // base class for binary functions
using first_argument_type = _Arg1;
using second_argument_type = _Arg2;
using result_type = _Result;
};
template <typename _Fty>
struct function {
_Fty *_fn;
function() : _fn(nullptr) {}
function(_Fty *fn) : _fn(fn) {}
operator _Fty &() {
return *_fn;
}
operator bool() const {
return _fn != nullptr;
}
};
} // namespace Std
#endif

View File

@@ -0,0 +1,43 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_INITIALIZER_LIST_H
#define COMMON_STD_INITIALIZER_LIST_H
#include "common/scummsys.h"
namespace Std {
template<class T>
using initializer_list = ::std::initializer_list<T>;
} // namespace Std
#endif

43
common/std/limits.h Normal file
View File

@@ -0,0 +1,43 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_LIMITS_H
#define COMMON_STD_LIMITS_H
#include "common/scummsys.h"
namespace Std {
template<class T>
using numeric_limits = ::std::numeric_limits<T>;
} // namespace Std
#endif

93
common/std/list.h Normal file
View File

@@ -0,0 +1,93 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_LIST_H
#define COMMON_STD_LIST_H
#include "common/list.h"
namespace Std {
template<class T>
class list : public Common::List<T> {
public:
struct reverse_iterator {
private:
typename Common::List<T>::iterator _it;
public:
reverse_iterator(typename Common::List<T>::iterator it) : _it(it) {
}
reverse_iterator() {
}
T operator*() const {
return *_it;
}
reverse_iterator &operator++() {
--_it;
return *this;
}
bool operator==(const reverse_iterator &rhs) {
return _it == rhs._it;
}
bool operator!=(const reverse_iterator &rhs) {
return _it != rhs._it;
}
};
public:
reverse_iterator rbegin() {
return reverse_iterator(Common::List<T>::reverse_begin());
}
reverse_iterator rend() {
return reverse_iterator(Common::List<T>::end());
}
void splice(typename Common::List<T>::iterator pos, list<T>& /*other*/, typename Common::List<T>::iterator it ) {
// We insert it before pos in this list
typename Common::List<T>::NodeBase *n = it._node;
typename Common::List<T>::NodeBase *nPos = pos._node;
if (n == nullptr || nPos == nullptr || n == nPos || n->_next == nPos)
return;
// Remove from current position
n->_prev->_next = n->_next;
n->_next->_prev = n->_prev;
// Insert in new position
n->_next = nPos;
n->_prev = nPos->_prev;
n->_prev->_next = n;
n->_next->_prev = n;
}
};
} // namespace Std
#endif

223
common/std/map.h Normal file
View File

@@ -0,0 +1,223 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_MAP_H
#define COMMON_STD_MAP_H
#include "common/hashmap.h"
#include "common/std/utility.h"
namespace Std {
template<class Key, class Val, class CompFunc = Common::Less<Key> >
class map {
struct KeyValue {
Key _key;
Val _value;
};
private:
Common::Array<KeyValue> _items;
CompFunc _comp;
public:
using iterator = typename Common::Array<KeyValue>::iterator;
using const_iterator = typename Common::Array<KeyValue>::const_iterator;
/**
* Clears the map
*/
void clear() {
_items.clear();
}
/**
* Gets the iterator start
*/
iterator begin() {
return _items.begin();
}
/**
* Get the iterator end
*/
iterator end() {
return _items.end();
}
/**
* Get the const iterator start
*/
const_iterator begin() const {
return _items.begin();
}
/**
* Get the const iterator end
*/
const_iterator end() const {
return _items.end();
}
/**
* Returns an iterator for the first element of the map that is
* not less than the given key
*/
const_iterator lower_bound(const Key &theKey) const {
const_iterator first = this->begin();
const_iterator it;
int count_ = _items.size(), step;
while (count_ > 0) {
it = first;
step = count_ / 2;
it += step;
if (_comp(it->_key, theKey)) {
first = ++it;
count_ -= step + 1;
} else {
count_ = step;
}
}
return first;
}
iterator lower_bound(const Key &theKey) {
iterator first = this->begin();
iterator it;
int count_ = _items.size(), step;
while (count_ > 0) {
it = first;
step = count_ / 2;
it += step;
if (_comp(it->_key, theKey)) {
first = ++it;
count_ -= step + 1;
} else {
count_ = step;
}
}
return first;
}
/**
* Find the entry with the given key
*/
iterator find(const Key &theKey) {
iterator it = this->lower_bound(theKey);
if (it != this->end() && it->_key == theKey)
return it;
return this->end();
}
const_iterator find(const Key &theKey) const {
const_iterator it = this->lower_bound(theKey);
if (it != this->end() && it->_key == theKey)
return it;
return this->end();
}
/**
* Square brackets operator accesses items by key, creating if necessary
*/
Val &operator[](const Key &theKey) {
iterator it = this->lower_bound(theKey);
if (it == this->end() || it->_key != theKey) {
size_t idx = it - this->begin();
_items.insert_at(idx, KeyValue());
_items[idx]._key = theKey;
return _items[idx]._value;
} else {
return _items[it - this->begin()]._value;
}
}
/**
* Erases an entry in the map
*/
iterator erase(iterator it) {
iterator next = it;
++next;
_items.remove_at(it - begin());
return next;
}
iterator erase(const Key &theKey) {
return erase(find(theKey));
}
/**
* Returns the size of the map
*/
size_t size() const {
return _items.size();
}
/**
* Returns the number of elements with a matching key
*/
size_t count(const Key &theKey) {
int count_ = 0;
for (iterator it = this->begin(); it != this->end(); ++it) {
if (it->_key == theKey)
++count_;
}
return count_;
}
};
template<class Key, class Val, class HashFunc = Common::Hash<Key>,
class EqualFunc = Common::EqualTo<Key> >
class unordered_map : public Common::HashMap<Key, Val, HashFunc, EqualFunc> {
public:
pair<Key, Val> insert(pair<Key, Val> elem) {
// unordered_map doesn't replace already existing keys
if (this->contains(elem.first))
return pair<Key, Val>(elem.first, this->operator[](elem.first));
// Add item to map
this->operator[](elem.first) = elem.second;
return elem;
}
void reserve(size_t size) {
// No implementation
}
};
} // namespace Std
#endif

61
common/std/memory.h Normal file
View File

@@ -0,0 +1,61 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_MEMORY_H
#define COMMON_STD_MEMORY_H
#include "common/ptr.h"
#include "common/textconsole.h"
namespace Std {
template<class T>
using shared_ptr = Common::SharedPtr<T>;
template<class T>
using weak_ptr = Common::WeakPtr<T>;
template<typename T, class DL = Common::DefaultDeleter<T> >
using unique_ptr = Common::ScopedPtr<T, DL>;
template<class T>
T *memcpy(T *dest, const T *src, size_t n) {
return (T *)::memcpy(dest, src, n);
}
template<class T>
shared_ptr<T> static_pointer_cast(const shared_ptr<T> &src) {
T *ptr = src.get();
return shared_ptr<T>(ptr);
}
} // namespace Std
#endif

43
common/std/mutex.h Normal file
View File

@@ -0,0 +1,43 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_MUTEX_H
#define COMMON_STD_MUTEX_H
#include "common/mutex.h"
namespace Std {
class recursive_mutex : public Common::Mutex {
};
} // namespace Std
#endif

150
common/std/queue.h Normal file
View File

@@ -0,0 +1,150 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_QUEUE_H
#define COMMON_STD_QUEUE_H
#include "common/std/algorithm.h"
#include "common/std/vector.h"
#include "common/queue.h"
namespace Std {
template<class T>
using queue = Common::Queue<T>;
/**
* FIXME: The current implementation requires the reverse
* greater/lesser comparitor than the original does.
* If this is fixed, also change the router finder's use
*/
template<class T, class Container = vector<T>, class Comparitor = typename Common::Less<T> >
class priority_queue {
private:
Container _container;
Comparitor _comparitor;
public:
priority_queue() {}
bool empty() const {
return _container.empty();
}
const T &top() const {
return _container.front();
}
void push(const T &item) {
_container.push_back(item);
Common::sort(_container.begin(), _container.end(), _comparitor);
}
void pop() {
_container.remove_at(0);
}
};
template<class T>
class deque {
private:
vector<T> _intern;
public:
deque() = default;
typedef typename vector<T>::iterator iterator;
typedef const typename vector<T>::const_iterator const_iterator;
typedef typename vector<T>::reverse_iterator reverse_iterator;
typedef const typename vector<T>::const_reverse_iterator const_reverse_iterator;
void clear() {
_intern.clear();
}
void insert(const T &item) {
_intern.push_back(item);
}
void push_back(const T &item) {
_intern.push_back(item);
}
void push_front(const T &item) {
_intern.push_front(item);
}
void pop_back() {
_intern.pop_back();
}
void pop_front() {
_intern.remove_at(0);
}
const T &front() const {
return _intern.front();
}
const T &back() const {
return _intern.back();
}
void resize(size_t newSize) {
_intern.resize(newSize);
}
size_t size() const {
return _intern.size();
}
T at(size_t idx) {
return _intern[idx];
}
const_iterator cbegin() {
return _intern.cbegin();
}
const_iterator cend() {
return _intern.cend();
}
reverse_iterator rbegin() {
return _intern.rbegin();
}
reverse_iterator rend() {
return _intern.rend();
}
const_reverse_iterator rbegin() const {
return _intern.rbegin();
}
const_reverse_iterator rend() const {
return _intern.rend();
}
const_reverse_iterator crbegin() const {
return _intern.crbegin();
}
const_reverse_iterator crend() const {
return _intern.crend();
}
};
} // namespace Std
#endif

50
common/std/regex.h Normal file
View File

@@ -0,0 +1,50 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_REGEX_H
#define COMMON_STD_REGEX_H
#include "common/str.h"
#include "common/textconsole.h"
namespace Std {
struct regex {
public:
regex(const char *) {}
};
inline Common::String regex_replace(const char *wildcard, const regex &esc, const char *fmt) {
error("TODO: Implement if engine needs it");
}
} // namespace Std
#endif

143
common/std/set.h Normal file
View File

@@ -0,0 +1,143 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_SET_H
#define COMMON_STD_SET_H
#include "common/array.h"
namespace Std {
/**
* Derives the ScummVM SortedArray to match the std::set class
*/
template<class T, class Comparitor = Common::Less<T> >
class set : public Common::SortedArray<T, const T &> {
private:
static int ComparatorFn(const T &a, const T &b) {
return Comparitor().operator()(a, b) ? -1 : 0;
}
static bool CompareEq(const T &a, const T &b) {
return !ComparatorFn(a, b) && !ComparatorFn(b, a);
}
public:
struct Entry {
const T &_value;
Entry(const T &item) : _value(item) {
}
};
public:
using iterator = typename Common::SortedArray<T, const T &>::iterator;
using const_iterator = typename Common::SortedArray<T, const T &>::const_iterator;
/**
* Constructor
*/
set() : Common::SortedArray<T, const T & >(ComparatorFn) {}
/**
* Locate an item in the set
*/
iterator find(const T &item) {
iterator begin = this->begin();
iterator end = this->end();
while (begin < end) {
iterator mid = begin + (Common::distance(begin, end) / 2);
if (ComparatorFn(item, *mid))
end = mid;
else if (ComparatorFn(*mid, item))
begin = mid + 1;
else
return mid;
}
return this->end();
}
/**
* Insert an element at the sorted position.
*/
Entry insert(const T &item) {
Common::SortedArray<T, const T &>::insert(item);
return Entry(item);
}
/**
* Removes the element at the given iterator
*/
void erase(iterator item) {
Common::SortedArray<T, const T &>::erase(item);
}
/**
* Removes the elements at the specified range
*/
void erase(iterator first, iterator last) {
Common::SortedArray<T, const T &>::erase(first, last);
}
/**
* Removes the elements equal to the given item.
* Returns the number of elements removed
*/
size_t erase(const T &item) {
iterator first = find(item);
if (first == this->end())
return 0;
iterator end = first + 1;
while (end != this->end() && CompareEq(*first, *end)) {
++end;
}
size_t erased = Common::distance(first, end);
this->erase(first, end);
return erased;
}
/**
* Returns the number of keys that match the specified key
*/
size_t count(const T item) const {
size_t total = 0;
for (const_iterator it = this->begin(); it != this->end(); ++it) {
if (CompareEq(*it, item))
++total;
else if (!ComparatorFn(item, *it))
// Passed beyond possibility of matches
break;
}
return total;
}
};
} // namespace Std
#endif

43
common/std/stack.h Normal file
View File

@@ -0,0 +1,43 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_STACK_H
#define COMMON_STD_STACK_H
#include "common/stack.h"
namespace Std {
template<class T>
using stack = Common::Stack<T>;
} // namespace Std
#endif

43
common/std/std.cpp Normal file
View File

@@ -0,0 +1,43 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Dummy include of STD mockup headers so they'll appear in the Visual Studio project
#include "common/std/algorithm.h"
#include "common/std/array.h"
#include "common/std/chrono.h"
#include "common/std/functional.h"
#include "common/std/initializer_list.h"
#include "common/std/limits.h"
#include "common/std/list.h"
#include "common/std/map.h"
#include "common/std/memory.h"
#include "common/std/mutex.h"
#include "common/std/queue.h"
#include "common/std/regex.h"
#include "common/std/set.h"
#include "common/std/thread.h"
#include "common/std/type_traits.h"
#include "common/std/unordered_set.h"
#include "common/std/utility.h"
#include "common/std/vector.h"
#include "common/std/xtr1common.h"
#include "common/std/xutility.h"

54
common/std/thread.h Normal file
View File

@@ -0,0 +1,54 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_THREAD_H
#define COMMON_STD_THREAD_H
#include "common/std/chrono.h"
#include "common/textconsole.h"
namespace Std {
class this_thread {
public:
static void yield() {
warning("TODO: this_thread::yield");
}
static void sleep_for(uint32 milli) {
g_system->delayMillis(milli);
}
// template <class Rep, class Period>
// static void sleep_for(const chrono::duration<Rep, Period> &rel_time);
};
} // namespace Std
#endif

59
common/std/type_traits.h Normal file
View File

@@ -0,0 +1,59 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_TYPE_TRAITS_H
#define COMMON_STD_TYPE_TRAITS_H
#include "common/scummsys.h"
namespace Std {
// STRUCT TEMPLATE remove_extent
template <class _Ty>
struct remove_extent { // remove array extent
using type = _Ty;
};
template <class _Ty, size_t _Ix>
struct remove_extent<_Ty[_Ix]> {
using type = _Ty;
};
template <class _Ty>
struct remove_extent<_Ty[]> {
using type = _Ty;
};
template <class _Ty>
using remove_extent_t = typename remove_extent<_Ty>::type;
} // namespace Std
#endif

View File

@@ -0,0 +1,96 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_UNORDERED_SET_H
#define COMMON_STD_UNORDERED_SET_H
#include "common/array.h"
namespace Std {
/**
* Unordered set
* TODO: If needed, implement containers of items by unique hash of key
*/
template <class T, class Hash = Common::Hash<T>, class Pred = Common::EqualTo<T> >
class unordered_set : public Common::Array<T> {
private:
Hash _hash;
Pred _comparitor;
public:
struct Entry {
const T &_value;
Entry(const T &item) : _value(item) {}
};
public:
using iterator = typename Common::Array<T>::iterator;
using const_iterator = typename Common::Array<T>::const_iterator;
unordered_set() {}
/**
* Locate an item in the set
*/
iterator find(const T &item) {
iterator it;
for (it = this->begin(); it != this->end() && *it != item; ++it) {
}
return it;
}
/**
* Adds an item
*/
Entry insert(const T &item) {
this->push_back(item);
return Entry(item);
}
/**
* Returns the number of keys that match the specified key
*/
size_t count(const T item) const {
size_t total = 0;
for (const_iterator it = this->begin(); it != this->end(); ++it) {
if (*it == item)
++total;
else if (!_comparitor(item, *it))
// Passed beyond possibility of matches
break;
}
return total;
}
};
} // namespace Std
#endif

58
common/std/utility.h Normal file
View File

@@ -0,0 +1,58 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_UTILITY_H
#define COMMON_STD_UTILITY_H
#include "common/util.h"
namespace Std {
template<class T1, class T2>
struct pair {
T1 first;
T2 second;
pair() {
}
pair(T1 first_, T2 second_) : first(first_), second(second_) {
}
};
template< class T1, class T2 >
pair<T1, T2> make_pair(T1 first, T2 second) {
return pair<T1, T2>(first, second);
}
using Common::move;
} // namespace Std
#endif

183
common/std/vector.h Normal file
View File

@@ -0,0 +1,183 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_VECTOR_H
#define COMMON_STD_VECTOR_H
#include "common/array.h"
namespace Std {
template<class T>
class vector : public Common::Array<T> {
public:
struct reverse_iterator {
private:
vector<T> *_owner;
int _index;
public:
reverse_iterator(vector<T> *owner, int index) : _owner(owner), _index(index) {
}
reverse_iterator() : _owner(0), _index(-1) {
}
T &operator*() {
return (*_owner)[_index];
}
reverse_iterator &operator++() {
--_index;
return *this;
}
bool operator==(const reverse_iterator &rhs) {
return _owner == rhs._owner && _index == rhs._index;
}
bool operator!=(const reverse_iterator &rhs) {
return !operator==(rhs);
}
};
struct const_reverse_iterator {
private:
const vector<T> *_owner;
int _index;
public:
const_reverse_iterator(const vector<T> *owner, int index) : _owner(owner), _index(index) {
}
const_reverse_iterator() : _owner(0), _index(-1) {
}
const T operator*() const {
return (*_owner)[_index];
}
const_reverse_iterator &operator++() {
--_index;
return *this;
}
bool operator==(const const_reverse_iterator &rhs) const {
return _owner == rhs._owner && _index == rhs._index;
}
bool operator!=(const const_reverse_iterator &rhs) const {
return !operator==(rhs);
}
bool operator<(const const_reverse_iterator &rhs) const {
return _index > rhs._index;
}
};
public:
using iterator = typename Common::Array<T>::iterator;
using const_iterator = typename Common::Array<T>::const_iterator;
constexpr vector() : Common::Array<T>() {}
explicit vector(size_t newSize) : Common::Array<T>(newSize) {}
vector(size_t newSize, const T &elem) : Common::Array<T>(newSize, elem) {}
vector(std::initializer_list<T> list) : Common::Array<T>(list) {}
using Common::Array<T>::insert;
void insert(const T &element) {
this->push_back(element);
}
/**
* Adds a range of items at the specified position in the array
*/
void insert(iterator position, const_iterator first, const_iterator last) {
int destIndex = position - this->begin();
for (; first != last; ++first) {
this->insert_at(destIndex++, *first);
}
}
T &at(size_t index) {
return (*this)[index];
}
const T &at(size_t index) const {
return (*this)[index];
}
/**
* Remove an element
*/
void remove(T element) {
for (uint i = 0; i < this->size(); ++i) {
if (this->operator[](i) == element) {
this->remove_at(i);
return;
}
}
}
/**
* Rotates the array so that the item pointed to by the iterator becomes
* the first item, and the predeceding item becomes the last one
*/
void rotate(iterator it) {
if (it != this->end()) {
size_t count = it - this->begin();
for (size_t ctr = 0; ctr < count; ++ctr) {
this->push_back(this->front());
this->remove_at(0);
}
}
}
const_iterator cbegin() {
return this->begin();
}
const_iterator cend() {
return this->end();
}
reverse_iterator rbegin() {
return reverse_iterator(this, (int)this->size() - 1);
}
reverse_iterator rend() {
return reverse_iterator(this, -1);
}
const_reverse_iterator rbegin() const {
return const_reverse_iterator(this, (int)this->size() - 1);
}
const_reverse_iterator rend() const {
return const_reverse_iterator(this, -1);
}
const_reverse_iterator crbegin() const {
return const_reverse_iterator(this, (int)this->size() - 1);
}
const_reverse_iterator crend() const {
return const_reverse_iterator(this, -1);
}
};
} // namespace Std
#endif

52
common/std/xtr1common.h Normal file
View File

@@ -0,0 +1,52 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_XTR1COMMON_H
#define COMMON_STD_XTR1COMMON_H
namespace Std {
// STRUCT TEMPLATE conditional
template <bool _Test, class _Ty1, class _Ty2>
struct conditional { // Choose _Ty1 if _Test is true, and _Ty2 otherwise
using type = _Ty1;
};
template <class _Ty1, class _Ty2>
struct conditional<false, _Ty1, _Ty2> {
using type = _Ty2;
};
template <bool _Test, class _Ty1, class _Ty2>
using conditional_t = typename conditional<_Test, _Ty1, _Ty2>::type;
} // namespace Std
#endif

48
common/std/xutility.h Normal file
View File

@@ -0,0 +1,48 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_XUTILITY_H
#define COMMON_STD_XUTILITY_H
#include "common/algorithm.h"
#include "common/util.h"
namespace Std {
template <class T>
void reverse(T *First, T *Last) {
for (--Last; First < Last; ++First, --Last) {
SWAP(*First, *Last);
}
}
} // namespace Std
#endif