Skip to content

Commit 6d4a2ef

Browse files
authored
Merge pull request #155 from couchbaselabs/CBL-7449-master
Update C TestServer to use 4.0.0 API
2 parents f09f849 + e1865a0 commit 6d4a2ef

File tree

8 files changed

+602
-532
lines changed

8 files changed

+602
-532
lines changed

CBLClient/Apps/CBLTestServer-C/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if(ANDROID)
5555
endif()
5656

5757
message(STATUS ${CMAKE_LIBRARY_ARCHITECTURE})
58-
find_package(CouchbaseLite 3.0.0 REQUIRED)
58+
find_package(CouchbaseLite 4.0.0 REQUIRED)
5959

6060
if(ANDROID)
6161
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
@@ -83,6 +83,7 @@ set(
8383
src/BlobMethods.cpp
8484
src/CollectionMethods.cpp
8585
src/ScopeMethods.cpp
86+
src/DatabaseHelpers.cpp
8687
src/DatabaseMethods.cpp
8788
src/DatabaseConfigurationMethods.cpp
8889
src/DataTypeMethods.cpp

CBLClient/Apps/CBLTestServer-C/ios/TestServer/TestServer.xcodeproj/project.pbxproj

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
40F448562E7BC0590068F13B /* DatabaseHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40F448552E7BC0590068F13B /* DatabaseHelpers.cpp */; };
1011
42827136268ECFD600E35F5B /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 42827135268ECFD600E35F5B /* certs */; };
1112
42827139268ECFF200E35F5B /* Databases in Resources */ = {isa = PBXBuildFile; fileRef = 42827137268ECFF200E35F5B /* Databases */; };
1213
4282713A268ECFF200E35F5B /* Files in Resources */ = {isa = PBXBuildFile; fileRef = 42827138268ECFF200E35F5B /* Files */; };
@@ -178,6 +179,8 @@
178179
/* End PBXCopyFilesBuildPhase section */
179180

