summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base')
-rw-r--r--Swiften/Base/Algorithm.h26
-rw-r--r--Swiften/Base/LRUCache.h16
-rw-r--r--Swiften/Base/Override.h34
-rw-r--r--Swiften/Base/SimpleIDGenerator.h7
-rw-r--r--Swiften/Base/StdRandomGenerator.h3
5 files changed, 37 insertions, 49 deletions
diff --git a/Swiften/Base/Algorithm.h b/Swiften/Base/Algorithm.h
index 108dbe3..ee761b7 100644
--- a/Swiften/Base/Algorithm.h
+++ b/Swiften/Base/Algorithm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2014 Isode Limited.
+ * Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -160,4 +160,28 @@ namespace Swift {
return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), pred);
}
+
+ /**
+ * Ranges
+ */
+ template <typename T>
+ class range_t {
+ public:
+ range_t(T b, T e) : b_(b), e_(e) {}
+
+ T begin() {
+ return b_;
+ }
+ T end() {
+ return e_;
+ }
+ private:
+ T b_;
+ T e_;
+ };
+
+ template <typename T>
+ range_t<T> range(T b, T e) {
+ return range_t<T>(b, e);
+ }
}
diff --git a/Swiften/Base/LRUCache.h b/Swiften/Base/LRUCache.h
index e4e652f..1f92612 100644
--- a/Swiften/Base/LRUCache.h
+++ b/Swiften/Base/LRUCache.h
@@ -19,9 +19,9 @@ namespace Swift {
/**
- * The \ref LRUCache templaged class implements a lookup cache which removes
+ * The \ref LRUCache template class implements a lookup cache which removes
* the least recently used cached item from the cache, if the cache size hits
- * the \ref MAX_SIZE limit.
+ * the \p MAX_SIZE limit.
*
* An example use is a cache for entity capabilities hash to DiscoInfo.
*/
@@ -32,9 +32,9 @@ public:
public:
/**
- * Inserts the key/value pair in the front of the cache. If the \ref key
+ * Inserts the key/value pair in the front of the cache. If the \p key
* already exists in the cache, it is moved to the front instead. If
- * afterwards, the cahe size exceeds the \ref MAX_SIZE limit, the least
+ * afterwards, the cahe size exceeds the \p MAX_SIZE limit, the least
* recently item is removed from the cache.
*/
void insert(const KEY_TYPE& key, VALUE_TYPE value) {
@@ -48,11 +48,11 @@ public:
}
/**
- * Looks up a cache entry based on the provided \ref key and moves it back
+ * Looks up a cache entry based on the provided \p key and moves it back
* to the front of the cache. If there is no cache entry for the provided
- * \ref key, an uninitialized \ref boost::optional is returned.
- * If the optional \ref missFunction is provided, it is called on a cache miss.
- * If the \ref missFunction returns an initialized \ref boost::optional, the
+ * \p key, an uninitialized \p boost::optional is returned.
+ * If the optional \p missFunction is provided, it is called on a cache miss.
+ * If the \p missFunction returns an initialized \p boost::optional, the
* value is inserted in the cache.
*/
boost::optional<VALUE_TYPE> get(const KEY_TYPE& key, cacheMissFunction missFunction = cacheMissFunction()) {
diff --git a/Swiften/Base/Override.h b/Swiften/Base/Override.h
deleted file mode 100644
index 2806aae..0000000
--- a/Swiften/Base/Override.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#pragma once
-
-#if defined(__clang__)
-# if __has_feature(cxx_override_control) || __has_extension(cxx_override_control)
-# define SWIFTEN_OVERRIDE override
-# else
-# define SWIFTEN_OVERRIDE
-# endif
-
-#elif defined(__GNUC__)
-# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) && defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define SWIFTEN_OVERRIDE override
-# else
-# define SWIFTEN_OVERRIDE
-# endif
-
-#elif defined(_MSC_VER)
-// Actually, 1700 is the first version that supports the C++11 override, but
-// older versions apparently support a similar keyword.
-# if _MSC_VER >= 1400
-# define SWIFTEN_OVERRIDE override
-# else
-# define SWIFTEN_OVERRIDE
-# endif
-
-#else
-# define SWIFTEN_OVERRIDE
-#endif
diff --git a/Swiften/Base/SimpleIDGenerator.h b/Swiften/Base/SimpleIDGenerator.h
index ff645b1..09e01de 100644
--- a/Swiften/Base/SimpleIDGenerator.h
+++ b/Swiften/Base/SimpleIDGenerator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,7 +10,6 @@
#include <Swiften/Base/API.h>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/Override.h>
namespace Swift {
@@ -22,9 +21,9 @@ namespace Swift {
class SWIFTEN_API SimpleIDGenerator : public IDGenerator {
public:
SimpleIDGenerator();
- ~SimpleIDGenerator();
+ ~SimpleIDGenerator() override;
- std::string generateID() SWIFTEN_OVERRIDE;
+ std::string generateID() override;
private:
std::string currentID;
diff --git a/Swiften/Base/StdRandomGenerator.h b/Swiften/Base/StdRandomGenerator.h
index 4cc5e95..159d361 100644
--- a/Swiften/Base/StdRandomGenerator.h
+++ b/Swiften/Base/StdRandomGenerator.h
@@ -9,7 +9,6 @@
#include <random>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/Override.h>
#include <Swiften/Base/RandomGenerator.h>
namespace Swift {
@@ -17,7 +16,7 @@ namespace Swift {
public:
StdRandomGenerator();
- int generateRandomInteger(int max) SWIFTEN_OVERRIDE;
+ int generateRandomInteger(int max) override;
private:
std::mt19937 generator;