View on GitHub
ejpp
Embedded JSON Database engine for C++11/14
Namespaces | Classes | Enumerations | Functions | Variables
ejdb Namespace Reference

Contains the main EJPP classes, etc. More...

Namespaces

 detail
 Implementation details.
 

Classes

struct  adopt_transaction_t
 Tag type for expressing an adopted transaction. More...
 
struct  collection
 Class representing an EJDB collection. More...
 
struct  db
 Main point of access to EJDB. More...
 
struct  ejdb_deleter
 Functor allowing for the deletion of opaque EJDB pointers. More...
 
class  error_category
 The category type used for all EJDB errors. More...
 
struct  query
 Class representing an EJDB query. More...
 
struct  transaction_guard
 Simple collection::transaction_t wrapper for exception safe operation using RAII More...
 
struct  try_transaction_t
 Tag type for expressing a transaction that only tries to start. More...
 
struct  unique_transaction
 Defines an exception-safe wrapper around collection::transaction_t with unique ownership. More...
 

Enumerations

enum  db_mode {
  db_mode::read = 1 << 0, db_mode::write = 1 << 1, db_mode::create = 1 << 2, db_mode::truncate = 1 << 3,
  db_mode::nolock = 1 << 4, db_mode::noblock = 1 << 5, db_mode::trans_sync = 1 << 6
}
 Database open modes. More...
 
enum  errc {
  errc::success, errc::thread_error, errc::invalid_operation, errc::file_not_found,
  errc::no_permission, errc::invalid_tc_metadata, errc::invalid_record_header, errc::open_error,
  errc::close_error, errc::trunc_error, errc::sync_error, errc::stat_error,
  errc::seek_error, errc::read_error, errc::write_error, errc::mmap_error,
  errc::lock_error, errc::unlink_error, errc::rename_error, errc::mkdir_error,
  errc::rmdir_error, errc::keep, errc::no_record_found, errc::illegal_transaction_state,
  errc::miscellaneous = 9999, errc::invalid_collection_name = 9000, errc::invalid_bson = 9001, errc::invalid_bson_oid = 9002,
  errc::invalid_query_control_field = 9003, errc::query_field_require_array = 9004, errc::invalid_metadata = 9005, errc::invalid_field_path = 9006,
  errc::invalid_query_regex = 9007, errc::query_result_sort_error = 9008, errc::query_error = 9009, errc::query_update_failed = 9010,
  errc::query_elemmatch_limit = 9011, errc::query_cannot_mix_include_exclude = 9012, errc::query_invalid_action = 9013, errc::too_many_collections = 9014,
  errc::import_export_error = 9015, errc::json_parse_failed = 9016, errc::bson_too_large = 9017, errc::invalid_command = 9018
}
 Error codes. Tokyo Cabinet errors up to errc::miscellaneous. More...
 
enum  index_mode {
  index_mode::drop = 1 << 0, index_mode::drop_all = 1 << 1, index_mode::optimize = 1 << 2, index_mode::rebuild = 1 << 3,
  index_mode::number = 1 << 4, index_mode::string = 1 << 5, index_mode::array = 1 << 6, index_mode::istring = 1 << 7
}
 Index modes, index types. More...
 
enum  query_search_mode { query_search_mode::normal = 0, query_search_mode::count_only = 1, query_search_mode::first_only = 1 << 1 }
 Query search mode flags. More...
 

Functions

template<>
uint32_t execute_query_impl< query_search_mode::count_only > (std::weak_ptr< EJDB > m_db, EJCOLL *m_coll, EJQ *qry)
 Instantiated with flags == query_search_mode::count_only. Executes a query in count-only mode. More...
 
template<>
uint32_t execute_query_impl< query_search_mode::count_only|query_search_mode::first_only > (std::weak_ptr< EJDB > m_db, EJCOLL *m_coll, EJQ *qry)
 Instantiated with flags == query_search_mode::count_only | query_search_mode::first_only. Executes a query in count-only mode, but only counts up to one (1). More...
 
template<>
std::vector< char > execute_query_impl< query_search_mode::first_only > (std::weak_ptr< EJDB > m_db, EJCOLL *m_coll, EJQ *qry)
 Instantiated with flags == query_search_mode::first_only. Executes a query in first-only mode. More...
 
template<>
std::vector< std::vector< char > > execute_query_impl< query_search_mode::normal > (std::weak_ptr< EJDB > m_db, EJCOLL *m_coll, EJQ *qry)
 Instantiated with flags == query_search_mode::normal. Executes a query in normal mode. More...
 
std::error_code make_error_code (errc ecode) noexcept
 Makes an std::error_code from an ejdb::errc.
 
constexpr query_search_mode operator& (query_search_mode lhs, query_search_mode rhs) noexcept
 Allow bitwise-AND of query_search_mode.
 
constexpr query_search_modeoperator&= (query_search_mode &lhs, query_search_mode rhs) noexcept
 Allow bitwise-AND-assign of query_search_mode.
 
constexpr db_mode operator| (db_mode lhs, db_mode rhs) noexcept
 Allow bitwise-OR of db_mode.
 