180181
/* Begin PBXFileReference section */
182+
40F448542E7BC0590068F13B /* DatabaseHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DatabaseHelpers.h; sourceTree = "<group>"; };
183+
40F448552E7BC0590068F13B /* DatabaseHelpers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseHelpers.cpp; sourceTree = "<group>"; };
181184
42827135268ECFD600E35F5B /* certs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = certs; path = "../../../CBLTestServer-Dotnet/TestServer.NetCore/certs"; sourceTree = "<group>"; };
182185
42827137268ECFF200E35F5B /* Databases */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Databases; path = "../../../CBLTestServer-Dotnet/TestServer.NetCore/Databases"; sourceTree = "<group>"; };
183186
42827138268ECFF200E35F5B /* Files */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Files; path = "../../../CBLTestServer-Dotnet/TestServer.NetCore/Files"; sourceTree = "<group>"; };
@@ -440,60 +443,62 @@
440443
42F2DA47265351B8001C9EC3 /* src */ = {
441444
isa = PBXGroup;
442445
children = (
443-
42E1FA7A2728B04400054B57 /* cdecode.c */,
446+
42F2DA54265351B8001C9EC3 /* ArrayMethods.h */,
447+
42F2DA65265351B8001C9EC3 /* ArrayMethods.cpp */,
448+
42F2DA74265351B8001C9EC3 /* BasicAuthenticationMethods.h */,
449+
42F2DA81265351B8001C9EC3 /* BasicAuthenticationMethods.cpp */,
450+
42F2DA66265351B8001C9EC3 /* BlobMethods.h */,
451+
42F2DA7C265351B8001C9EC3 /* BlobMethods.cpp */,
444452
42E1FA792728B04400054B57 /* cdecode.h */,
445-
42B9FED926E04C510076EF3B /* EncryptableMethods.cpp */,
446-
42B9FEDA26E04C510076EF3B /* EncryptableMethods.h */,
447-
42ECEAE526C4B2920045D780 /* DataTypeMethods.cpp */,
448-
42ECEAE426C4B2920045D780 /* DataTypeMethods.h */,
449-
42B72B30269FDBAD00F0D94F /* QueryMethods.cpp */,
450-
42B72B2F269FDBAD00F0D94F /* QueryMethods.h */,
453+
42E1FA7A2728B04400054B57 /* cdecode.c */,
451454
42F2DBC82655F50C001C9EC3 /* civetweb */,
452-
42F2DABB2655F43E001C9EC3 /* libzip */,
453-
42F2DA65265351B8001C9EC3 /* ArrayMethods.cpp */,
454-
42F2DA48265351B8001C9EC3 /* ReplicatorMethods.h */,
455-
42F2DA49265351B8001C9EC3 /* FleeceHelpers.cpp */,
455+
A374B3D528B617CF00CFF87E /* CollectionMethods.hpp */,
456+
A374B3D428B617CF00CFF87E /* CollectionMethods.cpp */,
457+
42F2DA4D265351B8001C9EC3 /* DatabaseConfigurationMethods.h */,
458+
42F2DA7E265351B8001C9EC3 /* DatabaseConfigurationMethods.cpp */,
459+
40F448542E7BC0590068F13B /* DatabaseHelpers.h */,
460+
40F448552E7BC0590068F13B /* DatabaseHelpers.cpp */,
461+
42F2DA5E265351B8001C9EC3 /* DatabaseMethods.h */,
462+
42F2DA67265351B8001C9EC3 /* DatabaseMethods.cpp */,
463+
42ECEAE426C4B2920045D780 /* DataTypeMethods.h */,
464+
42ECEAE526C4B2920045D780 /* DataTypeMethods.cpp */,
465+
42F2DA5A265351B8001C9EC3 /* date.h */,
466+
42F2DA4C265351B8001C9EC3 /* Defer.hh */,
467+
42F2DA5F265351B8001C9EC3 /* Defines.h */,
468+
42F2DA7F265351B8001C9EC3 /* DictionaryMethods.h */,
456469
42F2DA4A265351B8001C9EC3 /* DictionaryMethods.cpp */,
457470
42F2DA4B265351B8001C9EC3 /* DocumentMethods.h */,
458-
42F2DA4C265351B8001C9EC3 /* Defer.hh */,
459-
42F2DA4D265351B8001C9EC3 /* DatabaseConfigurationMethods.h */,
460-
42F2DA4E265351B8001C9EC3 /* FleeceHelpers.h */,
461-
42F2DA4F265351B8001C9EC3 /* Response.h */,
462-
42F2DA50265351B8001C9EC3 /* ReplicatorConfigurationMethods.cpp */,
463-
42F2DA53265351B8001C9EC3 /* TestServer.h */,
464-
42F2DA54265351B8001C9EC3 /* ArrayMethods.h */,
465471
42F2DA55265351B8001C9EC3 /* DocumentMethods.cpp */,
466-
42F2DA56265351B8001C9EC3 /* ValueSerializer.cpp */,
467-
42F2DA57265351B8001C9EC3 /* ReplicatorMethods.cpp */,
472+
42B9FEDA26E04C510076EF3B /* EncryptableMethods.h */,
473+
42B9FED926E04C510076EF3B /* EncryptableMethods.cpp */,
474+
42F2DA73265351B8001C9EC3 /* FileLoggingMethods.h */,
475+
42F2DA75265351B8001C9EC3 /* FileLoggingMethods.cpp */,
476+
42B72B2B269D15F300F0D94F /* FileLoggingMethods+Apple.mm */,
468477
42F2DA58265351B8001C9EC3 /* FilePathResolver.h */,
469-
42F2DA59265351B8001C9EC3 /* SessionAuthenticationMethods.cpp */,
470-
42F2DA5A265351B8001C9EC3 /* date.h */,
471-
42F2DA5B265351B8001C9EC3 /* Router.cpp */,
472-
42F2DA5C265351B8001C9EC3 /* MemoryMap.cpp */,
473-
42F2DA5D265351B8001C9EC3 /* ValueSerializer.h */,
474-
42F2DA5E265351B8001C9EC3 /* DatabaseMethods.h */,
475-
42F2DA5F265351B8001C9EC3 /* Defines.h */,
476-
42F2DA61265351B8001C9EC3 /* TestServer.cpp */,
478+
4282713B268ED06800E35F5B /* FilePathResolver+Apple.mm */,
479+
42F2DA4E265351B8001C9EC3 /* FleeceHelpers.h */,
480+
42F2DA49265351B8001C9EC3 /* FleeceHelpers.cpp */,
481+
42F2DABB2655F43E001C9EC3 /* libzip */,
477482
42F2DA62265351B8001C9EC3 /* MemoryMap.h */,
478-
42F2DA63265351B8001C9EC3 /* SessionAuthenticationMethods.h */,
483+
42F2DA5C265351B8001C9EC3 /* MemoryMap.cpp */,
484+
42B72B2F269FDBAD00F0D94F /* QueryMethods.h */,
485+
42B72B30269FDBAD00F0D94F /* QueryMethods.cpp */,
486+
42F2DA80265351B8001C9EC3 /* ReplicatorConfigurationMethods.h */,
487+
42F2DA50265351B8001C9EC3 /* ReplicatorConfigurationMethods.cpp */,
488+
42F2DA48265351B8001C9EC3 /* ReplicatorMethods.h */,
489+
42F2DA57265351B8001C9EC3 /* ReplicatorMethods.cpp */,
490+
42F2DA4F265351B8001C9EC3 /* Response.h */,
479491
42F2DA64265351B8001C9EC3 /* Response.cpp */,
480-
42F2DA66265351B8001C9EC3 /* BlobMethods.h */,
481-
42F2DA67265351B8001C9EC3 /* DatabaseMethods.cpp */,
482-
42F2DA73265351B8001C9EC3 /* FileLoggingMethods.h */,
483-
42B72B2B269D15F300F0D94F /* FileLoggingMethods+Apple.mm */,
484-
42F2DA74265351B8001C9EC3 /* BasicAuthenticationMethods.h */,
485-
42F2DA75265351B8001C9EC3 /* FileLoggingMethods.cpp */,
486492
42F2DA76265351B8001C9EC3 /* Router.h */,
487-
42F2DA7C265351B8001C9EC3 /* BlobMethods.cpp */,
488-
42F2DA7E265351B8001C9EC3 /* DatabaseConfigurationMethods.cpp */,
489-
42F2DA7F265351B8001C9EC3 /* DictionaryMethods.h */,
490-
42F2DA80265351B8001C9EC3 /* ReplicatorConfigurationMethods.h */,
491-
42F2DA81265351B8001C9EC3 /* BasicAuthenticationMethods.cpp */,
492-
4282713B268ED06800E35F5B /* FilePathResolver+Apple.mm */,
493-
A374B3D428B617CF00CFF87E /* CollectionMethods.cpp */,
494-
A374B3D528B617CF00CFF87E /* CollectionMethods.hpp */,
495-
A374B3D728B6181800CFF87E /* ScopeMethods.cpp */,
493+
42F2DA5B265351B8001C9EC3 /* Router.cpp */,
496494
A374B3D828B6181800CFF87E /* ScopeMethods.hpp */,
495+
A374B3D728B6181800CFF87E /* ScopeMethods.cpp */,
496+
42F2DA63265351B8001C9EC3 /* SessionAuthenticationMethods.h */,
497+
42F2DA59265351B8001C9EC3 /* SessionAuthenticationMethods.cpp */,
498+
42F2DA53265351B8001C9EC3 /* TestServer.h */,
499+
42F2DA61265351B8001C9EC3 /* TestServer.cpp */,
500+
42F2DA5D265351B8001C9EC3 /* ValueSerializer.h */,
501+
42F2DA56265351B8001C9EC3 /* ValueSerializer.cpp */,
497502
);
498503
name = src;
499504
path = ../../src;
@@ -832,6 +837,7 @@
832837
42F2DBD12655FA3C001C9EC3 /* CBLTestServerBridge.mm in Sources */,
833838
42F2DBA02655F46C001C9EC3 /* zip_source_supports.c in Sources */,
834839
42F2DBB42655F46C001C9EC3 /* zip_set_file_comment.c in Sources */,
840+
40F448562E7BC0590068F13B /* DatabaseHelpers.cpp in Sources */,
835841
42F2DB642655F46C001C9EC3 /* zip_strerror.c in Sources */,
836842
42F2DB622655F46C001C9EC3 /* zip_source_is_deleted.c in Sources */,
837843
42F2DA8D265351B8001C9EC3 /* Response.cpp in Sources */,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "DatabaseHelpers.h"
2+
3+
#include "Defer.hh"
4+
#include "Defines.h"
5+
6+
#include INCLUDE_CBL(CouchbaseLite.h)
7+
8+
void withDefaultCollection(const CBLDatabase* db, const std::function<void(CBLCollection*)>& fn) {
9+
CBLError err {};
10+
CBLCollection* collection = CBLDatabase_DefaultCollection(db, &err);
11+
DEFER { CBLCollection_Release(collection); };
12+
TRY(collection, err)
13+
fn(collection);
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include <functional>
4+
5+
class CBLDatabase;
6+
class CBLCollection;
7+
8+
void withDefaultCollection(const CBLDatabase* db, const std::function<void(CBLCollection*)>& fn);

0 commit comments

Comments
 (0)