Merge in namespace fixes for binary protocol.
[awesomized/libmemcached] / libmemcached / common.h
index e350149bded5249b572de9638649532f5447d1bb..98072cb3138d4266994173ff4d59b63e1eadd838 100644 (file)
 
 #include <config.h>
 
+#ifdef __cplusplus
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <ctype.h>
+#else
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
+#include <time.h>
 #endif
 
-/* Define this here, which will turn on the visibilty controls while we're
- * building libmemcached.
- */
-#define BUILDING_LIBMEMCACHED 1
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <unistd.h>
 
+#include <libmemcached/memcached.h>
+#include <libmemcached/watchpoint.h>
+#include <libmemcached/is.h>
+#include <libmemcached/namespace.h>
 
-#include "libmemcached/memcached.h"
-#include "libmemcached/watchpoint.h"
-#include "libmemcached/is.h"
-#include "libmemcached/prefix_key.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct memcached_server_st * memcached_server_write_instance_st;
 
@@ -87,18 +83,24 @@ LIBMEMCACHED_LOCAL
 memcached_return_t memcached_server_execute(memcached_st *ptr,
                                             memcached_server_execute_fn callback,
                                             void *context);
+#ifdef __cplusplus
+} // extern "C"
+#endif
 
 
 /* These are private not to be installed headers */
-#include "libmemcached/io.h"
-#include "libmemcached/do.h"
-#include "libmemcached/internal.h"
-#include "libmemcached/array.h"
-#include "libmemcached/libmemcached_probes.h"
-#include "libmemcached/memcached/protocol_binary.h"
-#include "libmemcached/byteorder.h"
-#include "libmemcached/response.h"
-#include "libmemcached/prefix_key.h"
+#include <libmemcached/error.hpp>
+#include <libmemcached/memory.h>
+#include <libmemcached/io.h>
+#include <libmemcached/do.hpp>
+#include <libmemcached/internal.h>
+#include <libmemcached/array.h>
+#include <libmemcached/libmemcached_probes.h>
+#include <libmemcached/memcached/protocol_binary.h>
+#include <libmemcached/byteorder.h>
+#include <libmemcached/initialize_query.h>
+#include <libmemcached/response.h>
+#include <libmemcached/prefix_key.h>
 
 /* string value */
 struct memcached_continuum_item_st
@@ -140,10 +142,13 @@ memcached_return_t run_distribution(memcached_st *ptr);
 LIBMEMCACHED_LOCAL
 void set_last_disconnected_host(memcached_server_write_instance_st ptr);
 
+#ifdef __cplusplus
 LIBMEMCACHED_LOCAL
-memcached_return_t memcached_key_test(const char * const *keys,
+memcached_return_t memcached_key_test(const memcached_st& memc,
+                                      const char * const *keys,
                                       const size_t *key_length,
                                       size_t number_of_keys);
+#endif
 
 LIBMEMCACHED_LOCAL
 memcached_return_t memcached_purge(memcached_server_write_instance_st ptr);
@@ -160,7 +165,9 @@ memcached_server_st *memcached_server_create_with(const memcached_st *memc,
 static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
 {
   unlikely (key_length == 0)
+  {
     return MEMCACHED_BAD_KEY_PROVIDED;
+  }
 
   if (binary)
   {
@@ -176,26 +183,6 @@ static inline memcached_return_t memcached_validate_key_length(size_t key_length
   return MEMCACHED_SUCCESS;
 }
 
-static inline void libmemcached_free(const memcached_st *ptr, void *mem)
-{
-  ptr->allocators.free(ptr, mem, ptr->allocators.context);
-}
-
-static inline void *libmemcached_malloc(const memcached_st *ptr, const size_t size)
-{
-  return ptr->allocators.malloc(ptr, size, ptr->allocators.context);
-}
-
-static inline void *libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size)
-{
-  return ptr->allocators.realloc(ptr, mem, size, ptr->allocators.context);
-}
-
-static inline void *libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size)
-{
-  return ptr->allocators.calloc(ptr, nelem, size, ptr->allocators.context);
-}
-
 #ifdef __cplusplus
 }
 #endif