Skip to content

Commit 4d8db6c

Browse files
committed
0.14.0
1 parent 5ced603 commit 4d8db6c

File tree

11 files changed

+176
-56
lines changed

11 files changed

+176
-56
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
ObjectBox C and C++ API Changelog
22
=================================
33

4+
0.14.0 (2021-05-13)
5+
-------------------
6+
7+
* change `obx_query_prop_count()` to respect case-sensitivity setting when counting distinct strings
8+
* change `OBXSyncCredentialsType` values to start at 1
9+
* add `obx_query_find_first()` to get a first object matching the query
10+
* add `obx_query_find_unique()` to get the only object matching the query
11+
* add `obx_async_put_object4()` accepting a put_mode
12+
* updated ARMv7hf toolchain, now requires GLIBC v2.28 (e.g. Raspbian 10, Ubuntu 20.04)
13+
* semi-internal Dart APIs: add query streaming and finalizers
14+
415
0.13.0 (2021-03-16)
516
-------------------
17+
618
* add Sync binary library variants for all supported platforms
719
* add MacOS universal binary library, supporting Intel x64 and Apple Silicon arm64
8-
* split Sync symbols out of objectbox.h/pp into objectbox-sync.h/pp
9-
* add Sync server-time getter, listener and local-to-server diff info - to access server time info on clients
20+
* split Sync symbols out of objectbox.h/pp into objectbox-sync.h/pp
21+
* add Sync server-time getter, listener and local-to-server diff info - to access server time info on clients
1022
* add Sync heartbeat interval configuration and an option to send one immediately
1123
* semi-internal: update Dart/Flutter SDK to v2.0
1224

CMakeLists.txt

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@ if (${CMAKE_VERSION} VERSION_LESS "3.11.0")
99
endif ()
1010
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib")
1111
else ()
12-
project(objectbox-download)
12+
function(defineObjectBoxLibForURL VARIANT DL_URL)
13+
include(FetchContent)
14+
project(objectbox${VARIANT}-download)
15+
FetchContent_Declare(${PROJECT_NAME} URL ${DL_URL})
1316

