ObjectBox C and C++ API  0.21.0
objectbox.hpp File Reference
#include <algorithm>
#include <atomic>
#include <cstring>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "objectbox.h"
#include "flatbuffers/flatbuffers.h"
Include dependency graph for objectbox.hpp:

Classes

class  obx::Exception
 Base class for ObjectBox related exceptions. Note that there are currently 3 main sub types: IllegalArgumentException, IllegalStateException, and, for all other error types, DbException. More...
 
class  obx::IllegalArgumentException
 Thrown when the passed arguments are illegal. More...
 
class  obx::IllegalStateException
 Thrown when a request does not make sense in the current state. For example, doing actions on a closed object. More...
 
class  obx::MaxDataSizeExceededException
 Thrown when a transaction is about to commit but it would exceed the user-defined data size limit. See obx_opt_max_data_size_in_kb() for details. More...
 
class  obx::ShuttingDownException
 The operation on a resource (typically a Store) failed because the resources is in process of being shut down or already has shutdown. For example, calling methods on the Store will throw this exception after Store::close(). More...
 
class  obx::DbException
 Database related exception, containing a error code to differentiate between various errors. Note: what() typically contains a specific text about the error condition (sometimes helpful to resolve the issue). More...
 
class  obx::BytesLazy
 Bytes, which must be resolved "lazily" via get() and released via this object (destructor). Unlike void* style bytes, this may represent allocated resources and/or bytes that are only produced on demand. More...
 
class  obx::Closable
 
class  obx::Options
 Options provide a way to configure Store when opening it. Options functions can be chained, e.g. options.directory("mypath/objectbox").maxDbSizeInKb(2048); Note: Options objects can be used only once to create a store as they are "consumed" during Store creation. Thus, you need to create a new Option object for each Store that is created. More...
 
class  obx::Store
 A ObjectBox store represents a database storing data in a given directory on a local file system. More...
 
class  obx::Transaction
 Provides RAII wrapper for an active database transaction on the current thread (do not use across threads). A Transaction object is considered a "top level transaction" if it is the first one on the call stack in the thread. If the thread already has an ongoing Transaction, additional Transaction instances are considered "inner transactions". More...
 
class  obx::PropertyTypeless
 Typeless property used as a base class for other types - sharing common conditions. More...
 
class  obx::Property< EntityT, ValueT >
 Carries property information when used in the entity-meta ("underscore") class. More...
 
class  obx::Property< EntityT, OBXPropertyType_String >
 Carries property information when used in the entity-meta ("underscore") class. More...
 
class  obx::Property< EntityT, OBXPropertyType_ByteVector >
 Carries property information when used in the entity-meta ("underscore") class. More...
 
class  obx::Property< EntityT, OBXPropertyType_StringVector >
 Carries property information when used in the entity-meta ("underscore") class. More...
 
class  obx::RelationProperty< SourceEntityT, TargetEntityT >
 Carries property-based to-one relation information when used in the entity-meta ("underscore") class. More...
 
class  obx::RelationStandalone< SourceEntityT, TargetEntityT >
 Carries to-many relation information when used in the entity-meta ("underscore") class. More...
 
class  obx::QueryBuilderBase
 A QueryBuilderBase is used to create database queries using an API (no string based query language). Building the queries involves calling functions to add conditions for the query. In the end a Query object is build, which then can be used to actually run the query (potentially multiple times). For generated code, you can also use the templated subclass QueryBuilder instead to have type safety at compile time. More...
 
class  obx::QueryBuilder< EntityT >
 See QueryBuilderBase for general information on query builders; this templated class allows to work with generated entity types conveniently. To specify actual conditions, use obx_qb_*() methods with queryBuilder.cPtr() as the first argument. More...
 
class  obx::QueryBase
 Query allows to find data matching user defined criteria for a entity type. Created by QueryBuilder and typically used with supplying a Cursor. More...
 
class  obx::Query< EntityT >
 Query allows to find data matching user defined criteria for a entity type. Created by QueryBuilder and typically used with supplying a Cursor. More...
 
class  obx::BoxTypeless
 Like Box, but without template type. Serves as the basis for Box, but can also be used as "lower-level" box with some restrictions on the functionality. More...
 
class  obx::Box< EntityT >
 A Box offers database operations for objects of a specific type. More...
 
class  obx::AsyncBox< EntityT >
 AsyncBox provides asynchronous ("happening on the background") database manipulation. More...
 