constexpr index_mode operator| (index_mode lhs, index_mode rhs) noexcept
 Allow bitwise-OR of index_mode.
 
constexpr query_search_mode operator| (query_search_mode lhs, query_search_mode rhs) noexcept
 Allow bitwise-OR of query_search_mode.
 
constexpr db_modeoperator|= (db_mode &lhs, db_mode rhs) noexcept
 Allow bitwise-OR-assign of db_mode.
 
constexpr index_modeoperator|= (index_mode &lhs, index_mode rhs) noexcept
 Allow bitwise-OR-assign of index_mode.
 
constexpr query_search_modeoperator|= (query_search_mode &lhs, query_search_mode rhs) noexcept
 Allow bitwise-OR-assign of query_search_mode.
 

Variables

constexpr adopt_transaction_t adopt_transaction
 Tag constant for adopting a transaction.
 
constexpr try_transaction_t try_transaction {}
 Tag constant for trying to start a transaction.
 

Detailed Description

Contains the main EJPP classes, etc.

Enumeration Type Documentation

enum ejdb::db_mode
strong

Database open modes.

Enumerator
read 

Open as a reader.

write 

Open as a writer.

create 

Create if db file not exists.

truncate 

Truncate db on open.

nolock 

Open without locking.

noblock 

Lock without blocking.

trans_sync 

Synchronize every transaction.

enum ejdb::errc
strong

Error codes. Tokyo Cabinet errors up to errc::miscellaneous.

Enumerator
success 

success

thread_error 

threading error

invalid_operation 

invalid operation

file_not_found 

file not found

no_permission 

no permission

invalid_tc_metadata 

invalid meta data

invalid_record_header 

invalid record header

open_error 

open error

close_error 

close error

trunc_error 

trunc error

sync_error 

sync error

stat_error 

stat error

seek_error 

seek error

read_error 

read error

write_error 

write error

mmap_error 

mmap error

lock_error 

lock error

unlink_error 

unlink error

rename_error 

rename error

mkdir_error 

mkdir error

rmdir_error 

rmdir error

keep 

existing record

no_record_found 

no record found

illegal_transaction_state 

illegal transaction state

miscellaneous 

miscellaneous error

invalid_collection_name 

Invalid collection name.

invalid_bson 

Invalid bson object.

invalid_bson_oid 

Invalid bson object id.

invalid_query_control_field 

Invalid query control field starting with '$'.

query_field_require_array 

$strand, $stror, $in, $nin, $bt keys requires not empty array value.

invalid_metadata 

Inconsistent database metadata.

invalid_field_path 

Invalid field path value.

invalid_query_regex 

Invalid query regexp value.

query_result_sort_error 

Result set sorting error.

query_error 

Query generic error.

query_update_failed 

Updating failed.

query_elemmatch_limit 

Only one $elemMatch allowed in the fieldpath.

query_cannot_mix_include_exclude 

$fields hint cannot mix include and exclude fields.

query_invalid_action 

action key in $do block can only be one of: $join.

too_many_collections 

Exceeded the maximum number of collections per database.

import_export_error 

EJDB export/import error.

json_parse_failed 

JSON parsing failed.

bson_too_large 

BSON size is too big.

invalid_command 

Invalid ejdb command specified.

enum ejdb::index_mode
strong

Index modes, index types.

Enumerator
drop 

Drop index.

drop_all 

Drop index for all types.

optimize 

Optimize indexes.

rebuild 

Rebuild index.

number 

Number index.

string 

String index.

array 

Array token index.

istring 

Case insensitive string index.

Query search mode flags.

Enumerator
normal 

Default search mode.

count_only 

Query only count(*)

first_only 

Fetch first record only.

Function Documentation

template<>
uint32_t execute_query_impl< query_search_mode::count_only > ( std::weak_ptr< EJDB >  m_db,
EJCOLL *  m_coll,
EJQ *  qry 
)

Instantiated with flags == query_search_mode::count_only. Executes a query in count-only mode.

Returns
Number of records which match the criteria in qry.
template<>
uint32_t execute_query_impl< query_search_mode::count_only|query_search_mode::first_only > ( std::weak_ptr< EJDB >  m_db,
EJCOLL *  m_coll,
EJQ *  qry 
)

Instantiated with flags == query_search_mode::count_only | query_search_mode::first_only. Executes a query in count-only mode, but only counts up to one (1).

Returns
One (1) when at least one documents match the criteria in qry, otherwise zero (0).
template<>
std::vector< char > execute_query_impl< query_search_mode::first_only > ( std::weak_ptr< EJDB >  m_db,
EJCOLL *  m_coll,
EJQ *  qry 
)

Instantiated with flags == query_search_mode::first_only. Executes a query in first-only mode.

Returns
Only the first record which matches the criteria in qry, or std::experimental::nullopt on failure or if none match.
template<>
std::vector< std::vector< char > > execute_query_impl< query_search_mode::normal > ( std::weak_ptr< EJDB >  m_db,
EJCOLL *  m_coll,
EJQ *  qry 
)

Instantiated with flags == query_search_mode::normal. Executes a query in normal mode.

Returns
All records which match the criteria in qry. If collection or qry is invalid, an empty vector is returned.