summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06908fe)
raw | patch | inline | side by side (parent: 06908fe)
author | tweenk <tweenk@users.sourceforge.net> | |
Wed, 25 Feb 2009 22:52:12 +0000 (22:52 +0000) | ||
committer | tweenk <tweenk@users.sourceforge.net> | |
Wed, 25 Feb 2009 22:52:12 +0000 (22:52 +0000) |
src/util/glib-list-iterators.h | patch | blob | history |
index 3779cad1e4c46a819459b0fe5b53f3a365b34dc6..586bc314a9321db3db3de3fc2a5e86a605e3a770 100644 (file)
-/** @file
- * @brief STL iterators for Glib list types
- */
-/* Inkscape::Util::GSListIterator - STL iterator for GSList
+/*
+ * Inkscape::Util::GSListIterator - STL iterator for GSList
* Inkscape::Util::GSListConstIterator - STL iterator for GSList
* Inkscape::Util::GListIterator - STL iterator for GList
* Inkscape::Util::GListConstIterator - STL iterator for GList
*
* Authors:
* MenTaLguY <mental@rydia.net>
- * Krzysztof KosiĆski <tweenk.pl@gmail.com>
*
* Copyright (C) 2005 MenTaLguY
*
#include "glib/glist.h"
namespace Inkscape {
+
namespace Util {
template <typename T> class GSListConstIterator;
GSList const *list() const { return _list; }
reference operator*() const {
- _ref_union u;
- u._gp = _list->data;
- return *u._p;
+ return *reinterpret_cast<pointer>(&_list->data);
}
bool operator==(GSListConstIterator const &other) {
}
private:
- union _ref_union {gpointer _gp; pointer _p;};
GSList const *_list;
};
GSList *list() { return _list; }
const_reference operator*() const {
- return const_cast<GSListIterator<T *> *>(this)->operator*();
+ return *reinterpret_cast<pointer>(&_list->data);
}
reference operator*() {
- _ref_union u;
- u._gp = _list->data;
- return *u._p;
+ return *reinterpret_cast<pointer>(&_list->data);
}
bool operator==(GSListIterator const &other) {
}
private:
- union _ref_union {gpointer _gp; pointer _p;};
GSList *_list;
};
GList const *list() const { return _list; }
reference operator*() const {
- _ref_union u;
- u._gp = _list->data;
- return *u._p;
+ return *reinterpret_cast<pointer>(&_list->data);
}
bool operator==(GListConstIterator const &other) {
}
private:
- union _ref_union {gpointer _gp; pointer _p;};
GList const *_list;
};
GList *list() { return _list; }
const_reference operator*() const {
- return const_cast<GListIterator<T *> *>(this)->operator*();
- }
- reference operator*() {
- _ref_union u;
- u._gp = _list->data;
- return *u._p;
+ return *reinterpret_cast<pointer>(&_list->data);
}
+ reference operator*() { return *reinterpret_cast<pointer>(&_list->data); }
bool operator==(GListIterator const &other) {
return other._list == _list;
}
private:
- union _ref_union {gpointer _gp; pointer _p;};
GList *_list;
};
-} // namespace Util
-} // Namespace Inkscape
+}
+
+}
#endif
/*