14-
if (DEFINED ENV{OBJECTBOX_ARTIFACT_URL})
15-
set(DL_URL $ENV{OBJECTBOX_ARTIFACT_URL})
16-
message(STATUS "Using pre-compiled ObjectBox library from the OBJECTBOX_ARTIFACT_URL environment variable: ${DL_URL}")
17-
else ()
17+
FetchContent_Populate(${PROJECT_NAME})
18+
set(DL_DIR "${${PROJECT_NAME}_SOURCE_DIR}")
19+
message(STATUS "Pre-compiled ObjectBox library is saved in ${DL_DIR}")
20+
21+
project(objectbox${VARIANT})
22+
add_library(${PROJECT_NAME} SHARED IMPORTED GLOBAL)
23+
set(objectbox_include_dirs ${DL_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/external/)
24+
set_target_properties(
25+
${PROJECT_NAME} PROPERTIES
26+
IMPORTED_LOCATION ${DL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}
27+
IMPORTED_IMPLIB ${DL_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}objectbox${CMAKE_IMPORT_LIBRARY_SUFFIX}
28+
INTERFACE_INCLUDE_DIRECTORIES "${objectbox_include_dirs}"
29+
)
30+
endfunction()
31+
32+
function(defineObjectBoxLib VARIANT)
1833
# Configuration updated for each release
19-
set(DL_VERSION 0.13.0)
34+
set(DL_VERSION 0.14.0)
2035

2136
# Platform detection and other setup
2237
set(DL_URL https://github.com/objectbox/objectbox-c/releases/download)
@@ -45,25 +60,20 @@ else ()
4560
endif ()
4661

4762
string(TOLOWER ${DL_PLATFORM} DL_PLATFORM)
48-
set(DL_URL ${DL_URL}/v${DL_VERSION}/objectbox-${DL_PLATFORM}.${DL_EXTENSION})
49-
message(STATUS "Using pre-compiled ObjectBox library v${DL_VERSION} for ${DL_PLATFORM}: ${DL_URL}")
50-
endif ()
63+
set(DL_URL ${DL_URL}/v${DL_VERSION}/objectbox${VARIANT}-${DL_PLATFORM}.${DL_EXTENSION})
64+
message(STATUS "Using pre-compiled ObjectBox${VARIANT} library v${DL_VERSION} for ${DL_PLATFORM}: ${DL_URL}")
5165

52-
include(FetchContent)
53-
FetchContent_Declare(${PROJECT_NAME} URL ${DL_URL})
66+
defineObjectBoxLibForURL("${VARIANT}" "${DL_URL}")
67+
endfunction()
5468

55-
FetchContent_Populate(${PROJECT_NAME})
56-
message(STATUS "Pre-compiled ObjectBox library is saved in ${objectbox-download_SOURCE_DIR}")
57-
58-
project(objectbox)
59-
add_library(${PROJECT_NAME} SHARED IMPORTED GLOBAL)
60-
set(objectbox_include_dirs ${objectbox-download_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/external/)
61-
set_target_properties(
62-
${PROJECT_NAME} PROPERTIES
63-
IMPORTED_LOCATION ${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}
64-
IMPORTED_IMPLIB ${objectbox-download_SOURCE_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}objectbox${CMAKE_IMPORT_LIBRARY_SUFFIX}
65-
INTERFACE_INCLUDE_DIRECTORIES "${objectbox_include_dirs}"
66-
)
69+
if (DEFINED ENV{OBJECTBOX_ARTIFACT_URL})
70+
set(DL_URL $ENV{OBJECTBOX_ARTIFACT_URL})
71+
message(STATUS "Using pre-compiled ObjectBox library from the OBJECTBOX_ARTIFACT_URL environment variable: ${DL_URL}")
72+
defineObjectBoxLibForURL("" "${DL_URL}")
73+
else ()
74+
defineObjectBoxLib("")
75+
defineObjectBoxLib("-sync")
76+
endif ()
6777
endif ()
6878

6979
add_subdirectory(src-test)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ box.put({.text = "Buy milk"});
1111
1212
See [ObjectBox C and C++ docs](https://cpp.objectbox.io/) for API details.
1313
14-
**Latest version: 0.13.0** (2021-03-16).
14+
**Latest version: 0.14.0** (2021-05-13).
1515
See [changelog](CHANGELOG.md) for more details.
1616
1717
Feature Highlights

download.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tty -s || quiet=true
4444

4545
# Note: optional arguments like "--quiet" shifts argument positions in the case block above
4646

47-
version=${1:-0.13.0}
47+
version=${1:-0.14.0}
4848
os=${2:-$(uname)}
4949
arch=${3:-$(uname -m)}
5050
echo "Base config: OS ${os} and architecture ${arch}"

doxygen/Changelog.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@
33
ObjectBox C and C++ API Changelog
44
=================================
55

6+
0.14.0 (2021-05-13)
7+
-------------------
8+
9+
* change `obx_query_prop_count()` to respect case-sensitivity setting when counting distinct strings
10+
* change `OBXSyncCredentialsType` values to start at 1
11+
* add `obx_query_find_first()` to get a first object matching the query
12+
* add `obx_query_find_unique()` to get the only object matching the query
13+
* add `obx_async_put_object4()` accepting a put_mode
14+
* updated ARMv7hf toolchain, now requires GLIBC v2.28 (e.g. Raspbian 10, Ubuntu 20.04)
15+
* semi-internal Dart APIs: add query streaming and finalizers
16+
617
0.13.0 (2021-03-16)
718
-------------------
8-
* split Sync symbols out of objectbox.h/pp into objectbox-sync.h/pp
9-
* add Sync server-time getter, listener and local-to-server diff info - to access server time info on clients
19+
20+
* add Sync binary library variants for all supported platforms
21+
* add MacOS universal binary library, supporting Intel x64 and Apple Silicon arm64
22+
* split Sync symbols out of objectbox.h/pp into objectbox-sync.h/pp
23+
* add Sync server-time getter, listener and local-to-server diff info - to access server time info on clients
1024
* add Sync heartbeat interval configuration and an option to send one immediately
1125
* semi-internal: update Dart/Flutter SDK to v2.0
1226

doxygen/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "ObjectBox C and C++ API"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = "0.13.0"
41+
PROJECT_NUMBER = "0.14.0"
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

include/objectbox-dart.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <stdint.h>
2121

22+
#include "dart_api.h"
2223
#include "objectbox-sync.h"
2324

2425
#ifdef __cplusplus
@@ -71,6 +72,39 @@ OBX_dart_sync_listener* obx_dart_sync_listener_change(OBX_sync* sync, int64_t na
7172
/// @see obx_sync_listener_server_time()
7273
OBX_dart_sync_listener* obx_dart_sync_listener_server_time(OBX_sync* sync, int64_t native_port);
7374

75+
/// @see obx_async_put_object()
76+
obx_id obx_dart_async_put_object(OBX_async* async, int64_t native_port, void* data, size_t size, OBXPutMode mode);
77+
78+
struct OBX_dart_stream;
79+
typedef struct OBX_dart_stream OBX_dart_stream;
80+
81+
obx_err obx_dart_stream_close(OBX_dart_stream* stream);
82+
83+
/// @see obx_dart_stream_query_find
84+
OBX_dart_stream* obx_dart_query_find(OBX_query* query, int64_t native_port);
85+
86+
OBX_dart_stream* obx_dart_query_find_ptr(OBX_query* query, int64_t native_port);
87+
88+
struct OBX_dart_finalizer;
89+
typedef struct OBX_dart_finalizer OBX_dart_finalizer;
90+
91+
/// A function to clean up native resources. Must be a c-function (non-throwing). The returned error is ignored.
92+
/// e.g. obx_query_close(), obx_store_close(), ...
93+
typedef obx_err obx_dart_closer(void* native_object);
94+
95+
/// Attaches a finalizer (destructor) to be called when the given object is garbage-collected.
96+
/// @param dart_object marks the object owning the native pointer
97+
/// @param native_object is the native pointer to be freed
98+
/// @param closer is the function that frees native_object
99+
/// @param native_object_size is an allocated size estimate - can be used by a the Dart garbage collector to prioritize
100+
/// @return a finalizer freed automatically when the GC finalizer runs (or manually by obx_dart_detach_finalizer())
101+
/// @return NULL if the finalizer couldn't be attached, in which case the caller is responsible for running the closer
102+
OBX_dart_finalizer* obx_dart_attach_finalizer(Dart_Handle dart_object, obx_dart_closer* closer, void* native_object,
103+
size_t native_object_size);
104+
105+
/// Detach the finalizer preliminarily, without executing its "closer"
106+
obx_err obx_dart_detach_finalizer(OBX_dart_finalizer* finalizer, Dart_Handle dart_object);
107+
74108
#ifdef __cplusplus
75109
}
76110
#endif

include/objectbox-sync.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
#include "objectbox.h"
3535

36+
#if defined(static_assert) || defined(__cplusplus)
37+
static_assert(OBX_VERSION_MAJOR == 0 && OBX_VERSION_MINOR == 14 && OBX_VERSION_PATCH == 0,
38+
"Versions of objectbox.h and objectbox-sync.h files do not match, please update");
39+
#endif
40+
3641
#ifdef __cplusplus
3742
extern "C" {
3843
#endif
@@ -51,9 +56,9 @@ struct OBX_sync;
5156
typedef struct OBX_sync OBX_sync;
5257

5358
typedef enum {
54-
OBXSyncCredentialsType_NONE = 0,
55-
OBXSyncCredentialsType_SHARED_SECRET = 1,
56-
OBXSyncCredentialsType_GOOGLE_AUTH = 2,
59+
OBXSyncCredentialsType_NONE = 1,
60+
OBXSyncCredentialsType_SHARED_SECRET = 2,
61+
OBXSyncCredentialsType_GOOGLE_AUTH = 3,
5762
} OBXSyncCredentialsType;
5863

5964
// TODO sync prefix

include/objectbox-sync.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "objectbox-sync.h"
2020
#include "objectbox.hpp"
2121

22-
static_assert(OBX_VERSION_MAJOR == 0 && OBX_VERSION_MINOR == 13 && OBX_VERSION_PATCH == 0,
23-
"Versions of objectbox.h and objectbox-sync.hpp files must be exactly the same");
22+
static_assert(OBX_VERSION_MAJOR == 0 && OBX_VERSION_MINOR == 14 && OBX_VERSION_PATCH == 0,
23+
"Versions of objectbox.h and objectbox-sync.hpp files do not match, please update");
2424

2525
static_assert(sizeof(obx_id) == sizeof(OBX_id_array::ids[0]),
2626
"Can't directly link OBX_id_array.ids to std::vector<obx_id>::data()");

include/objectbox.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extern "C" {
4646
/// When using ObjectBox as a dynamic library, you should verify that a compatible version was linked using
4747
/// obx_version() or obx_version_is_at_least().
4848
#define OBX_VERSION_MAJOR 0
49-
#define OBX_VERSION_MINOR 13
49+
#define OBX_VERSION_MINOR 14
5050
#define OBX_VERSION_PATCH 0 // values >= 100 are reserved for dev releases leading to the next minor/major increase
5151

5252
//----------------------------------------------
@@ -996,12 +996,12 @@ obx_err obx_box_put5(OBX_box* box, obx_id id, const void* data, size_t size, OBX
996996

997997
/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW.
998998
/// @param data writable data buffer, which may be updated for the ID
999-
/// @returns 0 on error
999+
/// @returns id if the object could be put, or 0 in case of an error
10001000
obx_id obx_box_put_object(OBX_box* box, void* data, size_t size);
10011001

10021002
/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW
10031003
/// @param data writable data buffer, which may be updated for the ID
1004-
/// @returns 0 on error, e.g. the entity was not put according to OBXPutMode
1004+
/// @returns id if the object, or 0 in case of an error, e.g. the entity was not put according to OBXPutMode
10051005
obx_id obx_box_put_object4(OBX_box* box, void* data, size_t size, OBXPutMode mode);
10061006

10071007
/// Put all given objects in the database in a single transaction. If any of the individual objects failed to put,
@@ -1124,11 +1124,18 @@ obx_err obx_async_update(OBX_async* async, obx_id id, const void* data, size_t s
11241124
/// Reserve an ID, which is returned immediately for future reference, and put asynchronously.
11251125
/// Note: of course, it can NOT be guaranteed that the entity will actually be put successfully in the DB.
11261126
/// @param data the given bytes are mutated to update the contained ID data.
1127+
/// @returns id of the new object, 0 on error
11271128
obx_id obx_async_put_object(OBX_async* async, void* data, size_t size);
11281129

1130+
/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW
1131+
/// @param data writable data buffer, which may be updated for the ID
1132+
/// @returns id of the new object, 0 on error, e.g. the entity can't be put according to OBXPutMode
1133+
obx_id obx_async_put_object4(OBX_async* async, void* data, size_t size, OBXPutMode mode);
1134+
11291135
/// Reserve an ID, which is returned immediately for future reference, and insert asynchronously.
11301136
/// Note: of course, it can NOT be guaranteed that the entity will actually be inserted successfully in the DB.
11311137
/// @param data the given bytes are mutated to update the contained ID data.
1138+
/// @returns id of the new object, 0 on error
11321139
obx_id obx_async_insert_object(OBX_async* async, void* data, size_t size);
11331140

11341141
/// Remove asynchronously.
@@ -1384,6 +1391,22 @@ obx_err obx_query_limit(OBX_query* query, uint64_t limit);
13841391
/// Find entities matching the query. NOTE: the returned data is only valid as long the transaction is active!
13851392
OBX_bytes_array* obx_query_find(OBX_query* query);
13861393

1394+
/// Find the first object matching the query.
1395+
/// @returns OBX_NOT_FOUND if no object matches.
1396+
/// The exposed data comes directly from the OS to allow zero-copy access, which limits the data lifetime:
1397+
/// @warning Currently ignores offset, taking the the first matching element.
1398+
/// @attention The exposed data is only valid as long as the (top) transaction is still active and no write
1399+
/// operation (e.g. put/remove) was executed. Accessing data after this is undefined behavior.
1400+
obx_err obx_query_find_first(OBX_query* query, const void** data, size_t* size);
1401+
1402+
/// Find the only object matching the query.
1403+
/// @returns OBX_NOT_FOUND if no object matches, an error if there are multiple objects matching the query.
1404+
/// The exposed data comes directly from the OS to allow zero-copy access, which limits the data lifetime:
1405+
/// @warning Currently ignores offset and limit, considering all matching elements.
1406+
/// @attention The exposed data is only valid as long as the (top) transaction is still active and no write
1407+
/// operation (e.g. put/remove) was executed. Accessing data after this is undefined behavior.
1408+
obx_err obx_query_find_unique(OBX_query* query, const void** data, size_t* size);
1409+
13871410
/// Walk over matching objects using the given data visitor
13881411
obx_err obx_query_visit(OBX_query* query, obx_data_visitor* visitor, void* user_data);
13891412

0 commit comments

Comments
 (0)