summaryrefslogtreecommitdiff
path: root/src/generic
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-04-24 16:13:40 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-04-24 16:49:05 -0700
commitc093f4cce643e245ab2048e0782237744208eb9f (patch)
treeedcfb0fbdd57acc1df658d30fe4c87663d938044 /src/generic
parent5cbd4c728046b4b12d289bf9b7edbc2c7b589fca (diff)
downloadtmwa-c093f4cce643e245ab2048e0782237744208eb9f.tar.gz
tmwa-c093f4cce643e245ab2048e0782237744208eb9f.tar.bz2
tmwa-c093f4cce643e245ab2048e0782237744208eb9f.tar.xz
tmwa-c093f4cce643e245ab2048e0782237744208eb9f.zip
Header cleanup
Diffstat (limited to 'src/generic')
-rw-r--r--src/generic/array.cpp21
-rw-r--r--src/generic/array.hpp41
-rw-r--r--src/generic/enum.hpp2
-rw-r--r--src/generic/intern-pool.hpp1
-rw-r--r--src/generic/intern-pool_test.cpp2
-rw-r--r--src/generic/md5.cpp5
-rw-r--r--src/generic/md5.hpp4
-rw-r--r--src/generic/random.hpp2
8 files changed, 66 insertions, 12 deletions
diff --git a/src/generic/array.cpp b/src/generic/array.cpp
new file mode 100644
index 0000000..96c85ac
--- /dev/null
+++ b/src/generic/array.cpp
@@ -0,0 +1,21 @@
+#include "array.hpp"
+// array.cpp - A simple bounds-checked array.
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// 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/>.
+
+#include "../poison.hpp"
diff --git a/src/generic/array.hpp b/src/generic/array.hpp
new file mode 100644
index 0000000..e6fefae
--- /dev/null
+++ b/src/generic/array.hpp
@@ -0,0 +1,41 @@
+#ifndef TMWA_GENERIC_ARRAY_HPP
+#define TMWA_GENERIC_ARRAY_HPP
+// array.hpp - A simple bounds-checked array.
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// 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/>.
+
+# include "fwd.hpp"
+
+# include <cassert>
+# include <cstddef>
+
+template<class T, size_t n>
+struct Array
+{
+ T data[n];
+public:
+ T& operator [](size_t i) { assert (i < n); return data[i]; }
+ const T& operator [](size_t i) const { assert (i < n); return data[i]; }
+
+ T *begin() { return data + 0; }
+ T *end() { return data + n; }
+ const T *begin() const { return data + 0; }
+ const T *end() const { return data + n; }
+};
+
+#endif // TMWA_GENERIC_ARRAY_HPP
diff --git a/src/generic/enum.hpp b/src/generic/enum.hpp
index bf0ac74..5f075bc 100644
--- a/src/generic/enum.hpp
+++ b/src/generic/enum.hpp
@@ -22,6 +22,7 @@
# include "fwd.hpp"
# include <cassert>
+# include <cstddef>
# include <algorithm>
# include <type_traits>
@@ -124,6 +125,7 @@ public:
// std::underlying_type isn't supported until gcc 4.7
// this is a poor man's emulation
+// TODO I'm depending on GCC 4.7 now, this can go away
template<class E>
struct underlying_type
{
diff --git a/src/generic/intern-pool.hpp b/src/generic/intern-pool.hpp
index b9fc38c..62a1d7f 100644
--- a/src/generic/intern-pool.hpp
+++ b/src/generic/intern-pool.hpp
@@ -22,6 +22,7 @@
# include "fwd.hpp"
# include <cassert>
+# include <cstddef>
# include <map>
# include <vector>
diff --git a/src/generic/intern-pool_test.cpp b/src/generic/intern-pool_test.cpp
index 3207792..f53e31d 100644
--- a/src/generic/intern-pool_test.cpp
+++ b/src/generic/intern-pool_test.cpp
@@ -20,7 +20,7 @@
#include <gtest/gtest.h>
-#include "../strings/base.hpp"
+#include "../strings/literal.hpp"
#include "../poison.hpp"
diff --git a/src/generic/md5.cpp b/src/generic/md5.cpp
index b49d36f..38a605c 100644
--- a/src/generic/md5.cpp
+++ b/src/generic/md5.cpp
@@ -18,14 +18,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <cstring>
-
#include "../compat/rawmem.hpp"
#include "../strings/xstring.hpp"
-#include "../strings/vstring.hpp"
-
-#include "random.hpp"
#include "../poison.hpp"
diff --git a/src/generic/md5.hpp b/src/generic/md5.hpp
index 071c08b..fd23eca 100644
--- a/src/generic/md5.hpp
+++ b/src/generic/md5.hpp
@@ -21,11 +21,7 @@
# include "fwd.hpp"
-# include <netinet/in.h>
-
# include <cstdint>
-# include <cstddef>
-# include <cstdio>
# include <array>
diff --git a/src/generic/random.hpp b/src/generic/random.hpp
index 2fb2632..3b27b36 100644
--- a/src/generic/random.hpp
+++ b/src/generic/random.hpp
@@ -23,8 +23,6 @@
# include "random.t.hpp"
-# include "fwd.hpp"
-
# include <random>
// This is not namespace random since that collides with a C function,