ObjectBox C and C++ API  0.12.0
obx::QueryBuilder< EntityT > Class Template Reference

Provides a simple wrapper for OBX_query_builder to simplify memory management - calls obx_qb_close() on destruction. To specify actual conditions, use obx_qb_*() methods with queryBuilder.cPtr() as the first argument. More...

#include <objectbox.hpp>

Public Member Functions

 QueryBuilder (Store &store)
 
 QueryBuilder (Store &store, OBX_query_builder *ptr, bool isRoot)
 
 QueryBuilder (const QueryBuilder &)=delete
 Can't be copied, single owner of C resources is required (to avoid double-free during destruction) More...
 
 QueryBuilder (QueryBuilder &&source) noexcept
 
virtual ~QueryBuilder ()
 
OBX_query_buildercPtr () const
 
template<OBXPropertyType PropType>
QueryBuilderorder (Property< EntityT, PropType > property, int flags=0)
 Adds an order based on a given property. More...
 
QueryBuilderwith (const QueryCondition &condition)
 Appends given condition/combination of conditions. More...
 
template<typename RangePropertyEntityT , OBXPropertyType RangePropertyType, typename = EnableIfDate<RangePropertyType>>
QueryBuilder< RangePropertyEntityT > linkTime (Property< RangePropertyEntityT, RangePropertyType > property)
 Links the (time series) entity type to another entity space using a time point in a linked entity. More...
 
template<typename RangePropertyEntityT , OBXPropertyType RangePropertyType, typename = EnableIfDate<RangePropertyType>>
QueryBuilder< RangePropertyEntityT > linkTime (Property< RangePropertyEntityT, RangePropertyType > beginProperty, Property< RangePropertyEntityT, RangePropertyType > endProperty)
 Links the (time series) entity type to another entity space using a range defined in a given linked entity. More...
 
template<typename RelTargetEntityT >
QueryBuilder< RelTargetEntityT > link (RelationProperty< EntityT, RelTargetEntityT > rel)
 Create a link based on a property-relation (to-one). More...
 
template<typename RelSourceEntityT >
QueryBuilder< RelSourceEntityT > backlink (RelationProperty< RelSourceEntityT, EntityT > rel)
 Create a backlink based on a property-relation used in reverse (to-many). More...
 
template<typename RelTargetEntityT >
QueryBuilder< RelTargetEntityT > link (RelationStandalone< EntityT, RelTargetEntityT > rel)
 Create a link based on a standalone relation (many-to-many) More...
 
template<typename RelSourceEntityT >
QueryBuilder< RelSourceEntityT > backlink (RelationStandalone< RelSourceEntityT, EntityT > rel)
 Create a backlink based on a standalone relation (many-to-many, reverse direction) More...
 
Query< EntityT > build ()
 

Protected Member Functions

template<typename LinkedEntityT >
QueryBuilder< LinkedEntityT > linkedQB (OBX_query_builder *linkedQB)
 

Detailed Description

template<typename EntityT>
class obx::QueryBuilder< EntityT >

Provides a simple wrapper for OBX_query_builder to simplify memory management - calls obx_qb_close() on destruction. To specify actual conditions, use obx_qb_*() methods with queryBuilder.cPtr() as the first argument.

Constructor & Destructor Documentation

◆ QueryBuilder() [1/4]

template<typename EntityT >
obx::QueryBuilder< EntityT >::QueryBuilder ( Store store)
inlineexplicit

◆ QueryBuilder() [2/4]

template<typename EntityT >
obx::QueryBuilder< EntityT >::QueryBuilder ( Store store,
OBX_query_builder ptr,
bool  isRoot 
)
inlineexplicit

◆ QueryBuilder() [3/4]

template<typename EntityT >
obx::QueryBuilder< EntityT >::QueryBuilder ( const QueryBuilder< EntityT > &  )
delete

Can't be copied, single owner of C resources is required (to avoid double-free during destruction)

◆ QueryBuilder() [4/4]

template<typename EntityT >
obx::QueryBuilder< EntityT >::QueryBuilder ( QueryBuilder< EntityT > &&  source)
inlinenoexcept

◆ ~QueryBuilder()

template<typename EntityT >
virtual obx::QueryBuilder< EntityT >::~QueryBuilder ( )
inlinevirtual

Member Function Documentation

◆ backlink() [1/2]

template<typename EntityT >
template<typename RelSourceEntityT >
QueryBuilder<RelSourceEntityT> obx::QueryBuilder< EntityT >::backlink ( RelationProperty< RelSourceEntityT, EntityT >  rel)
inline

Create a backlink based on a property-relation used in reverse (to-many).

Note
Returned QueryBuilder switches context, make sure to call build() on the root QueryBuilder.
Parameters
relthe relation property, with target EntityT represented by this QueryBuilder.
Returns
the linked QueryBuilder; "switches context" to the linked entity.
Examples
/home/markus/dev/objectbox/objectbox-c/include/objectbox.hpp.

