summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 21:05:46 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 21:05:46 +0000
commit2ae87e72131a8e88327dbb0b5b286accddafe05d (patch)
treeec755c0d0c31cbcb470d0df2625db8614efca6b2 /src/core
parent9b6b2cabc187f3cb72a53d396418ab1b9ebd2933 (diff)
downloadopenttd-2ae87e72131a8e88327dbb0b5b286accddafe05d.tar.xz
(svn r23634) -Add: support language files for GameScript (Rubidium)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/smallvec_type.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index 00fb7c5a0..40793788d 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -326,6 +326,37 @@ public:
}
};
+/**
+ * Simple vector template class, with automatic delete.
+ *
+ * @note There are no asserts in the class so you have
+ * to care about that you grab an item which is
+ * inside the list.
+ *
+ * @param T The type of the items stored, must be a pointer
+ * @param S The steps of allocation
+ */
+template <typename T, uint S>
+class AutoDeleteSmallVector : public SmallVector<T, S> {
+public:
+ ~AutoDeleteSmallVector()
+ {
+ this->Clear();
+ }
+
+ /**
+ * Remove all items from the list.
+ */
+ FORCEINLINE void Clear()
+ {
+ for (uint i = 0; i < this->items; i++) {
+ delete this->data[i];
+ }
+
+ this->items = 0;
+ }
+};
+
typedef AutoFreeSmallVector<char*, 4> StringList; ///< Type for a list of strings.
#endif /* SMALLVEC_TYPE_HPP */