#include <stddef.h>
#include <stdint.h>
+#ifndef EXPORT_API
+#define EXPORT_API
+#endif // EXPORT_API
+
+
/* Exported types */
typedef struct leveldb_t leveldb_t;
/* DB operations */
-extern leveldb_t* leveldb_open(
+EXPORT_API extern leveldb_t* leveldb_open(
const leveldb_options_t* options,
const char* name,
char** errptr);
-extern void leveldb_close(leveldb_t* db);
+EXPORT_API extern void leveldb_close(leveldb_t* db);
-extern void leveldb_put(
+EXPORT_API extern void leveldb_put(
leveldb_t* db,
const leveldb_writeoptions_t* options,
const char* key, size_t keylen,
const char* val, size_t vallen,
char** errptr);
-extern void leveldb_delete(
+EXPORT_API extern void leveldb_delete(
leveldb_t* db,
const leveldb_writeoptions_t* options,
const char* key, size_t keylen,
char** errptr);
-extern void leveldb_write(
+EXPORT_API extern void leveldb_write(
leveldb_t* db,
const leveldb_writeoptions_t* options,
leveldb_writebatch_t* batch,
/* Returns NULL if not found. A malloc()ed array otherwise.
Stores the length of the array in *vallen. */
-extern char* leveldb_get(
+EXPORT_API extern char* leveldb_get(
leveldb_t* db,
const leveldb_readoptions_t* options,
const char* key, size_t keylen,
size_t* vallen,
char** errptr);
-extern leveldb_iterator_t* leveldb_create_iterator(
+EXPORT_API extern leveldb_iterator_t* leveldb_create_iterator(
leveldb_t* db,
const leveldb_readoptions_t* options);
-extern const leveldb_snapshot_t* leveldb_create_snapshot(
+EXPORT_API extern const leveldb_snapshot_t* leveldb_create_snapshot(
leveldb_t* db);
-extern void leveldb_release_snapshot(
+EXPORT_API extern void leveldb_release_snapshot(
leveldb_t* db,
const leveldb_snapshot_t* snapshot);
/* Returns NULL if property name is unknown.
Else returns a pointer to a malloc()-ed null-terminated value. */
-extern char* leveldb_property_value(
+EXPORT_API extern char* leveldb_property_value(
leveldb_t* db,
const char* propname);
-extern void leveldb_approximate_sizes(
+EXPORT_API extern void leveldb_approximate_sizes(
leveldb_t* db,
int num_ranges,
const char* const* range_start_key, const size_t* range_start_key_len,
/* Management operations */
-extern void leveldb_destroy_db(
+EXPORT_API extern void leveldb_destroy_db(
const leveldb_options_t* options,
const char* name,
char** errptr);
-extern void leveldb_repair_db(
+EXPORT_API extern void leveldb_repair_db(
const leveldb_options_t* options,
const char* name,
char** errptr);
/* Iterator */
-extern void leveldb_iter_destroy(leveldb_iterator_t*);
-extern unsigned char leveldb_iter_valid(const leveldb_iterator_t*);
-extern void leveldb_iter_seek_to_first(leveldb_iterator_t*);
-extern void leveldb_iter_seek_to_last(leveldb_iterator_t*);
-extern void leveldb_iter_seek(leveldb_iterator_t*, const char* k, size_t klen);
-extern void leveldb_iter_next(leveldb_iterator_t*);
-extern void leveldb_iter_prev(leveldb_iterator_t*);
-extern const char* leveldb_iter_key(const leveldb_iterator_t*, size_t* klen);
-extern const char* leveldb_iter_value(const leveldb_iterator_t*, size_t* vlen);
-extern void leveldb_iter_get_error(const leveldb_iterator_t*, char** errptr);
+EXPORT_API extern void leveldb_iter_destroy(leveldb_iterator_t*);
+EXPORT_API extern unsigned char leveldb_iter_valid(const leveldb_iterator_t*);
+EXPORT_API extern void leveldb_iter_seek_to_first(leveldb_iterator_t*);
+EXPORT_API extern void leveldb_iter_seek_to_last(leveldb_iterator_t*);
+EXPORT_API extern void leveldb_iter_seek(leveldb_iterator_t*, const char* k, size_t klen);
+EXPORT_API extern void leveldb_iter_next(leveldb_iterator_t*);
+EXPORT_API extern void leveldb_iter_prev(leveldb_iterator_t*);
+EXPORT_API extern const char* leveldb_iter_key(const leveldb_iterator_t*, size_t* klen);
+EXPORT_API extern const char* leveldb_iter_value(const leveldb_iterator_t*, size_t* vlen);
+EXPORT_API extern void leveldb_iter_get_error(const leveldb_iterator_t*, char** errptr);
/* Write batch */
-extern leveldb_writebatch_t* leveldb_writebatch_create();
-extern void leveldb_writebatch_destroy(leveldb_writebatch_t*);
-extern void leveldb_writebatch_clear(leveldb_writebatch_t*);
-extern void leveldb_writebatch_put(
+EXPORT_API extern leveldb_writebatch_t* leveldb_writebatch_create();
+EXPORT_API extern void leveldb_writebatch_destroy(leveldb_writebatch_t*);
+EXPORT_API extern void leveldb_writebatch_clear(leveldb_writebatch_t*);
+EXPORT_API extern void leveldb_writebatch_put(
leveldb_writebatch_t*,
const char* key, size_t klen,
const char* val, size_t vlen);
-extern void leveldb_writebatch_delete(
+EXPORT_API extern void leveldb_writebatch_delete(
leveldb_writebatch_t*,
const char* key, size_t klen);
-extern void leveldb_writebatch_iterate(
+EXPORT_API extern void leveldb_writebatch_iterate(
leveldb_writebatch_t*,
void* state,
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
/* Options */
-extern leveldb_options_t* leveldb_options_create();
-extern void leveldb_options_destroy(leveldb_options_t*);
-extern void leveldb_options_set_comparator(
+EXPORT_API extern leveldb_options_t* leveldb_options_create();
+EXPORT_API extern void leveldb_options_destroy(leveldb_options_t*);
+EXPORT_API extern void leveldb_options_set_comparator(
leveldb_options_t*,
leveldb_comparator_t*);
-extern void leveldb_options_set_create_if_missing(
+EXPORT_API extern void leveldb_options_set_create_if_missing(
leveldb_options_t*, unsigned char);
-extern void leveldb_options_set_error_if_exists(
+EXPORT_API extern void leveldb_options_set_error_if_exists(
leveldb_options_t*, unsigned char);
-extern void leveldb_options_set_paranoid_checks(
+EXPORT_API extern void leveldb_options_set_paranoid_checks(
leveldb_options_t*, unsigned char);
-extern void leveldb_options_set_env(leveldb_options_t*, leveldb_env_t*);
-extern void leveldb_options_set_info_log(leveldb_options_t*, leveldb_logger_t*);
-extern void leveldb_options_set_write_buffer_size(leveldb_options_t*, size_t);
-extern void leveldb_options_set_max_open_files(leveldb_options_t*, int);
-extern void leveldb_options_set_cache(leveldb_options_t*, leveldb_cache_t*);
-extern void leveldb_options_set_block_size(leveldb_options_t*, size_t);
-extern void leveldb_options_set_block_restart_interval(leveldb_options_t*, int);
+EXPORT_API extern void leveldb_options_set_env(leveldb_options_t*, leveldb_env_t*);
+EXPORT_API extern void leveldb_options_set_info_log(leveldb_options_t*, leveldb_logger_t*);
+EXPORT_API extern void leveldb_options_set_write_buffer_size(leveldb_options_t*, size_t);
+EXPORT_API extern void leveldb_options_set_max_open_files(leveldb_options_t*, int);
+EXPORT_API extern void leveldb_options_set_cache(leveldb_options_t*, leveldb_cache_t*);
+EXPORT_API extern void leveldb_options_set_block_size(leveldb_options_t*, size_t);
+EXPORT_API extern void leveldb_options_set_block_restart_interval(leveldb_options_t*, int);
enum {
leveldb_no_compression = 0,
leveldb_snappy_compression = 1
};
-extern void leveldb_options_set_compression(leveldb_options_t*, int);
+EXPORT_API extern void leveldb_options_set_compression(leveldb_options_t*, int);
/* Comparator */
-extern leveldb_comparator_t* leveldb_comparator_create(
+EXPORT_API extern leveldb_comparator_t* leveldb_comparator_create(
void* state,
void (*destructor)(void*),
int (*compare)(
const char* a, size_t alen,
const char* b, size_t blen),
const char* (*name)(void*));
-extern void leveldb_comparator_destroy(leveldb_comparator_t*);
+EXPORT_API extern void leveldb_comparator_destroy(leveldb_comparator_t*);
/* Read options */
-extern leveldb_readoptions_t* leveldb_readoptions_create();
-extern void leveldb_readoptions_destroy(leveldb_readoptions_t*);
-extern void leveldb_readoptions_set_verify_checksums(
+EXPORT_API extern leveldb_readoptions_t* leveldb_readoptions_create();
+EXPORT_API extern void leveldb_readoptions_destroy(leveldb_readoptions_t*);
+EXPORT_API extern void leveldb_readoptions_set_verify_checksums(
leveldb_readoptions_t*,
unsigned char);
-extern void leveldb_readoptions_set_fill_cache(
+EXPORT_API extern void leveldb_readoptions_set_fill_cache(
leveldb_readoptions_t*, unsigned char);
-extern void leveldb_readoptions_set_snapshot(
+EXPORT_API extern void leveldb_readoptions_set_snapshot(
leveldb_readoptions_t*,
const leveldb_snapshot_t*);
/* Write options */
-extern leveldb_writeoptions_t* leveldb_writeoptions_create();
-extern void leveldb_writeoptions_destroy(leveldb_writeoptions_t*);
-extern void leveldb_writeoptions_set_sync(
+EXPORT_API extern leveldb_writeoptions_t* leveldb_writeoptions_create();
+EXPORT_API extern void leveldb_writeoptions_destroy(leveldb_writeoptions_t*);
+EXPORT_API extern void leveldb_writeoptions_set_sync(
leveldb_writeoptions_t*, unsigned char);
/* Cache */
-extern leveldb_cache_t* leveldb_cache_create_lru(size_t capacity);
-extern void leveldb_cache_destroy(leveldb_cache_t* cache);
+EXPORT_API extern leveldb_cache_t* leveldb_cache_create_lru(size_t capacity);
+EXPORT_API extern void leveldb_cache_destroy(leveldb_cache_t* cache);
/* Env */
-extern leveldb_env_t* leveldb_create_default_env();
-extern void leveldb_env_destroy(leveldb_env_t*);
+EXPORT_API extern leveldb_env_t* leveldb_create_default_env();
+EXPORT_API extern void leveldb_env_destroy(leveldb_env_t*);
#ifdef __cplusplus
} /* end extern "C" */
#include <stdint.h>
#include "leveldb/status.h"
+#ifndef EXPORT_API
+#define EXPORT_API
+#endif // EXPORT_API
+
+
namespace leveldb {
class FileLock;
class Slice;
class WritableFile;
-class Env {
+class EXPORT_API Env {
public:
Env() { }
virtual ~Env();
};
// A file abstraction for reading sequentially through a file
-class SequentialFile {
+class EXPORT_API SequentialFile {
public:
SequentialFile() { }
virtual ~SequentialFile();
};
// A file abstraction for randomly reading the contents of a file.
-class RandomAccessFile {
+class EXPORT_API RandomAccessFile {
public:
RandomAccessFile() { }
virtual ~RandomAccessFile();
// A file abstraction for sequential writing. The implementation
// must provide buffering since callers may append small fragments
// at a time to the file.
-class WritableFile {
+class EXPORT_API WritableFile {
public:
WritableFile() { }
virtual ~WritableFile();
};
// An interface for writing log messages.
-class Logger {
+class EXPORT_API Logger {
public:
Logger() { }
virtual ~Logger();
// Identifies a locked file.
-class FileLock {
+class EXPORT_API FileLock {
public:
FileLock() { }
virtual ~FileLock();
};
// Log the specified data to *info_log if info_log is non-NULL.
-extern void Log(Logger* info_log, const char* format, ...)
+EXPORT_API extern void Log(Logger* info_log, const char* format, ...)
# if defined(__GNUC__) || defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3)))
# endif
;
// A utility routine: write "data" to the named file.
-extern Status WriteStringToFile(Env* env, const Slice& data,
+EXPORT_API extern Status WriteStringToFile(Env* env, const Slice& data,
const std::string& fname);
// A utility routine: read contents of named file into *data
-extern Status ReadFileToString(Env* env, const std::string& fname,
+EXPORT_API extern Status ReadFileToString(Env* env, const std::string& fname,
std::string* data);
// An implementation of Env that forwards all calls to another Env.
// May be useful to clients who wish to override just part of the
// functionality of another Env.
-class EnvWrapper : public Env {
+class EXPORT_API EnvWrapper : public Env {
public:
// Initialize an EnvWrapper that delegates all calls to *t
explicit EnvWrapper(Env* t) : target_(t) { }