class  obx::ExpiredObjects
 Removal of expired objects; see OBXPropertyFlags_EXPIRATION_TIME. More...
 
class  obx::TreeOptions
 Structural/behavioral options for a tree passed during tree creation. More...
 
struct  obx::AsyncTreePutResult
 Parameter to AsyncTreePutCallback, which is passed to Tree::putAsync(). More...
 
class  obx::Tree
 Top level tree API representing a tree structure/schema associated with a store. More...
 
class  obx::LeavesInfo
 Information about a set of leaf nodes that is returned by TreeCursor::getLeavesInfo(). Contains meta data about (data) leaves: full path in the tree, ID, and property type. More...
 
class  obx::TreeCursor
 Primary tree interface against the database. Offers tree path based get/put functionality. Not-thread safe: use a TreeCursor instance from one thread only; i.e. the underlying transaction is bound to a thread. More...
 

Namespaces

 obx
 
 obx::internal
 

Macros

#define OBX_VERIFY_ARGUMENT(c)    ((c) ? (void) (0) : obx::internal::throwIllegalArgumentException("Argument validation failed: ", #c))
 
#define OBX_VERIFY_STATE(c)    ((c) ? (void) (0) : obx::internal::throwIllegalStateException("State condition failed: ", #c))
 

Typedefs

using obx::ObxLogCallback = std::function< void(OBXLogLevel logLevel, const char *text, size_t textSize)>
 
using obx::AsyncStatusCallback = std::function< void(obx_err err)>
 
using obx::AsyncTreePutCallback = std::function< void(const AsyncTreePutResult &result)>
 

Enumerations

enum class  obx::TxMode { obx::READ , obx::WRITE }
 Transactions can be started in read (only) or write mode. More...
 
enum class  obx::TreePutResult { obx::Undefined , obx::Success , obx::PathNotFound , obx::DidNotPut }
 Regular results in the sense of "not throwing an exception" for put operations via TreeCursor. More...
 

Functions

void obx::internal::throwIllegalArgumentException (const char *text1, const char *text2)
 
void obx::internal::throwIllegalStateException (const char *text1, const char *text2)
 
void obx::internal::throwLastError (obx_err err=obx_last_error_code(), const char *contextPrefix=nullptr)
 
void obx::internal::appendLastErrorText (obx_err err, std::string &outMessage)
 
void obx::internal::throwError (obx_err err, const std::string &message)
 
void obx::internal::checkErrOrThrow (obx_err err)
 
bool obx::internal::checkSuccessOrThrow (obx_err err)
 
void obx::internal::checkPtrOrThrow (const void *ptr, const char *contextPrefix=nullptr)
 
void obx::internal::checkIdOrThrow (uint64_t id, const char *contextPrefix=nullptr)
 
template<typename T >
T * obx::internal::checkedPtrOrThrow (T *ptr, const char *contextPrefix=nullptr)
 "Pass-through" variant of checkPtrOrThrow() - prefer the latter if this is not required (less templating). More...
 
template<typename EX = IllegalStateException, typename T >
T & obx::internal::toRef (T *ptr, const char *message="Can not dereference a null pointer")
 Dereferences the given pointer, which must be non-null. More...
 
const OBX_id_array obx::internal::cIdArrayRef (const std::vector< obx_id > &ids)
 Produces an OBX_id_array with internal data referencing the given ids vector. You must ensure the given vector outlives the returned OBX_id_array. Additionally, you must NOT call obx_id_array_free(), because the result is not allocated by C, thus it must not free it. More...
 
std::vector< obx_idobx::internal::idVectorOrThrow (OBX_id_array *cIds)
 Consumes an OBX_id_array, producing a vector of IDs and freeing the array afterwards. Must be called right after the C-API call producing cIds in order to check and throw on error correctly. Example: idVectorOrThrow(obx_query_find_ids(cQuery_, offset_, limit_)) Note: even if this function throws the given OBX_id_array is freed. More...
 
flatbuffers::FlatBufferBuilder & obx::internal::threadLocalFbbDirty ()
 Not cleared, thus potentially "dirty" fbb. More...
 
void obx::internal::threadLocalFbbDone ()
 
TreePutResult obx::internal::mapErrorToTreePutResult (obx_err err)
 

Variable Documentation

◆ items

std::vector<std::unique_ptr<EntityT> > items

◆ op_

QueryOp op_
protected

◆ propId_

obx_schema_id propId_
protected