You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/06/06 17:56:47 UTC
[21/23] geode-native git commit: GEODE-2741: Code cleanup to move to
std::shared_ptr
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/Struct.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Struct.hpp b/src/cppcache/include/geode/Struct.hpp
index 13411f0..08374dd 100644
--- a/src/cppcache/include/geode/Struct.hpp
+++ b/src/cppcache/include/geode/Struct.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STRUCT_H_
-#define GEODE_STRUCT_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,14 +15,22 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_STRUCT_H_
+#define GEODE_STRUCT_H_
+
+#include <unordered_map>
+#include <vector>
+
+#include <geode/utils.hpp>
+
#include "geode_globals.hpp"
#include "geode_types.hpp"
#include "CacheableBuiltins.hpp"
#include "StructSet.hpp"
#include "SelectResults.hpp"
#include "Serializable.hpp"
-#include "VectorT.hpp"
-#include "HashMapT.hpp"
/**
* @file
@@ -50,7 +53,7 @@ class CPPCACHE_EXPORT Struct : public Serializable {
/**
* Constructor - meant only for internal use.
*/
- Struct(StructSet* ssPtr, VectorT<SerializablePtr>& fieldValues);
+ Struct(StructSet* ssPtr, std::vector<SerializablePtr>& fieldValues);
/**
* Factory function for registration of <code>Struct</code>.
@@ -135,7 +138,7 @@ class CPPCACHE_EXPORT Struct : public Serializable {
* Returns the name of the field corresponding to the index number in the
* Struct
*/
- virtual const char* getFieldName(int32_t index);
+ virtual const char* getFieldName(const int32_t index) const;
/**
* always returns 0
@@ -149,8 +152,12 @@ class CPPCACHE_EXPORT Struct : public Serializable {
Struct();
- HashMapT<CacheableStringPtr, CacheableInt32Ptr> m_fieldNames;
- VectorT<SerializablePtr> m_fieldValues;
+ typedef std::unordered_map<CacheableStringPtr, CacheableInt32Ptr,
+ dereference_hash<CacheableStringPtr>,
+ dereference_equal_to<CacheableStringPtr>>
+ FieldNames;
+ FieldNames m_fieldNames;
+ std::vector<SerializablePtr> m_fieldValues;
StructSet* m_parent;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/StructSet.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/StructSet.hpp b/src/cppcache/include/geode/StructSet.hpp
index 025a178..b2b6376 100644
--- a/src/cppcache/include/geode/StructSet.hpp
+++ b/src/cppcache/include/geode/StructSet.hpp
@@ -80,7 +80,7 @@ class CPPCACHE_EXPORT StructSet : public CqResults {
* Get the field name of the StructSet from the specified index number.
*
* @param index the index number of the field name to get.
- * @returns the field name from the specified index number or NULL if not
+ * @returns the field name from the specified index number or nullptr if not
* found.
*/
virtual const char* getFieldName(int32_t index) = 0;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/SystemProperties.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/SystemProperties.hpp b/src/cppcache/include/geode/SystemProperties.hpp
index 7dc6131..0e8ded2 100644
--- a/src/cppcache/include/geode/SystemProperties.hpp
+++ b/src/cppcache/include/geode/SystemProperties.hpp
@@ -25,7 +25,7 @@
#include "AuthInitialize.hpp"
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -42,10 +42,10 @@ typedef AuthInitialize* (*LibraryAuthInitializeFn)(const char* assemblyPath,
const char* factFuncName);
/**
- * A class for internal use, that encapsulates the properties that can be
- * set from DistributedSystem::connect.
- *
- */
+ * A class for internal use, that encapsulates the properties that can be
+ * set from DistributedSystem::connect.
+ *
+ */
class CPPCACHE_EXPORT SystemProperties {
public:
@@ -58,7 +58,7 @@ class CPPCACHE_EXPORT SystemProperties {
* member type to SERVER.
*/
SystemProperties(const PropertiesPtr& propertiesPtr,
- const char* configFile = NULL);
+ const char* configFile = nullptr);
/**
* Destructor.
@@ -97,8 +97,8 @@ class CPPCACHE_EXPORT SystemProperties {
} /*m_timestatisticsEnabled*/
/**
- * Returns the path of the private key file for SSL use.
- */
+ * Returns the path of the private key file for SSL use.
+ */
const char* sslKeyStore() const { return m_sslKeyStore; }
/**
@@ -140,19 +140,19 @@ class CPPCACHE_EXPORT SystemProperties {
const bool heapLRULimitEnabled() const { return (m_heapLRULimit > 0); }
/**
- * Returns the HeapLRULimit value (in bytes), the maximum memory that values
- * in a cache can use to store data before overflowing to disk or destroying
- * entries to ensure that the server process never runs out of memory due to
- * cache memory usage
- *
- */
+ * Returns the HeapLRULimit value (in bytes), the maximum memory that values
+ * in a cache can use to store data before overflowing to disk or destroying
+ * entries to ensure that the server process never runs out of memory due to
+ * cache memory usage
+ *
+ */
const size_t heapLRULimit() const { return m_heapLRULimit; }
/**
- * Returns the HeapLRUDelta value (a percent value). This specifies the
- * percentage of entries the system will evict each time it detects that
- * it has exceeded the HeapLRULimit. Defaults to 10%
- */
+ * Returns the HeapLRUDelta value (a percent value). This specifies the
+ * percentage of entries the system will evict each time it detects that
+ * it has exceeded the HeapLRULimit. Defaults to 10%
+ */
const int32_t heapLRUDelta() const { return m_heapLRUDelta; }
/**
* Returns the maximum socket buffer size to use
@@ -176,9 +176,9 @@ class CPPCACHE_EXPORT SystemProperties {
const int32_t notifyAckInterval() const { return m_notifyAckInterval; }
/**
- * Returns the expiry time of an idle event id map entry for duplicate
- * notification checking
- */
+ * Returns the expiry time of an idle event id map entry for duplicate
+ * notification checking
+ */
const int32_t notifyDupCheckLife() const { return m_notifyDupCheckLife; }
/**
@@ -197,15 +197,15 @@ class CPPCACHE_EXPORT SystemProperties {
const uint32_t connectTimeout() const { return m_connectTimeout; }
/**
- * Returns the connect wait timeout(in millis) used for to connect to server
- * This is only applicable for linux
- */
+ * Returns the connect wait timeout(in millis) used for to connect to server
+ * This is only applicable for linux
+ */
const uint32_t connectWaitTimeout() const { return m_connectWaitTimeout; }
/**
- * Returns the connect wait timeout(in millis) used for to connect to server
- * This is only applicable for linux
- */
+ * Returns the connect wait timeout(in millis) used for to connect to server
+ * This is only applicable for linux
+ */
const uint32_t bucketWaitTimeout() const { return m_bucketWaitTimeout; }
/**
@@ -214,8 +214,8 @@ class CPPCACHE_EXPORT SystemProperties {
char* conflateEvents() { return m_conflateEvents; }
/**
- * Returns true if the stack trace is enabled ,false otherwise
- */
+ * Returns true if the stack trace is enabled ,false otherwise
+ */
const bool debugStackTraceEnabled() const { return m_debugStackTraceEnabled; }
/**
@@ -234,23 +234,23 @@ class CPPCACHE_EXPORT SystemProperties {
const char* cacheXMLFile() const { return m_cacheXMLFile; }
/**
- * Returns the log-file-size-limit.
- */
+ * Returns the log-file-size-limit.
+ */
const uint32_t logFileSizeLimit() const { return m_logFileSizeLimit; }
/**
- * Returns the log-disk-space-limit.
- */
+ * Returns the log-disk-space-limit.
+ */
const uint32_t logDiskSpaceLimit() const { return m_logDiskSpaceLimit; }
/**
- * Returns the stat-file-space-limit.
- */
+ * Returns the stat-file-space-limit.
+ */
const uint32_t statsFileSizeLimit() const { return m_statsFileSizeLimit; }
/**
- * Returns the stat-disk-size-limit.
- */
+ * Returns the stat-disk-size-limit.
+ */
const uint32_t statsDiskSpaceLimit() const { return m_statsDiskSpaceLimit; }
const uint32_t maxQueueSize() { return m_maxQueueSize; }
@@ -282,9 +282,9 @@ class CPPCACHE_EXPORT SystemProperties {
}
/**
- * returns true if app want to clear pdx type ids when client disconnect.
- * deafult is false.
- */
+ * returns true if app want to clear pdx type ids when client disconnect.
+ * deafult is false.
+ */
bool onClientDisconnectClearPdxTypeIds() const {
return m_onClientDisconnectClearPdxTypeIds;
}
@@ -327,14 +327,14 @@ class CPPCACHE_EXPORT SystemProperties {
/** Returns securityPropertiesPtr.
* @return PropertiesPtr value.
- */
+ */
PropertiesPtr getSecurityProperties() const {
return m_securityPropertiesPtr;
}
/** Checks whether Security is on or off.
* @return bool value.
- */
+ */
inline bool isSecurityOn() const {
return (m_AuthIniLoaderFactory != nullptr &&
m_AuthIniLoaderLibrary != nullptr);
@@ -342,7 +342,7 @@ class CPPCACHE_EXPORT SystemProperties {
/** Checks whether list of endpoint is shuffeled or not.
* @return bool value.
- */
+ */
inline bool isEndpointShufflingDisabled() const {
return m_disableShufflingEndpoint;
}
@@ -392,8 +392,8 @@ class CPPCACHE_EXPORT SystemProperties {
inline bool autoReadyForEvents() const { return m_autoReadyForEvents; }
/**
- * Returns the timeout after which suspended transactions are rolled back.
- */
+ * Returns the timeout after which suspended transactions are rolled back.
+ */
const uint32_t suspendedTxTimeout() const { return m_suspendedTxTimeout; }
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/VectorT.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/VectorT.hpp b/src/cppcache/include/geode/VectorT.hpp
index b223112..d3225a5 100644
--- a/src/cppcache/include/geode/VectorT.hpp
+++ b/src/cppcache/include/geode/VectorT.hpp
@@ -20,245 +20,26 @@
#ifndef GEODE_VECTORT_H_
#define GEODE_VECTORT_H_
-// TODO shared_ptr - replace with std::vector
+#include <vector>
+#include <memory>
#include "geode_globals.hpp"
-#include "VectorOfSharedBase.hpp"
#include "Cacheable.hpp"
#include "CacheableKey.hpp"
-/** @file
-*/
-
namespace apache {
namespace geode {
namespace client {
-/** Vector template type class */
-template <class PTR_TYPE>
-class VectorT {
- private:
- VectorOfSharedBase m_vector;
-
- public:
- /** Interface of an iterator for <code>VectorT</code>.*/
- class Iterator {
- private:
- VectorOfSharedBase::Iterator m_iter;
-
- inline Iterator(const VectorOfSharedBase::Iterator& iter) : m_iter(iter) {}
-
- // Never defined.
- Iterator();
-
- public:
- inline const PTR_TYPE operator*() const {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(*m_iter);
- }
-
- inline Iterator& operator++() {
- ++m_iter;
- return *this;
- }
-
- inline void operator++(int) { m_iter++; }
-
- inline bool operator==(const Iterator& other) const {
- return (m_iter == other.m_iter);
- }
-
- inline bool operator!=(const Iterator& other) const {
- return (m_iter != other.m_iter);
- }
-
- friend class VectorT;
- };
-
- /** return the size of the vector. */
- inline int32_t size() const { return static_cast<int32_t>(m_vector.size()); }
-
- /** synonym for size. */
- inline int32_t length() const {
- return static_cast<int32_t>(m_vector.size());
- }
-
- /** return the largest possible size of the vector. */
- inline int32_t max_size() const {
- return static_cast<int32_t>(m_vector.max_size());
- }
-
- /** return the number of elements allocated for this vector. */
- inline int32_t capacity() const {
- return static_cast<int32_t>(m_vector.capacity());
- }
-
- /** return true if the vector's size is 0. */
- inline bool empty() const { return m_vector.empty(); }
-
- /** Return the n'th element */
- inline PTR_TYPE operator[](int32_t n) {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector[n]);
- }
-
- /** Return the n'th element */
- inline const PTR_TYPE operator[](int32_t n) const {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector[n]);
- }
-
- /** Return the n'th element with bounds checking. */
- inline PTR_TYPE at(int32_t n) {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.at(n));
- }
-
- /** Return the n'th element with bounds checking. */
- inline const PTR_TYPE at(int32_t n) const {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.at(n));
- }
-
- /** Get an iterator pointing to the start of vector. */
- inline Iterator begin() const { return Iterator(m_vector.begin()); }
-
- /** Get an iterator pointing to the end of vector. */
- inline Iterator end() const { return Iterator(m_vector.end()); }
-
- /** Create an empty vector. */
- inline VectorT() : m_vector() {}
-
- /** Create a vector with n elements allocated */
- inline VectorT(int32_t n) : m_vector(n) {}
-
- /** Create a vector with n copies of t */
- inline VectorT(int32_t n, const PTR_TYPE& t) : m_vector(n, t) {}
-
- /** copy constructor */
- inline VectorT(const VectorT& other) : m_vector(other.m_vector) {}
-
- /** destructor, sets all SharedPtr elements to nullptr */
- inline ~VectorT() {
- // destructor of m_vector field does all the work.
- }
-
- /** assignment operator */
- inline VectorT& operator=(const VectorT& other) {
- m_vector = other.m_vector;
- return *this;
- }
-
- /** reallocate a vector to hold n elements. */
- inline void reserve(int32_t n) { m_vector.reserve(n); }
-
- /** returns the first element. */
- inline PTR_TYPE front() {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.front());
- }
-
- /** returns the first element. */
- inline const PTR_TYPE front() const {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.front());
- }
-
- /** returns the last element. */
- inline PTR_TYPE back() {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.back());
- }
-
- /** returns the last element. */
- inline const PTR_TYPE back() const {
- return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.back());
- }
-
- /** insert a new element at the end. */
- inline void push_back(const PTR_TYPE& e) { m_vector.push_back(e); }
-
- /** removes the last element. */
- inline void pop_back() { m_vector.pop_back(); }
-
- /** swaps the contents of two vectors. */
- inline void swap(VectorT& other) { m_vector.swap(other.m_vector); }
-
- /** erases all elements. */
- inline void clear() { m_vector.clear(); }
-
- /** inserts or erases elements at the end such that size becomes n.
- * Not to be confused with reserve which simply allocates the space,
- * resize fills the space with active elements. */
- inline void resize(int32_t n, const PTR_TYPE& t = nullptr) {
- m_vector.resize(n, t);
- }
-
- /** insert object at the given position. */
- inline void insert(int32_t index, const PTR_TYPE& t) {
- m_vector.insert(index, t);
- }
-
- /** Removes the object at the specified index from a vector. */
- inline void erase(int32_t index) { m_vector.erase(index); }
-};
-
-typedef VectorT<CacheablePtr> _VectorOfCacheable;
-typedef VectorT<CacheableKeyPtr> _VectorOfCacheableKey;
-typedef VectorT<RegionEntryPtr> VectorOfRegionEntry;
-typedef VectorT<RegionPtr> VectorOfRegion;
-typedef VectorT<CacheableStringPtr> VectorOfCacheableString;
-
-/**
- * A vector of <code>Cacheable</code> objects that also extends
- * <code>SharedBase</code> for smart pointers.
- */
-class CPPCACHE_EXPORT VectorOfCacheable : public _VectorOfCacheable,
- public SharedBase {
- public:
- /** Iterator class for the vector. */
- typedef _VectorOfCacheable::Iterator Iterator;
-
- /** Create an empty vector. */
- inline VectorOfCacheable() : _VectorOfCacheable() {}
-
- /** Create a vector with n elements allocated. */
- inline VectorOfCacheable(int32_t n) : _VectorOfCacheable(n) {}
-
- /** Create a vector with n copies of t. */
- inline VectorOfCacheable(int32_t n, const CacheablePtr& t)
- : _VectorOfCacheable(n, t) {}
-
- /** Copy constructor. */
- inline VectorOfCacheable(const VectorOfCacheable& other)
- : _VectorOfCacheable(other) {}
-
- private:
- const VectorOfCacheable& operator=(const VectorOfCacheable&);
-};
-
-/**
- * A vector of <code>CacheableKey</code> objects that also extends
- * <code>SharedBase</code> for smart pointers.
- */
-class CPPCACHE_EXPORT VectorOfCacheableKey : public _VectorOfCacheableKey,
- public SharedBase {
- public:
- /** Iterator class for the vector. */
- typedef _VectorOfCacheableKey::Iterator Iterator;
-
- /** Create an empty vector. */
- inline VectorOfCacheableKey() : _VectorOfCacheableKey() {}
-
- /** Create a vector with n elements allocated */
- inline VectorOfCacheableKey(int32_t n) : _VectorOfCacheableKey(n) {}
-
- /** Create a vector with n copies of t */
- inline VectorOfCacheableKey(int32_t n, const CacheableKeyPtr& t)
- : _VectorOfCacheableKey(n, t) {}
-
- /** Copy constructor */
- inline VectorOfCacheableKey(const VectorOfCacheableKey& other)
- : _VectorOfCacheableKey(other) {}
-
- private:
- const VectorOfCacheableKey& operator=(const VectorOfCacheableKey&);
-};
+// TODO move to more appropriate location
+typedef std::vector<RegionEntryPtr> VectorOfRegionEntry;
+typedef std::vector<RegionPtr> VectorOfRegion;
+typedef std::vector<CacheablePtr> VectorOfCacheable;
+typedef std::shared_ptr<VectorOfCacheable> VectorOfCacheablePtr;
+typedef std::vector<CacheableKeyPtr> VectorOfCacheableKey;
+typedef std::shared_ptr<VectorOfCacheableKey> VectorOfCacheableKeyPtr;
+typedef std::vector<CacheableStringPtr> VectorOfCacheableString;
-typedef SharedPtr<VectorOfCacheable> VectorOfCacheablePtr;
-typedef SharedPtr<VectorOfCacheableKey> VectorOfCacheableKeyPtr;
} // namespace client
} // namespace geode
} // namespace apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/geode_base.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/geode_base.hpp b/src/cppcache/include/geode/geode_base.hpp
index dc0bc80..d506d22 100644
--- a/src/cppcache/include/geode/geode_base.hpp
+++ b/src/cppcache/include/geode/geode_base.hpp
@@ -304,14 +304,14 @@ void operator delete[](void *p);
#define GF_SAFE_DELETE(x) \
{ \
delete x; \
- x = NULL; \
+ x = nullptr; \
}
/** Deletes array x only if it exists */
#define GF_SAFE_DELETE_ARRAY(x) \
{ \
delete[] x; \
- x = NULL; \
+ x = nullptr; \
}
// TODO shared_ptre - make C+11 library dependent or make constructor destructor
@@ -322,8 +322,7 @@ void operator delete[](void *p);
friend std::__shared_ptr_emplace<_T, std::allocator<_T> >; \
friend std::default_delete<_T>;
#elif defined(__GNUC__) || defined(__SUNPRO_CC)
-#define FRIEND_STD_SHARED_PTR(_T) \
- friend __gnu_cxx::new_allocator<_T>;
+#define FRIEND_STD_SHARED_PTR(_T) friend __gnu_cxx::new_allocator<_T>;
#elif defined(_MSC_VER)
#if defined(_MANAGED)
#define FRIEND_STD_SHARED_PTR(_T) \
@@ -332,9 +331,8 @@ void operator delete[](void *p);
friend std::_Ptr_base<_T>; \
friend std::default_delete<_T>; \
friend std::shared_ptr<_T>;
-#else
-#define FRIEND_STD_SHARED_PTR(_T) \
- friend std::_Ref_count_obj<_T>;
+#else
+#define FRIEND_STD_SHARED_PTR(_T) friend std::_Ref_count_obj<_T>;
#endif
#else
#define FRIEND_STD_SHARED_PTR(_T)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/statistics/StatisticsFactory.hpp b/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
index 44e84bb..f14041a 100644
--- a/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
+++ b/src/cppcache/include/geode/statistics/StatisticsFactory.hpp
@@ -26,7 +26,7 @@
#include <geode/statistics/Statistics.hpp>
/** @file
-*/
+ */
namespace apache {
namespace geode {
@@ -88,11 +88,11 @@ class CPPCACHE_EXPORT StatisticsFactory {
bool largerBetter = true) = 0;
/**
- * Creates and returns an int gauge {@link StatisticDescriptor}
- * with the given <code>name</code>, <code>description</code>,
- * <code>units</code>, and with smaller values indicating better
+ * Creates and returns an int gauge {@link StatisticDescriptor}
+ * with the given <code>name</code>, <code>description</code>,
+ * <code>units</code>, and with smaller values indicating better
* performance.
- */
+ */
virtual StatisticDescriptor* createDoubleCounter(
const char* name, const char* description, const char* units,
@@ -199,7 +199,7 @@ class CPPCACHE_EXPORT StatisticsFactory {
const char* textId,
int64_t numericId) = 0;
- /** Return the first instance that matches the type, or NULL */
+ /** Return the first instance that matches the type, or nullptr */
virtual Statistics* findFirstStatisticsByType(StatisticsType* type) = 0;
/**
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/include/geode/utils.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/utils.hpp b/src/cppcache/include/geode/utils.hpp
new file mode 100644
index 0000000..f05c445
--- /dev/null
+++ b/src/cppcache/include/geode/utils.hpp
@@ -0,0 +1,80 @@
+#pragma once
+
+// TODO shared_ptr rename to avoid collision with Util.hpp. Consider
+// Equality.hpp?
+
+#ifndef GEODE_UTILSX_H_
+#define GEODE_UTILSX_H_
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <functional>
+#include <memory>
+#include <type_traits>
+
+namespace apache {
+namespace geode {
+namespace client {
+
+template <class _T>
+struct dereference_hash;
+
+template <class _T>
+struct dereference_hash<std::shared_ptr<_T>>
+ : public std::unary_function<std::shared_ptr<_T>, size_t> {
+ size_t operator()(const std::shared_ptr<_T>& val) const {
+ return std::hash<_T>{}(*val);
+ }
+};
+
+template <class _T>
+struct dereference_hash<_T*> : public std::unary_function<_T*, size_t> {
+ typedef _T* argument_type;
+ size_t operator()(const argument_type& val) const {
+ return std::hash<_T>{}(*val);
+ }
+};
+
+template <class _T>
+struct dereference_equal_to;
+
+template <class _T>
+struct dereference_equal_to<std::shared_ptr<_T>>
+ : public std::binary_function<std::shared_ptr<_T>, std::shared_ptr<_T>,
+ bool> {
+ constexpr bool operator()(const std::shared_ptr<_T>& lhs,
+ const std::shared_ptr<_T>& rhs) const {
+ return std::equal_to<_T>{}(*lhs, *rhs);
+ }
+};
+
+template <class _T>
+struct dereference_equal_to<_T*> : std::equal_to<_T*> {
+ typedef _T* first_argument_type;
+ typedef _T* second_argument_type;
+ constexpr bool operator()(const first_argument_type& lhs,
+ const second_argument_type& rhs) const {
+ return std::equal_to<_T>{}(*lhs, *rhs);
+ }
+};
+
+} // namespace client
+} // namespace geode
+} // namespace apache
+
+#endif // GEODE_UTILSX_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/BBNamingContext.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/BBNamingContext.cpp b/src/cppcache/integration-test/BBNamingContext.cpp
index 64d66ac..d7d61c5 100644
--- a/src/cppcache/integration-test/BBNamingContext.cpp
+++ b/src/cppcache/integration-test/BBNamingContext.cpp
@@ -29,7 +29,7 @@
using namespace apache::geode::client::testframework;
static int hashcode(char* str) {
- if (str == NULL) {
+ if (str == nullptr) {
return 0;
}
int localHash = 0;
@@ -92,7 +92,7 @@ class BBNamingContextServerImpl {
// Impls:
//
BBNamingContextClientImpl::BBNamingContextClientImpl()
- : m_bbc(NULL), m_errCount(0) {}
+ : m_bbc(nullptr), m_errCount(0) {}
BBNamingContextClientImpl::~BBNamingContextClientImpl() { close(); }
void BBNamingContextClientImpl::open() {
try {
@@ -113,15 +113,15 @@ void BBNamingContextClientImpl::open() {
}
}
void BBNamingContextClientImpl::close() {
- if (m_bbc != NULL) {
+ if (m_bbc != nullptr) {
delete m_bbc;
- m_bbc = NULL;
+ m_bbc = nullptr;
}
}
int BBNamingContextClientImpl::rebind(const char* key, const char* value,
char* type) {
// fprintf(stdout, "bind: key=%s, value=%s\n", key, value);
- if (m_bbc == NULL) {
+ if (m_bbc == nullptr) {
return -1;
}
if (m_errCount > ERR_MAX) {
@@ -152,7 +152,7 @@ int BBNamingContextClientImpl::rebind(const char* key, const char* value,
return -1;
}
void BBNamingContextClientImpl::dump() {
- if (m_bbc == NULL) {
+ if (m_bbc == nullptr) {
return;
}
if (m_errCount > ERR_MAX) {
@@ -176,7 +176,7 @@ void BBNamingContextClientImpl::dump() {
int BBNamingContextClientImpl::resolve(const char* key, char* value,
char* type) {
// fprintf(stdout, "resolve: key=%s\n", key);fflush(stdout);
- if (m_bbc == NULL) {
+ if (m_bbc == nullptr) {
return -1;
}
if (m_errCount > ERR_MAX) {
@@ -260,7 +260,7 @@ BBNamingContextClient::BBNamingContextClient() {
BBNamingContextClient::~BBNamingContextClient() {
if (m_impl) {
delete m_impl;
- m_impl = NULL;
+ m_impl = nullptr;
}
}
void BBNamingContextClient::open() { m_impl->open(); }
@@ -280,9 +280,9 @@ BBNamingContextServer::BBNamingContextServer() {
m_impl = new BBNamingContextServerImpl();
}
BBNamingContextServer::~BBNamingContextServer() {
- if (m_impl != NULL) {
+ if (m_impl != nullptr) {
delete m_impl;
- m_impl = NULL;
+ m_impl = nullptr;
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/BBNamingContext.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/BBNamingContext.hpp b/src/cppcache/integration-test/BBNamingContext.hpp
index 4523a4e..f6ea12d 100644
--- a/src/cppcache/integration-test/BBNamingContext.hpp
+++ b/src/cppcache/integration-test/BBNamingContext.hpp
@@ -35,9 +35,9 @@ class BBNamingContextClient {
~BBNamingContextClient();
void open();
void close();
- int rebind(const char* key, const char* value, char* type = NULL);
+ int rebind(const char* key, const char* value, char* type = nullptr);
void dump();
- int resolve(const char* key, char* value, char* type = NULL);
+ int resolve(const char* key, char* value, char* type = nullptr);
};
class BBNamingContextServerImpl;
class BBNamingContextServer {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp b/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
index be32e3f..6b4a669 100644
--- a/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
+++ b/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp
@@ -133,7 +133,7 @@ inline void randomString(int32_t size, std::wstring& randStr,
}
inline uint32_t crc32(const uint8_t* buffer, uint32_t bufLen) {
- if (buffer == NULL || bufLen == 0) {
+ if (buffer == nullptr || bufLen == 0) {
return 0;
}
@@ -202,7 +202,7 @@ class CacheableBooleanWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableBoolean* obj =
dynamic_cast<const CacheableBoolean*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<uint8_t>(obj->value() ? 1 : 0);
}
};
@@ -230,7 +230,7 @@ class CacheableByteWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableByte* obj = dynamic_cast<const CacheableByte*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<uint8_t>(obj->value());
}
};
@@ -259,7 +259,7 @@ class CacheableDoubleWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableDouble* obj =
dynamic_cast<const CacheableDouble*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<double>(obj->value());
}
};
@@ -295,7 +295,7 @@ class CacheableDateWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableDate* obj = dynamic_cast<const CacheableDate*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<int64_t>(obj->milliseconds());
}
};
@@ -348,7 +348,7 @@ class CacheableFileNameWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableFileName* obj =
dynamic_cast<const CacheableFileName*>(object.get());
- return (obj != NULL
+ return (obj != nullptr
? CacheableHelper::crc32((uint8_t*)obj->asChar(), obj->length())
: 0);
}
@@ -378,7 +378,7 @@ class CacheableFloatWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableFloat* obj =
dynamic_cast<const CacheableFloat*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<float>(obj->value());
}
};
@@ -407,7 +407,7 @@ class CacheableInt16Wrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableInt16* obj =
dynamic_cast<const CacheableInt16*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<int16_t>(obj->value());
}
};
@@ -436,7 +436,7 @@ class CacheableInt32Wrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableInt32* obj =
dynamic_cast<const CacheableInt32*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<int32_t>(obj->value());
}
};
@@ -466,7 +466,7 @@ class CacheableInt64Wrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableInt64* obj =
dynamic_cast<const CacheableInt64*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<int64_t>(obj->value());
}
};
@@ -507,7 +507,7 @@ class CacheableStringWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableString* obj =
dynamic_cast<const CacheableString*>(object.get());
- return (obj != NULL
+ return (obj != nullptr
? CacheableHelper::crc32((uint8_t*)obj->asChar(), obj->length())
: 0);
}
@@ -552,7 +552,7 @@ class CacheableHugeStringWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableString* obj =
dynamic_cast<const CacheableString*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32((uint8_t*)obj->asChar(), obj->length());
}
};
@@ -598,7 +598,7 @@ class CacheableHugeUnicodeStringWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableString* obj =
dynamic_cast<const CacheableString*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32((uint8_t*)obj->asWChar(),
obj->length() * sizeof(wchar_t));
}
@@ -642,7 +642,7 @@ class CacheableUnicodeStringWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableString* obj =
dynamic_cast<const CacheableString*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32((uint8_t*)obj->asWChar(),
obj->length() * sizeof(wchar_t));
}
@@ -673,7 +673,7 @@ class CacheableWideCharWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableWideChar* obj =
dynamic_cast<const CacheableWideChar*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32<wchar_t>(obj->value());
}
};
@@ -696,7 +696,7 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper {
virtual void initRandomValue(int32_t maxSize) {
m_cacheableObject = HMAPTYPE::create(maxSize);
HMAPTYPE* chmp = dynamic_cast<HMAPTYPE*>(m_cacheableObject.get());
- ASSERT(chmp != NULL, "initRandomValue: null object.");
+ ASSERT(chmp != nullptr, "initRandomValue: null object.");
std::vector<int8_t> keyTypeIds =
CacheableWrapperFactory::getRegisteredKeyTypes();
std::vector<int8_t> valTypeIds =
@@ -726,23 +726,21 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper {
continue;
}
- CacheableWrapper* keyWrapper =
- CacheableWrapperFactory::createInstance(*keyIter);
- ASSERT(keyWrapper != NULL, "initRandomValue: keyWrapper null object.");
+ const auto keyWrapper = std::unique_ptr<CacheableWrapper>(
+ CacheableWrapperFactory::createInstance(*keyIter));
+ ASSERT(keyWrapper != nullptr,
+ "initRandomValue: keyWrapper null object.");
if (item > keyWrapper->maxKeys()) {
- delete keyWrapper;
- break;
}
- CacheableWrapper* valWrapper =
- CacheableWrapperFactory::createInstance(*valIter);
- ASSERT(valWrapper != NULL, "initRandomValue: valWrapper null object.");
+ const auto valWrapper = std::unique_ptr<CacheableWrapper>(
+ CacheableWrapperFactory::createInstance(*valIter));
+ ASSERT(valWrapper != nullptr,
+ "initRandomValue: valWrapper null object.");
keyWrapper->initKey(((*keyIter) << 8) + item, maxSize);
valWrapper->initRandomValue(maxSize);
- chmp->insert(
+ chmp->emplace(
std::dynamic_pointer_cast<CacheableKey>(keyWrapper->getCacheable()),
valWrapper->getCacheable());
- delete keyWrapper;
- delete valWrapper;
item++;
}
}
@@ -750,23 +748,20 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const HMAPTYPE* obj = dynamic_cast<const HMAPTYPE*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
uint32_t chksum = 0;
- for (typename HMAPTYPE::Iterator iter = obj->begin(); iter != obj->end();
- ++iter) {
- CacheableWrapper* cwpKey =
- CacheableWrapperFactory::createInstance(iter.first()->typeId());
- CacheablePtr cwpObj = iter.second();
+ for (const auto& iter : *obj) {
+ const auto cwpKey = std::unique_ptr<CacheableWrapper>(
+ CacheableWrapperFactory::createInstance(iter.first->typeId()));
+ const auto& cwpObj = iter.second;
uint32_t cwpObjCkSum = 0;
if (cwpObj != nullptr) {
- CacheableWrapper* cwpVal =
- CacheableWrapperFactory::createInstance(cwpObj->typeId());
+ const auto cwpVal = std::unique_ptr<CacheableWrapper>(
+ CacheableWrapperFactory::createInstance(cwpObj->typeId()));
cwpObjCkSum = cwpVal->getCheckSum(cwpObj);
- delete cwpVal;
}
- chksum ^= (cwpKey->getCheckSum(iter.first()) ^ cwpObjCkSum);
- delete cwpKey;
+ chksum ^= (cwpKey->getCheckSum(iter.first) ^ cwpObjCkSum);
}
return chksum;
@@ -816,16 +811,14 @@ class CacheableHashSetTypeWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const HSETTYPE* obj = dynamic_cast<const HSETTYPE*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
uint32_t checkSum = 0;
- for (typename HSETTYPE::Iterator iter = obj->begin(); iter != obj->end();
- ++iter) {
- int8_t typeId = (*iter)->typeId();
- CacheableWrapper* wrapper =
- CacheableWrapperFactory::createInstance(typeId);
- checkSum ^= wrapper->getCheckSum(*iter);
- delete wrapper;
+ for (const auto& iter : *obj) {
+ const auto typeId = iter->typeId();
+ const auto wrapper = std::unique_ptr<CacheableWrapper>(
+ CacheableWrapperFactory::createInstance(typeId));
+ checkSum ^= wrapper->getCheckSum(iter);
}
return checkSum;
}
@@ -856,7 +849,7 @@ class CacheableBytesWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableBytes* obj =
dynamic_cast<const CacheableBytes*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32(obj->value(), obj->length());
}
};
@@ -884,7 +877,7 @@ class CacheableDoubleArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableDoubleArray* obj =
dynamic_cast<const CacheableDoubleArray*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32Array(obj->value(), obj->length());
}
};
@@ -910,7 +903,7 @@ class CacheableFloatArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableFloatArray* obj =
dynamic_cast<const CacheableFloatArray*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32Array(obj->value(), obj->length());
}
};
@@ -935,7 +928,7 @@ class CacheableInt16ArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableInt16Array* obj =
dynamic_cast<const CacheableInt16Array*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32Array(obj->value(), obj->length());
}
};
@@ -960,7 +953,7 @@ class CacheableInt32ArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableInt32Array* obj =
dynamic_cast<const CacheableInt32Array*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32Array(obj->value(), obj->length());
}
};
@@ -985,7 +978,7 @@ class CacheableInt64ArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableInt64Array* obj =
dynamic_cast<const CacheableInt64Array*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
return CacheableHelper::crc32Array(obj->value(), obj->length());
}
};
@@ -1001,7 +994,7 @@ class CacheableNullStringWrapper : public CacheableWrapper {
// CacheableWrapper members
virtual void initRandomValue(int32_t maxSize) {
- m_cacheableObject = CacheableString::create((char*)NULL);
+ m_cacheableObject = CacheableString::create((char*)nullptr);
}
virtual uint32_t getCheckSum(const CacheablePtr object) const {
@@ -1049,7 +1042,7 @@ class CacheableStringArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableStringArray* obj =
dynamic_cast<const CacheableStringArray*>(object.get());
- ASSERT(obj != NULL, "getCheckSum: null object.");
+ ASSERT(obj != nullptr, "getCheckSum: null object.");
uint32_t checkSum = 0;
CacheableStringPtr str;
for (int32_t index = 0; index < obj->length(); index++) {
@@ -1119,7 +1112,7 @@ class CacheableVectorTypeWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const VECTTYPE* vec = dynamic_cast<const VECTTYPE*>(object.get());
- ASSERT(vec != NULL, "getCheckSum: null object.");
+ ASSERT(vec != nullptr, "getCheckSum: null object.");
uint32_t checkSum = 0;
for (uint32_t index = 0; index < (uint32_t)vec->size(); ++index) {
CacheablePtr obj = vec->at(index);
@@ -1181,7 +1174,7 @@ class CacheableObjectArrayWrapper : public CacheableWrapper {
virtual uint32_t getCheckSum(const CacheablePtr object) const {
const CacheableObjectArray* arr =
dynamic_cast<const CacheableObjectArray*>(object.get());
- ASSERT(arr != NULL, "getCheckSum: null object.");
+ ASSERT(arr != nullptr, "getCheckSum: null object.");
uint32_t checkSum = 0;
for (uint32_t index = 0; index < static_cast<uint32_t>(arr->size());
++index) {
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/CacheHelper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheHelper.cpp b/src/cppcache/integration-test/CacheHelper.cpp
index 61bfc23..cf73dbf 100644
--- a/src/cppcache/integration-test/CacheHelper.cpp
+++ b/src/cppcache/integration-test/CacheHelper.cpp
@@ -68,7 +68,7 @@ extern ClientCleanup gClientCleanup;
CachePtr CacheHelper::getCache() { return cachePtr; }
CacheHelper& CacheHelper::getHelper() {
- if (singleton == NULL) {
+ if (singleton == nullptr) {
singleton = new CacheHelper();
}
return *singleton;
@@ -105,7 +105,7 @@ CacheHelper::CacheHelper(const char* member_id, const char* cachexml,
if (pp == nullptr) {
pp = Properties::create();
}
- if (cachexml != NULL) {
+ if (cachexml != nullptr) {
std::string tmpXmlFile(cachexml);
std::string newFile;
CacheHelper::createDuplicateXMLFile(newFile, tmpXmlFile);
@@ -291,7 +291,7 @@ void CacheHelper::disconnect(bool keepalive) {
} catch (...) {
LOG("Throwing exception while disconnecting....");
}
- singleton = NULL;
+ singleton = nullptr;
LOG("Finished cleanup after CacheHelper.");
}
@@ -528,7 +528,7 @@ RegionPtr CacheHelper::createRegionAndAttachPool(
regionFactoryPtr->setEntryTimeToLive(action, ettl);
regionFactoryPtr->setRegionIdleTimeout(action, rit);
regionFactoryPtr->setRegionTimeToLive(action, rttl);
- if (poolName != NULL) {
+ if (poolName != nullptr) {
regionFactoryPtr->setPoolName(poolName);
}
return regionFactoryPtr->create(name);
@@ -875,8 +875,8 @@ void CacheHelper::showRegionAttributes(RegionAttributes& attributes) {
printf("Initial Capacity = %d\n", attributes.getInitialCapacity());
printf("Load Factor = %f\n", attributes.getLoadFactor());
printf("End Points = %s\n",
- (attributes.getEndpoints() != NULL ? attributes.getEndpoints()
- : "(null)"));
+ (attributes.getEndpoints() != nullptr ? attributes.getEndpoints()
+ : "(null)"));
}
QueryServicePtr CacheHelper::getQueryService() {
@@ -891,10 +891,10 @@ const char* CacheHelper::getTcrEndpoints(bool& isLocalServer,
char tmp[100];
if (gfendpoints.empty()) {
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') != NULL) ||
- (ACE_OS::strchr(gfjavaenv, '/') != NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') != nullptr) ||
+ (ACE_OS::strchr(gfjavaenv, '/') != nullptr)) {
gflocalserver = true;
/* Support for multiple servers Max = 10*/
switch (numberOfServers) {
@@ -992,8 +992,8 @@ const char* CacheHelper::getTcrEndpoints2(bool& isLocalServer,
char tmp[128];
if (gfendpoints.empty()) {
- if ((ACE_OS::strchr(gfjavaenv, '\\') != NULL) ||
- (ACE_OS::strchr(gfjavaenv, '/') != NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') != nullptr) ||
+ (ACE_OS::strchr(gfjavaenv, '/') != nullptr)) {
gflocalserver = true;
/* Support for multiple servers Max = 10*/
switch (numberOfServers) {
@@ -1063,7 +1063,7 @@ const char* CacheHelper::getTcrEndpoints2(bool& isLocalServer,
gfendpoints = gfjavaenv;
}
}
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
isLocalServer = gflocalserver;
return (new std::string(gfendpoints.c_str()))->c_str();
@@ -1079,8 +1079,8 @@ const char* CacheHelper::getLocatorHostPort(bool& isLocator,
char tmp[100];
if (gflchostport.empty()) {
- if ((ACE_OS::strchr(gfjavaenv, '\\') != NULL) ||
- (ACE_OS::strchr(gfjavaenv, '/') != NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') != nullptr) ||
+ (ACE_OS::strchr(gfjavaenv, '/') != nullptr)) {
gflocator = true;
gflocalserver = true;
switch (numberOfLocators) {
@@ -1122,7 +1122,7 @@ const char* CacheHelper::getLocatorHostPort(bool& isLocator,
gflchostport = "";
}
}
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
isLocator = gflocator;
isLocalServer = gflocalserver;
@@ -1151,10 +1151,10 @@ void CacheHelper::initServer(int instance, const char* xml,
printf("TimeBomb registered server cleanupcallback \n");
}
printf("Inside initServer added\n");
- if (authParam != NULL) {
+ if (authParam != nullptr) {
printf("Inside initServer with authParam = %s\n", authParam);
} else {
- printf("Inside initServer with authParam as NULL\n");
+ printf("Inside initServer with authParam as nullptr\n");
authParam = "";
}
static const char* gfjavaenv = ACE_OS::getenv("GFJAVA");
@@ -1171,25 +1171,25 @@ void CacheHelper::initServer(int instance, const char* xml,
int portNum;
std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
- ASSERT(path != NULL,
+ ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
- ASSERT(mcastPort != NULL,
+ ASSERT(mcastPort != nullptr,
"Environment variable MCAST_PORT for multicast port is not set.");
- ASSERT(mcastAddr != NULL,
+ ASSERT(mcastAddr != nullptr,
"Environment variable MCAST_ADDR for multicast address is not set.");
ASSERT(!currDir.empty(),
"Current working directory could not be determined.");
- if (gfLogLevel == NULL || gfLogLevel[0] == '\0') {
+ if (gfLogLevel == nullptr || gfLogLevel[0] == '\0') {
gfLogLevel = "config";
}
- if (gfSecLogLevel == NULL || gfSecLogLevel[0] == '\0') {
+ if (gfSecLogLevel == nullptr || gfSecLogLevel[0] == '\0') {
gfSecLogLevel = "config";
}
- if ((ACE_OS::strchr(gfjavaenv, '\\') == NULL) &&
- (ACE_OS::strchr(gfjavaenv, '/') == NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
+ (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
return;
}
@@ -1253,8 +1253,8 @@ void CacheHelper::initServer(int instance, const char* xml,
break;
default: /* Support for any number of servers Max 10*/
ASSERT((instance <= 10), " More than 10 servers not supported");
- ASSERT(xml != NULL,
- "xml == NULL : For server instance > 3 xml file is must");
+ ASSERT(xml != nullptr,
+ "xml == nullptr : For server instance > 3 xml file is must");
char temp[8];
portNum = CacheHelper::staticHostPort4;
sname += ACE_OS::itoa(CacheHelper::staticHostPort4, temp, 10);
@@ -1263,7 +1263,7 @@ void CacheHelper::initServer(int instance, const char* xml,
currDir += sname;
- if (xml != NULL) {
+ if (xml != nullptr) {
/*
xmlFile = path;
xmlFile += PATH_SEP;
@@ -1308,8 +1308,9 @@ void CacheHelper::initServer(int instance, const char* xml,
ACE_OS::mkdir("backupDirectory4");
}
- if (locHostport != NULL) { // check number of locator host port.
- std::string geodeProperties = generateGeodeProperties(currDir, ssl, -1, 0,untrustedCert);
+ if (locHostport != nullptr) { // check number of locator host port.
+ std::string geodeProperties =
+ generateGeodeProperties(currDir, ssl, -1, 0, untrustedCert);
sprintf(
cmd,
@@ -1386,7 +1387,8 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
std::ifstream in(inFile, std::ios::in | std::ios::binary);
if (in) {
std::string contents;
- contents.assign(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
+ contents.assign(std::istreambuf_iterator<char>(in),
+ std::istreambuf_iterator<char>());
in.close();
replaceInPlace(contents, "HOST_PORT1", std::to_string(hostPort1));
@@ -1402,13 +1404,14 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
}
}
-void CacheHelper::replaceInPlace(std::string& searchStr, const std::string& matchStr,
+void CacheHelper::replaceInPlace(std::string& searchStr,
+ const std::string& matchStr,
const std::string& replaceStr) {
- size_t pos = 0;
- while ((pos = searchStr.find(matchStr, pos)) != std::string::npos) {
- searchStr.replace(pos, matchStr.length(), replaceStr);
- pos += replaceStr.length();
- }
+ size_t pos = 0;
+ while ((pos = searchStr.find(matchStr, pos)) != std::string::npos) {
+ searchStr.replace(pos, matchStr.length(), replaceStr);
+ pos += replaceStr.length();
+ }
}
#else
void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
@@ -1418,15 +1421,22 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
std::ifstream in(inFile, std::ios::in | std::ios::binary);
if (in) {
std::string contents;
- contents.assign(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
+ contents.assign(std::istreambuf_iterator<char>(in),
+ std::istreambuf_iterator<char>());
in.close();
- contents = std::regex_replace(contents, std::regex("HOST_PORT1"), std::to_string(hostPort1));
- contents = std::regex_replace(contents, std::regex("HOST_PORT2"), std::to_string(hostPort2));
- contents = std::regex_replace(contents, std::regex("HOST_PORT3"), std::to_string(hostPort3));
- contents = std::regex_replace(contents, std::regex("HOST_PORT4"), std::to_string(hostPort4));
- contents = std::regex_replace(contents, std::regex("LOC_PORT1"), std::to_string(locPort1));
- contents = std::regex_replace(contents, std::regex("LOC_PORT2"), std::to_string(locPort2));
+ contents = std::regex_replace(contents, std::regex("HOST_PORT1"),
+ std::to_string(hostPort1));
+ contents = std::regex_replace(contents, std::regex("HOST_PORT2"),
+ std::to_string(hostPort2));
+ contents = std::regex_replace(contents, std::regex("HOST_PORT3"),
+ std::to_string(hostPort3));
+ contents = std::regex_replace(contents, std::regex("HOST_PORT4"),
+ std::to_string(hostPort4));
+ contents = std::regex_replace(contents, std::regex("LOC_PORT1"),
+ std::to_string(locPort1));
+ contents = std::regex_replace(contents, std::regex("LOC_PORT2"),
+ std::to_string(locPort2));
std::ofstream out(outFile, std::ios::out);
out << contents;
@@ -1460,13 +1470,13 @@ void CacheHelper::closeServer(int instance) {
std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
ASSERT(!currDir.empty(),
"Current working directory could not be determined.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') == NULL) &&
- (ACE_OS::strchr(gfjavaenv, '/') == NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
+ (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
return;
}
@@ -1517,12 +1527,12 @@ void CacheHelper::closeLocator(int instance, bool ssl) {
std::string currDir = ACE_OS::getcwd(currWDPath, 2048);
std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
ASSERT(!currDir.empty(),
"Current working directory could not be determined.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') == NULL) &&
- (ACE_OS::strchr(gfjavaenv, '/') == NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
+ (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
return;
}
@@ -1595,8 +1605,8 @@ void CacheHelper::terminate_process_file(
std::chrono::system_clock::now() - start);
LOG("CacheHelper::terminate_process_file: process exited. "
"pidFileName=" +
- pidFileName + ", pid=" + pid + ", elapsed=" +
- std::to_string(elapsed.count()) + "ms");
+ pidFileName + ", pid=" + pid +
+ ", elapsed=" + std::to_string(elapsed.count()) + "ms");
return;
}
std::this_thread::yield();
@@ -1663,13 +1673,13 @@ void CacheHelper::initLocator(int instance, bool ssl, bool multiDS, int dsId,
// std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) +
// "/keystore";
- ASSERT(gfjavaenv != NULL,
+ ASSERT(gfjavaenv != nullptr,
"Environment variable GFJAVA for java build directory is not set.");
ASSERT(!currDir.empty(),
"Current working directory could not be determined.");
- if ((ACE_OS::strchr(gfjavaenv, '\\') == NULL) &&
- (ACE_OS::strchr(gfjavaenv, '/') == NULL)) {
+ if ((ACE_OS::strchr(gfjavaenv, '\\') == nullptr) &&
+ (ACE_OS::strchr(gfjavaenv, '/') == nullptr)) {
return;
}
std::string locDirname = "GFELOC";
@@ -1750,7 +1760,7 @@ bool CacheHelper::setSeed() {
}
int CacheHelper::hashcode(char* str) {
- if (str == NULL) {
+ if (str == nullptr) {
return 0;
}
int localHash = 0;
@@ -1811,7 +1821,7 @@ int CacheHelper::getNumLocatorListUpdates(const char* s) {
std::string searchStr(s);
std::string testFile = CacheHelper::unitTestOutputFile();
FILE* fp = fopen(testFile.c_str(), "r");
- ASSERT(NULL != fp, "Failed to open log file.");
+ ASSERT(nullptr != fp, "Failed to open log file.");
char buf[512];
int numMatched = 0;
@@ -1824,7 +1834,8 @@ int CacheHelper::getNumLocatorListUpdates(const char* s) {
std::string CacheHelper::generateGeodeProperties(const std::string& path,
const bool ssl, const int dsId,
- const int remoteLocator, const bool untrustedCert) {
+ const int remoteLocator,
+ const bool untrustedCert) {
char cmd[2048];
std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
@@ -1852,14 +1863,13 @@ std::string CacheHelper::generateGeodeProperties(const std::string& path,
std::string password;
if (ssl) {
- if (untrustedCert){
+ if (untrustedCert) {
serverKeystore += "untrusted_server_keystore.jks";
- serverTruststore += "untrusted_server_truststore.jks";
+ serverTruststore += "untrusted_server_truststore.jks";
password += "secret";
- }
- else {
+ } else {
serverKeystore += "server_keystore.jks";
- serverTruststore += "server_truststore.jks";
+ serverTruststore += "server_truststore.jks";
password += "gemstone";
}
msg += "jmx-manager-ssl-enabled=false\n";
@@ -1867,9 +1877,11 @@ std::string CacheHelper::generateGeodeProperties(const std::string& path,
msg += "cluster-ssl-require-authentication=true\n";
msg += "cluster-ssl-ciphers=TLS_RSA_WITH_AES_128_CBC_SHA\n";
msg += "cluster-ssl-keystore-type=jks\n";
- msg += "cluster-ssl-keystore=" + keystore + "/" + serverKeystore.c_str() + "\n";
+ msg += "cluster-ssl-keystore=" + keystore + "/" + serverKeystore.c_str() +
+ "\n";
msg += "cluster-ssl-keystore-password=" + password + "\n";
- msg += "cluster-ssl-truststore=" + keystore + "/" + serverTruststore.c_str() + "\n";
+ msg += "cluster-ssl-truststore=" + keystore + "/" +
+ serverTruststore.c_str() + "\n";
msg += "cluster-ssl-truststore-password=" + password + "\n";
msg += "security-username=xxxx\n";
msg += "security-userPassword=yyyy \n";
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/CacheHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheHelper.hpp b/src/cppcache/integration-test/CacheHelper.hpp
index 52de9fe..d63a67f 100644
--- a/src/cppcache/integration-test/CacheHelper.hpp
+++ b/src/cppcache/integration-test/CacheHelper.hpp
@@ -132,22 +132,22 @@ class CacheHelper {
// this will create pool even endpoints and locatorhost has been not defined
PoolPtr createPool2(const char* poolName, const char* locators,
- const char* serverGroup, const char* servers = NULL,
+ const char* serverGroup, const char* servers = nullptr,
int redundancy = 0, bool clientNotification = false,
int subscriptionAckInterval = -1, int connections = -1);
void logPoolAttributes(PoolPtr& pool);
- void createPoolWithLocators(const char* name, const char* locators = NULL,
+ void createPoolWithLocators(const char* name, const char* locators = nullptr,
bool clientNotificationEnabled = false,
int subscriptionRedundancy = -1,
int subscriptionAckInterval = -1,
int connections = -1,
bool isMultiuserMode = false,
- const char* serverGroup = NULL);
+ const char* serverGroup = nullptr);
RegionPtr createRegionAndAttachPool(
- const char* name, bool ack, const char* poolName = NULL,
+ const char* name, bool ack, const char* poolName = nullptr,
bool caching = true, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0,
int lel = 0, ExpirationAction::Action action = ExpirationAction::DESTROY);
@@ -254,9 +254,9 @@ class CacheHelper {
static bool isServerCleanupCallbackRegistered;
static void cleanupServerInstances();
- static void initServer(int instance, const char* xml = NULL,
- const char* locHostport = NULL,
- const char* authParam = NULL, bool ssl = false,
+ static void initServer(int instance, const char* xml = nullptr,
+ const char* locHostport = nullptr,
+ const char* authParam = nullptr, bool ssl = false,
bool enableDelta = true, bool multiDS = false,
bool testServerGC = false, bool untrustedCert = false);
@@ -285,8 +285,9 @@ class CacheHelper {
const std::string& outFile);
#ifdef _SOLARIS
- static void replaceInPlace(std::string& searchStr, const std::string& matchStr,
- const std::string& replaceStr);
+ static void replaceInPlace(std::string& searchStr,
+ const std::string& matchStr,
+ const std::string& replaceStr);
#endif
static std::list<int> staticLocatorInstanceList;
@@ -295,7 +296,8 @@ class CacheHelper {
// starting locator
static void initLocator(int instance, bool ssl = false, bool multiDS = false,
- int dsId = -1, int remoteLocator = 0, bool untrustedCert = false);
+ int dsId = -1, int remoteLocator = 0,
+ bool untrustedCert = false);
static void clearSecProp();
@@ -322,7 +324,7 @@ class CacheHelper {
};
#ifndef test_cppcache_utils_static
-CacheHelper* CacheHelper::singleton = NULL;
+CacheHelper* CacheHelper::singleton = nullptr;
std::list<int> CacheHelper::staticServerInstanceList;
std::list<int> CacheHelper::staticLocatorInstanceList;
std::list<std::string> CacheHelper::staticConfigFileList;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/CacheImplHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheImplHelper.hpp b/src/cppcache/integration-test/CacheImplHelper.hpp
index 68603be..474205b 100644
--- a/src/cppcache/integration-test/CacheImplHelper.hpp
+++ b/src/cppcache/integration-test/CacheImplHelper.hpp
@@ -27,15 +27,14 @@
#include "testUtils.hpp"
#ifndef ROOT_NAME
-ROOT_NAME++ +
- DEFINE ROOT_NAME before including CacheHelper.hpp
+ROOT_NAME++ + DEFINE ROOT_NAME before including CacheHelper.hpp
#endif
#ifndef ROOT_SCOPE
#define ROOT_SCOPE LOCAL
#endif
- using namespace apache::geode::client;
+ using namespace apache::geode::client;
using namespace unitTests;
class CacheImplHelper : public CacheHelper {
@@ -61,7 +60,7 @@ class CacheImplHelper : public CacheHelper {
regAttrs = attrFactory.createRegionAttributes();
showRegionAttributes(*regAttrs);
CacheImpl* cimpl = TestUtils::getCacheImpl(cachePtr);
- ASSERT(cimpl != NULL, "failed to get cacheImpl *.");
+ ASSERT(cimpl != nullptr, "failed to get cacheImpl *.");
cimpl->createRegion(regionName, regAttrs, regionPtr);
ASSERT(regionPtr != nullptr, "failed to create region.");
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/CacheableWrapper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CacheableWrapper.hpp b/src/cppcache/integration-test/CacheableWrapper.hpp
index 1ed5d03..cc0f951 100644
--- a/src/cppcache/integration-test/CacheableWrapper.hpp
+++ b/src/cppcache/integration-test/CacheableWrapper.hpp
@@ -87,7 +87,7 @@ CacheableWrapper* CacheableWrapperFactory::createInstance(int8_t typeId) {
CacheableWrapperFunc wrapperFunc = m_registeredValueMap[typeId];
return wrapperFunc();
}
- return NULL;
+ return nullptr;
}
void CacheableWrapperFactory::registerType(
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/LocatorHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/LocatorHelper.hpp b/src/cppcache/integration-test/LocatorHelper.hpp
index f41913e..b68d7f4 100644
--- a/src/cppcache/integration-test/LocatorHelper.hpp
+++ b/src/cppcache/integration-test/LocatorHelper.hpp
@@ -41,21 +41,22 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(1, NULL, locatorsG);
+ if (isLocalServer) CacheHelper::initServer(1, nullptr, locatorsG);
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(1, NULL, locatorsG, NULL, true);
+ if (isLocalServer)
+ CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true);
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer2_With_Locator)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(2, NULL, locatorsG);
+ if (isLocalServer) CacheHelper::initServer(2, nullptr, locatorsG);
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/QueryHelper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/QueryHelper.hpp b/src/cppcache/integration-test/QueryHelper.hpp
index 0a280b3..1bd3469 100644
--- a/src/cppcache/integration-test/QueryHelper.hpp
+++ b/src/cppcache/integration-test/QueryHelper.hpp
@@ -53,7 +53,7 @@ class QueryHelper {
static QueryHelper* singleton;
static QueryHelper& getHelper() {
- if (singleton == NULL) {
+ if (singleton == nullptr) {
singleton = new QueryHelper();
}
return *singleton;
@@ -75,7 +75,7 @@ class QueryHelper {
int numSets);
virtual void populatePortfolioPdxData(RegionPtr& pregion, int setSize,
int numSets, int32_t objSize = 1,
- char** nm = NULL);
+ char** nm = nullptr);
virtual void populatePositionPdxData(RegionPtr& pregion, int setSize,
int numSets);
virtual void populatePDXObject(RegionPtr& pregion);
@@ -149,7 +149,7 @@ class QueryHelper {
int positionNumSets;
};
-QueryHelper* QueryHelper::singleton = NULL;
+QueryHelper* QueryHelper::singleton = nullptr;
//===========================================================================================
@@ -232,7 +232,8 @@ void QueryHelper::populatePositionPdxData(RegionPtr& rptr, int setSize,
for (int set = 1; set <= numSets; set++) {
for (int current = 1; current <= setSize; current++) {
- auto pos = std::make_shared<PositionPdx>(secIds[current % numSecIds], current * 100);
+ auto pos = std::make_shared<PositionPdx>(secIds[current % numSecIds],
+ current * 100);
char posname[100] = {0};
ACE_OS::sprintf(posname, "pos%d-%d", set, current);
@@ -307,7 +308,8 @@ bool QueryHelper::verifyRS(SelectResultsPtr& resultSet, int expectedRows) {
return false;
}
- ResultSetPtr rsptr = std::static_pointer_cast<GF_UNWRAP_SP(ResultSetPtr)>(resultSet);
+ ResultSetPtr rsptr =
+ std::static_pointer_cast<GF_UNWRAP_SP(ResultSetPtr)>(resultSet);
int foundRows = 0;
@@ -330,11 +332,12 @@ bool QueryHelper::verifySS(SelectResultsPtr& structSet, int expectedRows,
if (expectedRows == 0 && expectedFields == 0) {
return true; // quite possible we got a null set back.
}
- printf("we have structSet itself NULL \n");
+ printf("we have structSet itself nullptr \n");
return false;
}
- StructSetPtr ssptr = std::static_pointer_cast<GF_UNWRAP_SP(StructSetPtr)>(structSet);
+ StructSetPtr ssptr =
+ std::static_pointer_cast<GF_UNWRAP_SP(StructSetPtr)>(structSet);
int foundRows = 0;
@@ -345,8 +348,8 @@ bool QueryHelper::verifySS(SelectResultsPtr& structSet, int expectedRows,
Struct* siptr = dynamic_cast<Struct*>(ser.get());
- if (siptr == NULL) {
- printf("siptr is NULL \n\n");
+ if (siptr == nullptr) {
+ printf("siptr is nullptr \n\n");
return false;
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/QueryStrings.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/QueryStrings.hpp b/src/cppcache/integration-test/QueryStrings.hpp
index 01d53b6..669d44d 100644
--- a/src/cppcache/integration-test/QueryStrings.hpp
+++ b/src/cppcache/integration-test/QueryStrings.hpp
@@ -123,9 +123,9 @@ const QueryStrings resultsetQueries[RS_ARRAY_SIZE] = {
// 9 idx
,
- QRY(constants, "select distinct * from /Portfolios where ID = NULL"),
+ QRY(constants, "select distinct * from /Portfolios where ID = nullptr"),
QRY(constants, "select distinct * from /Portfolios where ID = UNDEFINED"),
- QRY(constants, "select distinct * from /Portfolios where NULL"),
+ QRY(constants, "select distinct * from /Portfolios where nullptr"),
QRY(constants, "select distinct * from /Portfolios where UNDEFINED"),
QRY(constants, "select distinct * from /Portfolios where TRUE"),
QRY(constants, "select distinct * from /Portfolios where 1=1"),
@@ -153,7 +153,7 @@ const QueryStrings resultsetQueries[RS_ARRAY_SIZE] = {
"where element(select distinct * from /Portfolios.keySet p_k "
"where p_k = this.key ) = 'port1-3' and this.value.status = "
"'inactive'"),
- QRY(functions, "select distinct nvl(NULL, 'foundNull') from /Portfolios")
+ QRY(functions, "select distinct nvl(nullptr, 'foundNull') from /Portfolios")
//, QRY(functions , "select distinct nvl('notNull', 'foundNull')
//= 'notNull' from /Portfolios" )
,
@@ -223,7 +223,7 @@ const QueryStrings resultsetQueries[RS_ARRAY_SIZE] = {
"remove('5')!= null")
//, QRY(unsupported, "element(select distinct * from /Portfolios
// where ID =1).status")
- //, QRY(unsupported, "select distinct * from NULL")
+ //, QRY(unsupported, "select distinct * from nullptr")
//, QRY(unsupported, "select distinct * from UNDEFINED")
,
@@ -313,7 +313,7 @@ const int constantExpectedRowsPQRS[6] = {5, 7, 8, 10, 11, 12};
const QueryStrings resultsetQueriesOPL[RSOPL_ARRAY_SIZE] =
{ // queries returning result sets via ObjectPartList
- // 0 idx
+ // 0 idx
QRY(singleRegion, "select * from /Portfolios2"),
QRY(singleRegion, "select * from /Portfolios2 limit 5"),
QRY(singleRegion, "select count(*) from /Portfolios2"),
@@ -363,7 +363,7 @@ const QueryStrings structsetQueries[SS_ARRAY_SIZE] = {
// 5 idx
,
QRY(constants,
- "select distinct id, positions from /Portfolios where ID = NULL"),
+ "select distinct id, positions from /Portfolios where ID = nullptr"),
QRY(constants,
"select distinct pkid, getPk() from /Portfolios where ID = UNDEFINED"),
QRY(constants,
@@ -401,7 +401,8 @@ const QueryStrings structsetQueries[SS_ARRAY_SIZE] = {
"where element(select distinct p.ID, p.status, p.getType from "
"/Portfolios p where p.ID = oP.ID).status = 'inactive'"),
QRY(functions,
- "select distinct nvl(NULL, 'foundNull')='foundNull', 'dummy Col' from "
+ "select distinct nvl(nullptr, 'foundNull')='foundNull', 'dummy Col' "
+ "from "
"/Portfolios"),
QRY(functions,
"select distinct nvl('notNull', 'foundNull') as NtNul , 'dummy Col' as "
@@ -535,7 +536,7 @@ const QueryStrings structsetParamQueries[SSP_ARRAY_SIZE] = {
"where element(select distinct p.ID, p.status, p.getType from "
"/Portfolios p where p.ID = oP.ID).status = $1"),
QRY(functions,
- "select distinct nvl(NULL, $1)=$2, 'dummy Col' from /Portfolios"),
+ "select distinct nvl(nullptr, $1)=$2, 'dummy Col' from /Portfolios"),
QRY(functions,
"select distinct nvl($1, $2) as NtNul , $3 as Dumbo from /Portfolios"),
QRY(functions,
@@ -610,17 +611,22 @@ const int constantExpectedRowsSSPQ[10] = {2, 4, 5, 6, 7, 8, 9, 10, 11, 12};
const QueryStrings regionQueries[RQ_ARRAY_SIZE] =
{ // intended to be run on the /Portfolios region.query API
- // 0 idx
- QRY(regionQuery, "ID = 2"), QRY(regionQuery, "ID != 2"),
- QRY(regionQuery, "ID = NULL"), QRY(unsupported, "ID = UNDEFINED")
+ // 0 idx
+ QRY(regionQuery, "ID = 2"),
+ QRY(regionQuery, "ID != 2"),
+ QRY(regionQuery, "ID = nullptr"),
+ QRY(unsupported, "ID = UNDEFINED")
// 4 idx
,
- QRY(regionQuery, "NULL"), QRY(regionQuery, "UNDEFINED"),
+ QRY(regionQuery, "nullptr"),
+ QRY(regionQuery, "UNDEFINED"),
QRY(regionQuery, "UNDEFINED = 1"),
QRY(regionQuery, "IS_UNDEFINED(UNDEFINED)"),
QRY(regionQuery, "IS_DEFINED(TRUE)"),
- QRY(regionQuery, "IS_UNDEFINED(ID)"), QRY(regionQuery, "TRUE"),
- QRY(regionQuery, "FALSE"), QRY(regionQuery, "1=1"),
+ QRY(regionQuery, "IS_UNDEFINED(ID)"),
+ QRY(regionQuery, "TRUE"),
+ QRY(regionQuery, "FALSE"),
+ QRY(regionQuery, "1=1"),
QRY(regionQuery, "'a' <> 'a'")
// 14 idx
,
@@ -663,9 +669,9 @@ const QueryStrings cqResultsetQueries[CQRS_ARRAY_SIZE] = {
// 3 idx
,
- QRY(constants, "select * from /Portfolios where ID = NULL"),
+ QRY(constants, "select * from /Portfolios where ID = nullptr"),
QRY(constants, "select * from /Portfolios where ID = UNDEFINED"),
- QRY(constants, "select * from /Portfolios where NULL"),
+ QRY(constants, "select * from /Portfolios where nullptr"),
QRY(constants, "select * from /Portfolios where UNDEFINED"),
QRY(constants, "select * from /Portfolios where TRUE"),
QRY(constants, "select * from /Portfolios where 1=1"),
@@ -715,7 +721,7 @@ const QueryStrings cqResultsetQueries[CQRS_ARRAY_SIZE] = {
//, QRY(unsupported, "element(select * from /Portfolios where ID
//=1).status")
,
- QRY(unsupported, "select * from NULL"),
+ QRY(unsupported, "select * from nullptr"),
QRY(unsupported, "select * from UNDEFINED"),
LQRY(misc,
"select * from /Portfolios WHERE NOT (select * from "
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/ThinClientDistOps.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDistOps.hpp b/src/cppcache/integration-test/ThinClientDistOps.hpp
index eb3c0e0..339d179 100644
--- a/src/cppcache/integration-test/ThinClientDistOps.hpp
+++ b/src/cppcache/integration-test/ThinClientDistOps.hpp
@@ -48,7 +48,7 @@ using namespace test;
#define SERVER2 s2p2
#define CREATE_TWICE_KEY "__create_twice_key"
#define CREATE_TWICE_VALUE "__create_twice_value"
-CacheHelper* cacheHelper = NULL;
+CacheHelper* cacheHelper = nullptr;
static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 0;
@@ -67,7 +67,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, Alter_Client_Grid_Property_2)
END_TASK_DEFINITION
void initClient(const bool isthinClient) {
- if (cacheHelper == NULL) {
+ if (cacheHelper == nullptr) {
PropertiesPtr config = Properties::create();
if (g_isGridClient) {
config->insert("grid-client", "true");
@@ -79,14 +79,14 @@ void initClient(const bool isthinClient) {
}
void cleanProc() {
- if (cacheHelper != NULL) {
+ if (cacheHelper != nullptr) {
delete cacheHelper;
- cacheHelper = NULL;
+ cacheHelper = nullptr;
}
}
CacheHelper* getHelper() {
- ASSERT(cacheHelper != NULL, "No cacheHelper initialized.");
+ ASSERT(cacheHelper != nullptr, "No cacheHelper initialized.");
return cacheHelper;
}
@@ -118,7 +118,7 @@ void _verifyEntry(const char* name, const char* key, const char* val,
if (noKey == false) { // need to find the key!
ASSERT(regPtr->containsKey(keyPtr), "Key not found in region.");
}
- if (val != NULL) { // need to have a value!
+ if (val != nullptr) { // need to have a value!
ASSERT(regPtr->containsValueForKey(keyPtr), "Value not found in region.");
}
@@ -138,7 +138,7 @@ void _verifyEntry(const char* name, const char* key, const char* val,
}
ASSERT(containsKeyCnt < MAX, "Key found in region.");
}
- if (val == NULL) {
+ if (val == nullptr) {
if (regPtr->containsValueForKey(keyPtr)) {
containsValueCnt++;
} else {
@@ -147,8 +147,9 @@ void _verifyEntry(const char* name, const char* key, const char* val,
ASSERT(containsValueCnt < MAX, "Value found in region.");
}
- if (val != NULL) {
- auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
+ if (val != nullptr) {
+ auto checkPtr =
+ std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr));
ASSERT(checkPtr != nullptr, "Value Ptr should not be null.");
char buf[1024];
@@ -270,14 +271,16 @@ void createAndVerifyEntry(const char* name) {
int64_t int64Key = 9223372036854775807LL; // INT64_MAX
int64_t in64Value = 9223372036854775807LL; // INT64_MAX
regPtr->create(int64Key, in64Value);
- auto longRetValue = std::dynamic_pointer_cast<CacheableInt64>(regPtr->get(int64Key));
+ auto longRetValue =
+ std::dynamic_pointer_cast<CacheableInt64>(regPtr->get(int64Key));
ASSERT(in64Value == longRetValue->value(),
"longRetValue and longvalue should match");
int64_t int64Key1 = 9223372036854775807LL;
try {
regPtr->create(int64Key1, in64Value);
- auto longRetValue = std::dynamic_pointer_cast<CacheableInt64>(regPtr->get(int64Key));
+ auto longRetValue =
+ std::dynamic_pointer_cast<CacheableInt64>(regPtr->get(int64Key));
FAIL("Expected EntryExistException here");
} catch (EntryExistsException& e) {
LOG(" Expected EntryExistsException exception thrown by localCreate");
@@ -450,7 +453,8 @@ void doGetAgain(const char* name, const char* key, const char* value) {
fflush(stdout);
ASSERT(regPtr != nullptr, "Region not found.");
- auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); // force a netsearch
+ auto checkPtr = std::dynamic_pointer_cast<CacheableString>(
+ regPtr->get(keyPtr)); // force a netsearch
if (checkPtr != nullptr) {
LOG("checkPtr is not null");
@@ -459,7 +463,7 @@ void doGetAgain(const char* name, const char* key, const char* value) {
checkPtr->asChar(), key);
LOG(buf);
} else {
- LOG("checkPtr is NULL");
+ LOG("checkPtr is nullptr");
}
verifyEntry(name, key, value);
LOG("GetAgain complete.");
@@ -488,7 +492,8 @@ void doNetsearch(const char* name, const char* key, const char* value) {
"Value should not have been found in region.");
count++;
}
- auto checkPtr = std::dynamic_pointer_cast<CacheableString>(regPtr->get(keyPtr)); // force a netsearch
+ auto checkPtr = std::dynamic_pointer_cast<CacheableString>(
+ regPtr->get(keyPtr)); // force a netsearch
if (checkPtr != nullptr) {
LOG("checkPtr is not null");
@@ -497,7 +502,7 @@ void doNetsearch(const char* name, const char* key, const char* value) {
checkPtr->asChar(), key);
LOG(buf);
} else {
- LOG("checkPtr is NULL");
+ LOG("checkPtr is nullptr");
}
verifyEntry(name, key, value);
LOG("Netsearch complete.");
@@ -555,14 +560,14 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreatePoolForUpdateLocatorList)
/*
PoolPtr createPool(const char* poolName, const char* locators, const char*
serverGroup,
- const char* servers = NULL, int redundancy = 0, bool
+ const char* servers = nullptr, int redundancy = 0, bool
clientNotification = false, int subscriptionAckInterval = -1,
int connections = -1, int loadConditioningInterval = - 1, bool
isMultiuserMode = false, int updateLocatorListInterval = 5000 )
*/
initClient(true);
- getHelper()->createPool("__TESTPOOL1_", locatorsG, NULL, 0, false, -1, -1,
- -1, false);
+ getHelper()->createPool("__TESTPOOL1_", locatorsG, nullptr, 0, false, -1,
+ -1, -1, false);
LOG("CreatePoolForUpdateLocatorList complete.");
}
END_TASK_DEFINITION
@@ -572,14 +577,14 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreatePoolForDontUpdateLocatorList)
/*
PoolPtr createPool(const char* poolName, const char* locators, const char*
serverGroup,
- const char* servers = NULL, int redundancy = 0, bool
+ const char* servers = nullptr, int redundancy = 0, bool
clientNotification = false, int subscriptionAckInterval = -1,
int connections = -1, int loadConditioningInterval = - 1, bool
isMultiuserMode = false, int updateLocatorListInterval = 5000 )
*/
initClient(true);
- getHelper()->createPool("__TESTPOOL1_", locatorsG, NULL, 0, false, -1, -1,
- -1, false);
+ getHelper()->createPool("__TESTPOOL1_", locatorsG, nullptr, 0, false, -1,
+ -1, -1, false);
LOG("CreatePoolForDontUpdateLocatorList complete.");
}
END_TASK_DEFINITION
http://git-wip-us.apache.org/repos/asf/geode-native/blob/11467dd9/src/cppcache/integration-test/ThinClientDistOps2.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientDistOps2.hpp b/src/cppcache/integration-test/ThinClientDistOps2.hpp
index 6e1f851..7b3a9f1 100644
--- a/src/cppcache/integration-test/ThinClientDistOps2.hpp
+++ b/src/cppcache/integration-test/ThinClientDistOps2.hpp
@@ -85,8 +85,8 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER2, CreateServer2And3_Locator)
{
- if (isLocalServer) CacheHelper::initServer(2, NULL, locatorsG);
- if (isLocalServer) CacheHelper::initServer(3, NULL, locatorsG);
+ if (isLocalServer) CacheHelper::initServer(2, nullptr, locatorsG);
+ if (isLocalServer) CacheHelper::initServer(3, nullptr, locatorsG);
LOG("SERVER23 started");
}
END_TASK_DEFINITION
@@ -200,8 +200,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll)
reg0->getAll(keys0, values, exceptions);
ASSERT(values->size() == 2, "Expected 2 values");
ASSERT(exceptions->size() == 0, "Expected no exceptions");
- auto val0 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key0));
- auto val1 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key1));
+ auto val0 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key0));
+ auto val1 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key1));
ASSERT(strcmp(_nvals[0], val0->asChar()) == 0, "Got unexpected value");
ASSERT(strcmp(_nvals[1], val1->asChar()) == 0, "Got unexpected value");
@@ -220,8 +222,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll)
reg1->getAll(keys1, values, exceptions, true);
ASSERT(values->size() == 2, "Expected 2 values");
ASSERT(exceptions->size() == 0, "Expected no exceptions");
- auto val2 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key2));
- auto val3 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key3));
+ auto val2 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key2));
+ auto val3 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key3));
ASSERT(strcmp(_nvals[2], val2->asChar()) == 0, "Got unexpected value");
ASSERT(strcmp(_vals[3], val3->asChar()) == 0, "Got unexpected value");
@@ -233,7 +237,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll)
verifyEntry(_regionNames[1], _keys[2], _nvals[2], true);
verifyEntry(_regionNames[1], _keys[3], _vals[3], true);
- // also check with NULL values that region is properly populated
+ // also check with nullptr values that region is properly populated
reg1->localInvalidate(key3);
values = nullptr;
exceptions->clear();
@@ -297,8 +301,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll_Pool)
reg0->getAll(keys0, values, exceptions);
ASSERT(values->size() == 2, "Expected 2 values");
ASSERT(exceptions->size() == 0, "Expected no exceptions");
- auto val0 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key0));
- auto val1 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key1));
+ auto val0 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key0));
+ auto val1 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key1));
ASSERT(strcmp(_nvals[0], val0->asChar()) == 0, "Got unexpected value");
ASSERT(strcmp(_nvals[1], val1->asChar()) == 0, "Got unexpected value");
@@ -317,8 +323,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll_Pool)
reg1->getAll(keys1, values, exceptions, true);
ASSERT(values->size() == 2, "Expected 2 values");
ASSERT(exceptions->size() == 0, "Expected no exceptions");
- auto val2 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key2));
- auto val3 = std::dynamic_pointer_cast<CacheableString>(values->operator[](key3));
+ auto val2 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key2));
+ auto val3 =
+ std::dynamic_pointer_cast<CacheableString>(values->operator[](key3));
ASSERT(strcmp(_nvals[2], val2->asChar()) == 0, "Got unexpected value");
ASSERT(strcmp(_vals[3], val3->asChar()) == 0, "Got unexpected value");
@@ -330,7 +338,7 @@ DUNIT_TASK_DEFINITION(CLIENT1, Client1GetAll_Pool)
verifyEntry(_regionNames[1], _keys[2], _nvals[2], true);
verifyEntry(_regionNames[1], _keys[3], _vals[3], true);
- // also check with NULL values that region is properly populated
+ // also check with nullptr values that region is properly populated
reg1->localInvalidate(key3);
values = nullptr;
exceptions->clear();