◆ backlink() [2/2]

template<typename EntityT >
template<typename RelSourceEntityT >
QueryBuilder<RelSourceEntityT> obx::QueryBuilder< EntityT >::backlink ( RelationStandalone< RelSourceEntityT, EntityT >  rel)
inline

Create a backlink based on a standalone relation (many-to-many, reverse direction)

Note
Returned QueryBuilder switches context, make sure to call build() on the root QueryBuilder.
Returns
the linked QueryBuilder; "switches context" to the linked entity.

◆ cPtr()

template<typename EntityT >
OBX_query_builder* obx::QueryBuilder< EntityT >::cPtr ( ) const
inline

◆ link() [1/2]

template<typename EntityT >
template<typename RelTargetEntityT >
QueryBuilder<RelTargetEntityT> obx::QueryBuilder< EntityT >::link ( RelationProperty< EntityT, RelTargetEntityT >  rel)
inline

Create a link based on a property-relation (to-one).

Note
Returned QueryBuilder switches context, make sure to call build() on the root QueryBuilder.
Parameters
relthe relation property, with source EntityT represented by this QueryBuilder.
conditiona condition or a group of conditions to apply on the linked entity
Returns
the linked QueryBuilder; "switches context" to the linked entity.
Examples
/home/markus/dev/objectbox/objectbox-c/include/objectbox.hpp.

◆ link() [2/2]

template<typename EntityT >
template<typename RelTargetEntityT >
QueryBuilder<RelTargetEntityT> obx::QueryBuilder< EntityT >::link ( RelationStandalone< EntityT, RelTargetEntityT >  rel)
inline

Create a link based on a standalone relation (many-to-many)

Note
Returned QueryBuilder switches context, make sure to call build() on the root QueryBuilder.
Returns
the linked QueryBuilder; "switches context" to the linked entity.

◆ linkedQB()

template<typename EntityT >
template<typename LinkedEntityT >
QueryBuilder<LinkedEntityT> obx::QueryBuilder< EntityT >::linkedQB ( OBX_query_builder linkedQB)
inlineprotected

◆ linkTime() [1/2]

template<typename EntityT >
template<typename RangePropertyEntityT , OBXPropertyType RangePropertyType, typename = EnableIfDate<RangePropertyType>>
QueryBuilder<RangePropertyEntityT> obx::QueryBuilder< EntityT >::linkTime ( Property< RangePropertyEntityT, RangePropertyType >  beginProperty,
Property< RangePropertyEntityT, RangePropertyType >  endProperty 
)
inline

Links the (time series) entity type to another entity space using a range defined in a given linked entity.

Note
1) Time series functionality (ObjectBox TS) must be available to use this.
2) Returned QueryBuilder switches context, make sure to call build() on the root QueryBuilder.
Parameters
beginPropertyProperty of the linked entity defining the beginning of a time range. Must be a date type (e.g. PropertyType_Date or PropertyType_DateNano).
endPropertyProperty of the linked entity defining the end of a time range. Must be a date type (e.g. PropertyType_Date or PropertyType_DateNano).
Returns
the linked QueryBuilder; "switches context" to the linked entity.

◆ linkTime() [2/2]

template<typename EntityT >
template<typename RangePropertyEntityT , OBXPropertyType RangePropertyType, typename = EnableIfDate<RangePropertyType>>
QueryBuilder<RangePropertyEntityT> obx::QueryBuilder< EntityT >::linkTime ( Property< RangePropertyEntityT, RangePropertyType >  property)
inline

Links the (time series) entity type to another entity space using a time point in a linked entity.

Note
1) Time series functionality (ObjectBox TS) must be available to use this.
2) Returned QueryBuilder switches context, make sure to call build() on the root QueryBuilder.
Parameters
propertyProperty of the linked entity defining a time point or the begin of a time range. Must be a date type (e.g. PropertyType_Date or PropertyType_DateNano).
Returns
the linked QueryBuilder; "switches context" to the linked entity.
Examples
/home/markus/dev/objectbox/objectbox-c/include/objectbox.hpp.

◆ order()

template<typename EntityT >
template<OBXPropertyType PropType>
QueryBuilder& obx::QueryBuilder< EntityT >::order ( Property< EntityT, PropType >  property,
int  flags = 0 
)
inline

Adds an order based on a given property.

Parameters
propertythe property used for the order
flagscombination of OBXOrderFlags
Returns
the reference to the same QueryBuilder for fluent interface.
Examples
/home/markus/dev/objectbox/objectbox-c/include/objectbox.hpp.

◆ with()

template<typename EntityT >
QueryBuilder& obx::QueryBuilder< EntityT >::with ( const QueryCondition &  condition)
inline

Appends given condition/combination of conditions.

Returns
the reference to the same QueryBuilder for fluent interface.
Examples
/home/markus/dev/objectbox/objectbox-c/include/objectbox.hpp.