aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDavid Corrales2007-08-05 19:34:20 +0000
committerDavid Corrales2007-08-05 19:34:20 +0000
commit6856535010bd2fa4449bcfde1c88dc06cd46e26f (patch)
treeb81a2234c2beff0312c93e039d6cafda4babeca6 /common
parent1400d28bfb37fc94f3c44dec0a4d0cef65fb8fb7 (diff)
parentec1803f838d5efc7decf75c05a1fb4a9633751e5 (diff)
downloadscummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.gz
scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.bz2
scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.zip
Merged fsnode with trunk: r27971:28460
svn-id: r28462
Diffstat (limited to 'common')
-rw-r--r--common/file.h2
-rw-r--r--common/list.h58
-rw-r--r--common/util.cpp13
-rw-r--r--common/util.h1
4 files changed, 43 insertions, 31 deletions
diff --git a/common/file.h b/common/file.h
index d2eae1f28c..c18776a377 100644
--- a/common/file.h
+++ b/common/file.h
@@ -30,8 +30,6 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "common/stream.h"
-#include "backends/file/base-file.h"
-//#include "backends/factories/fs-factory-maker.cpp"
class FilesystemNode;
diff --git a/common/list.h b/common/list.h
index 1fda266da9..4ece453711 100644
--- a/common/list.h
+++ b/common/list.h
@@ -33,7 +33,7 @@ namespace Common {
* Simple double linked list, modeled after the list template of the standard
* C++ library.
*/
-template <class T>
+template <class t_T>
class List {
protected:
#if defined (_WIN32_WCE) || defined (_MSC_VER)
@@ -45,16 +45,16 @@ public:
NodeBase *_next;
};
- template <class T2>
+ template <class t_T2>
struct Node : public NodeBase {
- T2 _data;
+ t_T2 _data;
- Node(const T2 &x) : _data(x) {}
+ Node(const t_T2 &x) : _data(x) {}
};
- template <class T2>
+ template <class t_T2>
class Iterator {
- friend class List<T>;
+ friend class List<t_T>;
NodeBase *_node;
#if !defined (__WINSCW__)
@@ -67,46 +67,46 @@ public:
Iterator() : _node(0) {}
// Prefix inc
- Iterator<T2> &operator++() {
+ Iterator<t_T2> &operator++() {
if (_node)
_node = _node->_next;
return *this;
}
// Postfix inc
- Iterator<T2> operator++(int) {
+ Iterator<t_T2> operator++(int) {
Iterator tmp(_node);
++(*this);
return tmp;
}
// Prefix dec
- Iterator<T2> &operator--() {
+ Iterator<t_T2> &operator--() {
if (_node)
_node = _node->_prev;
return *this;
}
// Postfix dec
- Iterator<T2> operator--(int) {
+ Iterator<t_T2> operator--(int) {
Iterator tmp(_node);
--(*this);
return tmp;
}
- T2& operator*() const {
+ t_T2& operator*() const {
assert(_node);
#if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)
- return static_cast<List<T>::Node<T2> *>(_node)->_data;
+ return static_cast<List<t_T>::Node<t_T2> *>(_node)->_data;
#else
- return static_cast<Node<T2>*>(_node)->_data;
+ return static_cast<Node<t_T2>*>(_node)->_data;
#endif
}
- T2* operator->() const {
+ t_T2* operator->() const {
return &(operator*());
}
- bool operator==(const Iterator<T2>& x) const {
+ bool operator==(const Iterator<t_T2>& x) const {
return _node == x._node;
}
- bool operator!=(const Iterator<T2>& x) const {
+ bool operator!=(const Iterator<t_T2>& x) const {
return _node != x._node;
}
};
@@ -114,10 +114,10 @@ public:
NodeBase *_anchor;
public:
- typedef Iterator<T> iterator;
- typedef Iterator<const T> const_iterator;
+ typedef Iterator<t_T> iterator;
+ typedef Iterator<const t_T> const_iterator;
- typedef T value_type;
+ typedef t_T value_type;
public:
List() {
@@ -125,7 +125,7 @@ public:
_anchor->_prev = _anchor;
_anchor->_next = _anchor;
}
- List(const List<T>& list) {
+ List(const List<t_T>& list) {
_anchor = new NodeBase;
_anchor->_prev = _anchor;
_anchor->_next = _anchor;
@@ -138,16 +138,16 @@ public:
delete _anchor;
}
- void push_front(const T& element) {
+ void push_front(const t_T& element) {
insert(begin(), element);
}
- void push_back(const T& element) {
+ void push_back(const t_T& element) {
insert(end(), element);
}
- void insert(iterator pos, const T& element) {
- NodeBase *newNode = new Node<T>(element);
+ void insert(iterator pos, const t_T& element) {
+ NodeBase *newNode = new Node<t_T>(element);
newNode->_next = pos._node;
newNode->_prev = pos._node->_prev;
@@ -166,7 +166,7 @@ public:
NodeBase *next = pos._node->_next;
NodeBase *prev = pos._node->_prev;
- Node<T> *node = static_cast<Node<T> *>(pos._node);
+ Node<t_T> *node = static_cast<Node<t_T> *>(pos._node);
prev->_next = next;
next->_prev = prev;
delete node;
@@ -178,7 +178,7 @@ public:
NodeBase *next = pos._node->_next;
NodeBase *prev = pos._node->_prev;
- Node<T> *node = static_cast<Node<T> *>(pos._node);
+ Node<t_T> *node = static_cast<Node<t_T> *>(pos._node);
prev->_next = next;
next->_prev = prev;
delete node;
@@ -192,7 +192,7 @@ public:
return last;
}
- void remove(const T &val) {
+ void remove(const t_T &val) {
iterator i = begin();
while (i != end())
if (val == i.operator*())
@@ -202,13 +202,13 @@ public:
}
- List<T>& operator =(const List<T>& list) {
+ List<t_T>& operator =(const List<t_T>& list) {
if (this != &list) {
iterator i;
const_iterator j;
for (i = begin(), j = list.begin(); (i != end()) && (j != list.end()) ; ++i, ++j) {
- static_cast<Node<T> *>(i._node)->_data = static_cast<Node<T> *>(j._node)->_data;
+ static_cast<Node<t_T> *>(i._node)->_data = static_cast<Node<t_T> *>(j._node)->_data;
}
if (i == end())
diff --git a/common/util.cpp b/common/util.cpp
index fc5fe9a4e5..b38dfa6664 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -592,3 +592,16 @@ void CDECL warning(const char *s, ...) {
#endif
#endif
}
+
+char *scumm_strrev(char *str) {
+ if (!str)
+ return str;
+ int len = strlen(str);
+ if (len < 2)
+ return str;
+ char *p1, *p2;
+ for (p1 = str, p2 = str + len - 1; p1 < p2; p1++, p2--) {
+ SWAP(*p1, *p2);
+ }
+ return str;
+}
diff --git a/common/util.h b/common/util.h
index 2325ba523a..0d63af0878 100644
--- a/common/util.h
+++ b/common/util.h
@@ -289,5 +289,6 @@ void CDECL debugC(int level, uint32 engine_level, const char *s, ...) GCC_PRINTF
extern int gDebugLevel;
+char *scumm_strrev(char *str);
#endif