├── .appveyor └── test.ps1 ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .gitmodules ├── CONTRIBUTING.md ├── Jenkinsfile ├── LICENSE ├── Notes ├── CIAndVersions.md └── StyleGuidelines.md ├── README.md ├── Tools └── Touch.Server │ ├── Main.cs │ └── Options.cs ├── appveyor.yml ├── core_version.ini ├── jim_borden.gpg ├── packaging └── nuget │ ├── LICENSE.txt │ ├── README.md │ ├── do_clean.ps1 │ ├── do_package.ps1 │ └── logo.png └── src ├── AssemblyInfo.props ├── Couchbase.Lite.Shared ├── API │ ├── Conflict │ │ ├── Conflict.cs │ │ ├── ConflictResolver.cs │ │ ├── DefaultConflictResolver.cs │ │ └── IConflictResolver.cs │ ├── DI │ │ ├── CouchbaseDependencyAttribute.cs │ │ ├── IDefaultDirectoryResolver.cs │ │ ├── IMainThreadTaskScheduler.cs │ │ ├── IProxy.cs │ │ ├── IReachability.cs │ │ ├── IRuntimePlatform.cs │ │ └── Service.cs │ ├── Database │ │ ├── Collection.cs │ │ ├── CollectionChangedEventArgs.cs │ │ ├── Database.cs │ │ ├── DatabaseChangedEventArgs.cs │ │ ├── DatabaseConfiguration.cs │ │ ├── DocumentChangedEventArgs.cs │ │ ├── Interfaces │ │ │ └── IChangeObservable.cs │ │ ├── ListenerToken.cs │ │ └── Scope.cs │ ├── Document │ │ ├── ArrayObject.cs │ │ ├── Blob.cs │ │ ├── DictionaryObject.cs │ │ ├── Document+private.cs │ │ ├── Document.cs │ │ ├── DocumentFragment.cs │ │ ├── IArray.cs │ │ ├── IDictionaryObject.cs │ │ ├── IFragment.cs │ │ ├── IJSON.cs │ │ ├── IMutableArray.cs │ │ ├── IMutableDictionary.cs │ │ ├── IMutableFragment.cs │ │ ├── MutableArrayObject.cs │ │ ├── MutableDictionaryObject.cs │ │ └── MutableDocument.cs │ ├── Info │ │ ├── CouchbaseLiteErrorMessage.cs │ │ ├── CouchbaseLiteErrorMessageNetOnly.cs │ │ ├── Defaults.cs │ │ └── Defaults_Deprecated.cs │ ├── Log │ │ ├── ConsoleLogger.cs │ │ ├── FileLogger.cs │ │ ├── ILogger.cs │ │ └── Log.cs │ ├── Query │ │ ├── ArrayExpression.cs │ │ ├── ArrayFunction.cs │ │ ├── ArrayIndexConfiguration.cs │ │ ├── Collation.cs │ │ ├── DataSource.cs │ │ ├── Expression.cs │ │ ├── FullTextExpression.cs │ │ ├── FullTextFunction.cs │ │ ├── FullTextIndexConfiguration.cs │ │ ├── Function.cs │ │ ├── IArrayExpression.cs │ │ ├── ICollation.cs │ │ ├── IDataSource.cs │ │ ├── IExpression.cs │ │ ├── IFrom.cs │ │ ├── IFromRouter.cs │ │ ├── IFullTextExpression.cs │ │ ├── IFullTextIndexExpression.cs │ │ ├── IGroupBy.cs │ │ ├── IGroupByRouter.cs │ │ ├── IHaving.cs │ │ ├── IHavingRouter.cs │ │ ├── IIndex.cs │ │ ├── IIndexExpression.cs │ │ ├── IIndexItem.cs │ │ ├── IIndexable.cs │ │ ├── IJoin.cs │ │ ├── IJoinRouter.cs │ │ ├── ILimit.cs │ │ ├── ILimitRouter.cs │ │ ├── IMetaExpression.cs │ │ ├── IOrderBy.cs │ │ ├── IOrderByRouter.cs │ │ ├── IPropertyExpression.cs │ │ ├── IQuery.cs │ │ ├── IQueryFactory.cs │ │ ├── IQueryIndex.cs │ │ ├── IResultSet.cs │ │ ├── ISelect.cs │ │ ├── ISelectResult.cs │ │ ├── IVariableExpression.cs │ │ ├── IWhere.cs │ │ ├── IWhereRouter.cs │ │ ├── IndexBuilder.cs │ │ ├── IndexItem.cs │ │ ├── Joins.cs │ │ ├── Meta.cs │ │ ├── Ordering.cs │ │ ├── Parameters.cs │ │ ├── QueryBuilder.cs │ │ ├── Result.cs │ │ ├── SelectResult.cs │ │ └── ValueIndexConfiguration.cs │ ├── RuntimeException.cs │ └── Sync │ │ ├── Authenticator.cs │ │ ├── BackgroundMonitor.cs │ │ ├── BasicAuthenticator.cs │ │ ├── CollectionConfiguration.cs │ │ ├── IEndpoint.cs │ │ ├── ProxyAuthenticator.cs │ │ ├── ReplicationActivityLevel.cs │ │ ├── Replicator+Backgrounding.cs │ │ ├── Replicator.cs │ │ ├── ReplicatorConfiguration.cs │ │ ├── ReplicatorProgress.cs │ │ ├── ReplicatorStatus.cs │ │ ├── ReplicatorStatusChangedEventArgs.cs │ │ ├── SessionAuthenticator.cs │ │ └── URLEndpoint.cs ├── Couchbase.Lite.Shared.projitems ├── Couchbase.Lite.Shared.shproj ├── Document │ ├── BlobReadStream.cs │ ├── BlobWriteStream.cs │ ├── DataOps.cs │ ├── DocContext.cs │ ├── Fragment.cs │ ├── InMemoryDictionary.cs │ └── MRoot.cs ├── Linq │ ├── IDocumentModel.cs │ ├── ISelectResultContainer.cs │ ├── LinqExtensionMethods.cs │ ├── LiteCoreExpressionVisitor.cs │ ├── LiteCoreOrderingExpressionVisitor.cs │ ├── LiteCoreQueryExecutor.cs │ ├── LiteCoreQueryModelVisitor.cs │ ├── LiteCoreSelectExpressionVisitor.cs │ ├── LiteCoreWhereExpressionVisitor.cs │ └── NotSupportedExpressionVisitor.cs ├── Log │ ├── Log.cs │ ├── LogDomains.cs │ ├── LogJsonString.cs │ ├── LogTo.cs │ └── SecureLogString.cs ├── Query │ ├── DataSource.cs │ ├── DatabaseQueryable.cs │ ├── DatabaseSource.cs │ ├── From.cs │ ├── Having.cs │ ├── IndexConfiguration.cs │ ├── Join.cs │ ├── LimitedQuery.cs │ ├── LiveQuerier.cs │ ├── NQuery.cs │ ├── NullResultSet.cs │ ├── QueryBase.cs │ ├── QueryBinaryExpression.cs │ ├── QueryCollation.cs │ ├── QueryCompoundExpression.cs │ ├── QueryConstantExpression.cs │ ├── QueryExpression.cs │ ├── QueryGroupBy.cs │ ├── QueryIndex.cs │ ├── QueryIndexItem.cs │ ├── QueryOrdering.cs │ ├── QueryResultContext.cs │ ├── QueryResultSet.cs │ ├── QuerySelectResult.cs │ ├── QueryTernaryExpression.cs │ ├── QueryTypeExpression.cs │ ├── QueryUnaryExpression.cs │ ├── Select.cs │ ├── Where.cs │ └── XQuery.cs ├── Serialization │ ├── FLValueConverter.cs │ ├── FleeceMutableArray.cs │ ├── JsonFLValueReader.cs │ ├── JsonFLValueWriter.cs │ ├── MCollection.cs │ ├── MContext.cs │ ├── MDict.cs │ └── MValue.cs ├── Support │ ├── Android │ │ ├── AndroidConsoleLogger.cs │ │ ├── AndroidRuntimePlatform.cs │ │ ├── DefaultDirectoryResolver.cs │ │ ├── DotnetAndroidProxy.cs │ │ └── MainThreadTaskScheduler.cs │ ├── Freezer.cs │ ├── IStoppable.cs │ ├── IThreadSafety.cs │ ├── SerialQueue.cs │ ├── Status.cs │ ├── ThreadSafety.cs │ ├── WinUI │ │ ├── DefaultDirectoryResolver.cs │ │ ├── Reachability.cs │ │ ├── WinUIConsoleLogger.cs │ │ ├── WinUIProxy.cs │ │ └── WinUIRuntimePlatform.cs │ ├── iOS │ │ ├── DefaultDirectoryResolver.cs │ │ ├── IOSProxy.cs │ │ ├── MainThreadTaskScheduler.cs │ │ ├── iOSConsoleLogger.cs │ │ ├── iOSReachability.cs │ │ └── iOSRuntimePlatform.cs │ └── netdesktop │ │ ├── DefaultDirectoryResolver.cs │ │ ├── DesktopConsoleLogger.cs │ │ ├── LinuxProxy.cs │ │ ├── MacProxy.cs │ │ └── WindowsProxy.cs ├── Sync │ ├── AuthOptionsDictionary.cs │ ├── HTTPLogic.cs │ ├── HttpMessageParser.cs │ ├── Reachability.cs │ ├── ReplicatorOptionsDictionary.cs │ ├── WebSocketTransport.cs │ └── WebSocketWrapper.cs └── Util │ ├── AtomicBool.cs │ ├── CBDebug.cs │ ├── DisposalWatchdog.cs │ ├── Extensions.cs │ ├── FilteredEvent.cs │ ├── Misc.cs │ ├── NonNullDictionary.cs │ ├── OptionsDictionary.cs │ └── RunOnce.cs ├── Couchbase.Lite.Support.Android ├── Activate.cs ├── Couchbase.Lite.Support.Android.csproj └── Properties │ └── AssemblyInfo.cs ├── Couchbase.Lite.Support.Apple ├── Activate.cs └── iOS │ └── Couchbase.Lite.Support.iOS.csproj ├── Couchbase.Lite.Support.NetDesktop ├── Activate.cs ├── Couchbase.Lite.Support.NetDesktop.csproj └── desktop.props ├── Couchbase.Lite.Support.WinUI ├── Activate.cs └── Couchbase.Lite.Support.WinUI.csproj ├── Couchbase.Lite.Tests.NetCore ├── C │ └── tests │ │ └── data │ │ └── names_100.json ├── Couchbase.Lite.Tests.NetCore.csproj ├── Couchbase.Lite.Tests.NetCore.sln ├── coverage.xml ├── modify_packages.ps1 ├── modify_packages.sh └── replacedb │ ├── android140-sqlite-noattachment.cblite2.zip │ ├── android140-sqlite.cblite2.zip │ └── android200-sqlite.cblite2.zip ├── Couchbase.Lite.Tests.Shared ├── ArrayIndexTest.cs ├── ArrayTest.cs ├── BlobTest.cs ├── C │ └── tests │ │ └── data │ │ ├── SelfSigned.cer │ │ ├── attachment.png │ │ ├── certs.p12 │ │ ├── certs.pfx │ │ ├── client-ca.der │ │ ├── client.p12 │ │ ├── client.pfx │ │ ├── create_new_chain.sh │ │ ├── iTunesMusicLibrary.json │ │ ├── names_100.json │ │ ├── nested.json │ │ ├── paths.json │ │ ├── profiles_100.json │ │ ├── sentences.json │ │ └── states_titlecase.json ├── CSharpTest.cs ├── ConcurrencyTest.cs ├── Couchbase.Lite.Tests.Shared.projitems ├── Couchbase.Lite.Tests.Shared.shproj ├── CouchbaseTestFramework.cs ├── DatabaseEncryptionTest.cs ├── DatabaseTest.cs ├── DictionaryTest.cs ├── DocPerfTest.cs ├── DocumentTest.cs ├── FragmentTest.cs ├── LoadTest.cs ├── LogTest.cs ├── MigrationTest.cs ├── MmapTest.cs ├── NotificationTest.cs ├── P2PTest.cs ├── PerfTest.cs ├── PredictiveQueryTest.cs ├── QueryTest.cs ├── ReplicationTest.cs ├── SQLiteOptionsTest.cs ├── ScopeCollectionTest.cs ├── ScopesCollections.QueryTest.cs ├── ScopesCollections.ReplicationTest.cs ├── TLSIdentityTest.cs ├── TestCase.cs ├── TunesPerfTest.cs ├── URLEndpointListenerTest.cs ├── Util │ ├── Benchmark.cs │ ├── ForIssueAttribute.cs │ ├── IMockConnectionErrorLogic.cs │ ├── ImplementsTestSpecAttribute.cs │ ├── MockConnection.cs │ ├── Try.cs │ ├── WaitAssert.cs │ └── XunitLogger.cs ├── VersionVectorTests.cs ├── WebSocketTest.cs ├── replacedb │ ├── android140-sqlite-noattachment.cblite2.zip │ ├── android140-sqlite.cblite2.zip │ └── android200-sqlite.cblite2.zip └── xunit.runner.json ├── Couchbase.Lite.sln ├── Couchbase.Lite ├── Couchbase.Lite.csproj └── Properties │ └── AssemblyInfo.cs ├── LiteCore ├── LiteCore.sln ├── binding_list │ └── c4.def ├── generate_bindings.ps1 ├── parse │ ├── config_c4.py │ ├── config_fleece.py │ ├── parse_API.py │ ├── parse_enums.py │ ├── parse_structs.py │ ├── templates_c4 │ │ ├── C4ExternalKeyCallbacks.cs │ │ ├── C4ExtraInfo_literal.cs │ │ ├── C4ListenerConfig.cs │ │ ├── C4PredictiveModel.cs │ │ ├── C4ReplicationCollection.cs │ │ ├── C4ReplicatorParameters.cs │ │ ├── C4SocketFactory.cs │ │ ├── C4TLSConfig.cs │ │ ├── UIntPtr.cs │ │ ├── bool.cs │ │ ├── delegate.cs │ │ ├── header.cs │ │ └── string.cs │ └── templates_fleece │ │ ├── FLArrayIterator_literal.cs │ │ ├── FLDictIterator_literal.cs │ │ ├── FLDictKey_literal.cs │ │ ├── UIntPtr.cs │ │ ├── bool.cs │ │ └── header.cs └── src │ └── LiteCore.Shared │ ├── API │ ├── CouchbaseLiteException.cs │ └── NativeWrapper.cs │ ├── Constants.cs │ ├── Interop │ ├── C4Base.cs │ ├── C4Base_defs.cs │ ├── C4Base_native.cs │ ├── C4BlobStore.cs │ ├── C4BlobStoreTypes_defs.cs │ ├── C4BlobStore_native.cs │ ├── C4BlobStore_native_safe.cs │ ├── C4Certificate.cs │ ├── C4CertificateTypes_defs.cs │ ├── C4Certificate_native.cs │ ├── C4Collection_native.cs │ ├── C4Collection_native_safe.cs │ ├── C4Database.cs │ ├── C4DatabaseTypes_defs.cs │ ├── C4Database_native.cs │ ├── C4Database_native_safe.cs │ ├── C4DocEnumerator.cs │ ├── C4DocEnumeratorTypes_defs.cs │ ├── C4Document+Fleece_native.cs │ ├── C4Document+Fleece_native_safe.cs │ ├── C4Document.cs │ ├── C4DocumentTypes_defs.cs │ ├── C4Document_native.cs │ ├── C4Document_native_safe.cs │ ├── C4Error_defs.cs │ ├── C4Error_native.cs │ ├── C4IndexTypes_defs.cs │ ├── C4Index_native.cs │ ├── C4Index_native_safe.cs │ ├── C4Listener.cs │ ├── C4ListenerTypes_defs.cs │ ├── C4Listener_native.cs │ ├── C4Log_defs.cs │ ├── C4Log_native.cs │ ├── C4Observer.cs │ ├── C4Observer_native.cs │ ├── C4Observer_native_safe.cs │ ├── C4PredictiveQuery_defs.cs │ ├── C4PredictiveQuery_native.cs │ ├── C4Private.cs │ ├── C4Query.cs │ ├── C4QueryTypes_defs.cs │ ├── C4Query_native.cs │ ├── C4Query_native_safe.cs │ ├── C4Replicator.cs │ ├── C4ReplicatorTypes_defs.cs │ ├── C4Replicator_native.cs │ ├── C4Replicator_native_safe.cs │ ├── C4Socket.cs │ ├── C4SocketTypes_defs.cs │ ├── C4Socket_native.cs │ ├── C4Socket_native_safe.cs │ ├── FLBase_defs.cs │ ├── FLCollections_defs.cs │ ├── FLCollections_native.cs │ ├── FLDeepIterator_defs.cs │ ├── FLDoc_native.cs │ ├── FLEncoder_defs.cs │ ├── FLEncoder_native.cs │ ├── FLExpert_defs.cs │ ├── FLExpert_native.cs │ ├── FLJSON_native.cs │ ├── FLKeyPath_defs.cs │ ├── FLMutable_defs.cs │ ├── FLMutable_native.cs │ ├── FLSlice_defs.cs │ ├── FLSlice_native.cs │ ├── FLValue_defs.cs │ ├── FLValue_native.cs │ ├── Fleece.cs │ ├── LiteCoreBridge.cs │ ├── Misc_native.cs │ ├── NativeActivate.cs │ ├── NativeHandler.cs │ ├── SQLiteStatus.cs │ ├── bridge_literals.txt │ ├── gen_bindings.py │ ├── interfacer.ps1 │ ├── raw_literals.txt │ └── templates │ │ ├── C4SliceResult_bridge.template │ │ ├── C4SliceResult_raw_return.template │ │ ├── C4SliceResult_return.template │ │ ├── C4Slice_bridge.template │ │ ├── C4Slice_bridge_param.template │ │ ├── C4Slice_raw.template │ │ ├── C4Slice_raw_return.template │ │ ├── C4Slice_return.template │ │ ├── C4Slice_using.template │ │ ├── C4StringResult_bridge.template │ │ ├── C4StringResult_raw_return.template │ │ ├── C4StringResult_return.template │ │ ├── C4String[]_raw.template │ │ ├── C4String_bridge.template │ │ ├── C4String_bridge_param.template │ │ ├── C4String_raw.template │ │ ├── C4String_raw_return.template │ │ ├── C4String_return.template │ │ ├── C4String_using.template │ │ ├── FLSliceResult_bridge.template │ │ ├── FLSliceResult_return.template │ │ ├── FLSlice_bridge.template │ │ ├── FLSlice_bridge_param.template │ │ ├── FLSlice_return.template │ │ ├── FLSlice_using.template │ │ ├── FLStringResult_bridge.template │ │ ├── FLStringResult_ptr_raw.template │ │ ├── FLStringResult_raw_return.template │ │ ├── FLStringResult_return.template │ │ ├── FLString_bridge.template │ │ ├── FLString_bridge_param.template │ │ ├── FLString_raw.template │ │ ├── FLString_raw_return.template │ │ ├── FLString_return.template │ │ ├── FLString_using.template │ │ ├── UIntPtr_bridge.template │ │ ├── UIntPtr_bridge_param.template │ │ ├── UIntPtr_return.template │ │ ├── bool_raw.template │ │ ├── byte_ptr_bridge.template │ │ ├── byte_ptr_raw.template │ │ └── byte_ptr_return.template │ ├── LiteCore.Shared.projitems │ ├── LiteCore.Shared.shproj │ └── Util │ ├── C4String.cs │ ├── Hasher.cs │ └── PerfTimer.cs ├── build ├── do_build.ps1 ├── get_litecore_source.py └── get_litecore_source_requirements.txt └── global.json /.appveyor/test.ps1: -------------------------------------------------------------------------------- 1 | Push-Location $PSScriptRoot\..\src\Couchbase.Lite.TestCoverage\ 2 | dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura 3 | if($LASTEXITCODE -ne 0) { 4 | exit $LASTEXITCODE 5 | } 6 | 7 | if (-not (Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER)) { 8 | Pop-Location 9 | exit $LASTEXITCODE 10 | } 11 | 12 | Pop-Location -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | ### Library Version 6 | 7 | 14 | 15 | ### .NET Runtime 16 | 17 | 23 | 24 | ### Operating System / Device Details 25 | 26 | 32 | 33 | ### Log Output 34 | 35 | 38 | 39 | ### Expected behavior 40 | 41 | 42 | 43 | ### Actual behavior 44 | 45 | 46 | 47 | ### Steps To Reproduce 48 | 49 | 50 | 51 | 1. 52 | 2. 53 | 3. 54 | 55 | ### Reproduction Project 56 | 57 | 60 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/.gitmodules -------------------------------------------------------------------------------- /Notes/CIAndVersions.md: -------------------------------------------------------------------------------- 1 | # A Guide to Couchbase Lite Versioning 2 | 3 | For version 2.0 we have yet again changed the way we are going to do our CI going forward. This is because the old way was causing too many manual steps and slowing down the process for us. The structure of the version numbers going forward will be the same, except with the small change that patch numbers are now going to be included even if they are 0: 4 | 5 | > |Major|.|Minor|.|Patch|\[.|Hotfix|\]\[-b|BuildNum|] (X.Y.Z.A-b####) 6 | 7 | Major, minor, patch, and hotfix are self-explanatory, and BuildNum is just an increasing count of builds generated by the CI server. If a build fails, that number is skipped. 8 | 9 | For 2.x our continuous integration server is no longer public. The reason for this is that we expect to be making biweekly pushes to our developer feed (http://nuget.mobile.couchbase.com/nuget/Developer/) which include the most stable bits from the past two weeks. All of the packages on the developer feed will be of the version form X.Y.Z-db###. DB in this case stands for developer build, and the numbers after will simply increase by one for each release. Due to a change in build and QE strategy, we will be "promoting" builds from now on from our internal feeds without any changes to the actual binaries. This has the side effect of the internal version (i.e. version in the logs) and the version in the Windows right click properties menu under details showing up in the form X.Y.Z-b#### (i.e. the build number it received when it was built). This is intentional, so don't worry. This ensures that once a build has received whatever validation it needs, that it is shipped bit for bit as is. 10 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 3.0.0.{build} 2 | branches: 3 | only: 4 | - master 5 | 6 | skip_tags: true 7 | environment: 8 | COVERALLS_REPO_TOKEN: 9 | secure: rYG0uD7eOutfMDvCi7Fe/W855aWp3b3/onQnk06bxp7EEKsYYdji5yD1euE8M37L 10 | 11 | init: 12 | - cmd: git config --global core.autocrlf true 13 | 14 | # Environment 15 | image: Visual Studio 2019 16 | clone_depth: 1 17 | 18 | install: 19 | - git submodule update --init --recursive 20 | 21 | build_script: 22 | # Fail fast if C# is broken 23 | - cmd: msbuild /t:Restore src/Couchbase.Lite/Couchbase.Lite.csproj /p:Configuration=Debug_Coverage 24 | - cmd: msbuild src/Couchbase.Lite/Couchbase.Lite.csproj /p:JUST_CSHARP=1 /p:Configuration=Debug_Coverage 25 | # x86 is unused 26 | - ps: | 27 | New-Item -Type Directory vendor/couchbase-lite-core/build_cmake/x86/RelWithDebInfo 28 | Push-Location vendor/couchbase-lite-core/build_cmake/x86/RelWithDebInfo 29 | New-Item -Type File LiteCore.dll 30 | New-Item -Type File LiteCore.pdb 31 | Pop-Location 32 | 33 | New-Item -Type Directory vendor/couchbase-lite-core/build_cmake/x64 34 | Push-Location vendor/couchbase-lite-core/build_cmake/x64 35 | cmake -G "Visual Studio 16 2019" -A x64 ..\.. 36 | cmake --build . --target LiteCore --config RelWithDebInfo 37 | Pop-Location 38 | - cmd: msbuild /t:Restore src/Couchbase.Lite.TestCoverage/Couchbase.Lite.TestCoverage.csproj 39 | - cmd: msbuild src/Couchbase.Lite.TestCoverage/Couchbase.Lite.TestCoverage.sln 40 | 41 | test_script: 42 | - ps: .appveyor/test.ps1 -------------------------------------------------------------------------------- /core_version.ini: -------------------------------------------------------------------------------- 1 | [version] 2 | build = 4.0.0-38 3 | 4 | [hashes] 5 | ce = 6d3748cd6dd8466bd4ac3c07744357662dfc1894 6 | ee = 81151912cf26bcfd9258b638ed6ea1d098cadc46 7 | -------------------------------------------------------------------------------- /jim_borden.gpg: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | 4 | mQENBFS+x4wBCADdrcWEWdEUduBMSCsLc9J8T05IQsp352WQjgJo/jFpsJimD0db 5 | IzxXnBZofQscyKqoQoCBZjnwAX3ND1Fl8iuWDZBmKrVU0GQBSvAGeHRvVinX+Chn 6 | 4DIIGHkRgXIk4MjK0hHfYq2SPN6Y9E57lzasjWEqc7cNiz2GQbfVjD/8wVQfSX4V 7 | cJ4Q6HnXEiBwHdT4zwW+n74P8ceP5OK5Ui5p2jjU8V94LMnwKoxMRKW8SMrptMEd 8 | Sc5yG38UPq/BAo1dZxp5SfaYmb6DeI53IAP8dxXK2zSTpOb8AUNpofx06r64fQeo 9 | 8A3/SyQ7WVD8t5MU8DBR+y6VjUOeKUgUSUjPABEBAAG0JUppbSBCb3JkZW4gPGpp 10 | bS5ib3JkZW5AY291Y2hiYXNlLmNvbT6JATgEEwECACIFAlS+x4wCGwMGCwkIBwMC 11 | BhUIAgkKCwQWAgMBAh4BAheAAAoJEBlio68BlKjRK6UIALa+6CFxcVux+SzvrI+7 12 | 0TAjYNmCyP7GxvCth9nVfeRa0/hLl9ZPBfqQ0r+3NUCSbqdYU4LIlNiYcXqtmMUm 13 | KAtmaewkA/FeUGIraWhniJzM/BC4LhnWSNpJZDmCNnAhDNIQUvvJM2CIgHTZ96IX 14 | 8zDlsWphFO2ygaeVCThDGL917bRfFHMODBVB1rJh3kz1BD/Im5okeXNZh210eQIF 15 | VkSu38R+GEDW4H1mDyP7MljnS0WCOseJWKhltNuPsAsFVSRRHTiafQyqeLOgSFYH 16 | ifyGP25dtLLfREA04Sq94feqt88A/1Ch75RGopII//yw2MT4BzDNLX6BDUPmYfBL 17 | rui5AQ0EVL7HjAEIAMp+C9rSUQgx89nr2swZWlpv7l+EqOpvwd4PyfzUTJJtpV9x 18 | Dr4weCpug4zZO1N6NF9YNCTZw8aHVx2U7B4XA/iMcZyQDfqaGxAuugkZx9jvrog+ 19 | AgTMKavAHsApEVSiZ67+shu1rN5qN3/9SCysfBqzqyaVTmVMX1k3R7b1LjiyRroy 20 | HU8vRkwPI80SqoHcwJf2XUG94t9sOlEiHNGeqjlzOLj2Z3EakXsmKGNFFhHCQwtb 21 | NbPTQNpZ3tfFPtl6Jfb0/O00HLufyPb/CpI3dcbFVFL9POoW+y2H5Ln6OGzAxTzp 22 | IlIMVv6tkyDGSkjDNuEyXt+h+OB4+4NNHbgQNE0AEQEAAYkBHwQYAQIACQUCVL7H 23 | jAIbDAAKCRAZYqOvAZSo0a1UB/4+6tcZTfCYcbev88FNdOFw2c0eFQhEaXNP+gBl 24 | RWJBmhkSjP3Jom5ik9JCMwHpnfd6oqQt0gHRhwo9fvtNbfUZbKHk79HuKn+5tE5y 25 | apxOD2oHSXHVI9KKTsuW2jq+XNpBGzH5Kdr7w0nS3xTYhoru2JY6K9qjsMLWGegJ 26 | nMiZ3CXLe98iN8ug2XoSvboH0nYs0KQCwyjsfSbAWZsgTW77PghOF4ysHbeKTsYg 27 | BdT5YxUxUktYbDwfcdPLHbgyhmsemr6zm3luke18TAjo6U4C8CO2e+q3Lf03/YNZ 28 | phXtUZr6lUGfAVcBN9A69pO94K89HddztiMf763vH27w5V4U 29 | =jSPu 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /packaging/nuget/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This is a proprietary build. This license must be replaced by the real one at build time. -------------------------------------------------------------------------------- /packaging/nuget/do_clean.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$true)][string]$apikey) 3 | 4 | $ErrorActionPreference = "Stop" 5 | 6 | $url="https://proget.sc.couchbase.com/nuget/CI/Packages()?`$format=json" 7 | $content=$(Invoke-WebRequest $url).Content 8 | $results = $(ConvertFrom-Json $content).d.results 9 | foreach($result in $results) { 10 | $ms = [long]$result.Published.Substring(7,13) 11 | $published = $(New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0).AddMilliseconds($ms) 12 | 13 | $now = $(Get-Date).ToUniversalTime() 14 | $limit = New-TimeSpan -Days 30 15 | if(($now - $published) -gt $limit) { 16 | Write-Host "Deleting $($result.Id)-$($result.Version)" 17 | 18 | # Nuget won't fail when deleting a non-existent package, and Internal is a strict subset of CI 19 | dotnet nuget delete --api-key $apikey --source https://proget.sc.couchbase.com/nuget/CI --non-interactive $result.Id $result.Version 20 | dotnet nuget delete --api-key $apikey --source https://proget.sc.couchbase.com/nuget/Internal --non-interactive $result.Id $result.Version 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packaging/nuget/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/packaging/nuget/logo.png -------------------------------------------------------------------------------- /src/AssemblyInfo.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | Couchbase Lite .NET 4 | 0.0.0 5 | A lightweight, document-oriented (NoSQL), syncable database engine for .NET 6 | Copyright 2014-$([System.DateTime]::Now.ToString(yyyy)) 7 | Couchbase, Inc. 8 | Couchbase 9 | LICENSE.txt 10 | https://github.com/couchbase/couchbase-lite-net 11 | logo.png 12 | README.md 13 | couchbase couchbase-mobile couchbase-lite sync database mobile netcore xamarin maui ios android windows linux mac osx nosql 14 | true 15 | $(MsBuildThisFileDirectory)packages 16 | True 17 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb 18 | latest 19 | false 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Conflict/Conflict.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Conflict.cs 3 | // 4 | // Copyright (c) 2019 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Diagnostics; 20 | 21 | namespace Couchbase.Lite 22 | { 23 | /// 24 | /// Conflict contains information of the conflicted documents, including local and 25 | /// remote document’s content. The null content means that the document is deleted. 26 | /// 27 | public class Conflict 28 | { 29 | /// 30 | /// The conflict resolved document id. 31 | /// 32 | public string DocumentID { get; } 33 | 34 | /// 35 | /// The document in local database. If null, the document is deleted. 36 | /// 37 | public Document? LocalDocument { get; } 38 | 39 | /// 40 | /// The document in remote database. If null, the document is deleted. 41 | /// 42 | public Document? RemoteDocument { get; } 43 | 44 | internal Conflict(string docID, Document? localDoc, Document? remoteDoc) 45 | { 46 | Debug.Assert(localDoc != null || remoteDoc != null, 47 | "Local and remote document shouldn't be empty at same time, when resolving conflict."); 48 | 49 | DocumentID = docID; 50 | LocalDocument = localDoc; 51 | RemoteDocument = remoteDoc; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Conflict/ConflictResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ConflictResolver.cs 3 | // 4 | // Copyright (c) 2019 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite 20 | { 21 | /// 22 | /// ConflictResolver provides access to the default conflict resolver used by the replicator. 23 | /// 24 | public static class ConflictResolver 25 | { 26 | /// 27 | /// Access IConflictResolver.Default to get the singleton DefaultConflictResolver object. 28 | /// Then call methods on that instance. 29 | /// 30 | public static IConflictResolver Default { get; } = new DefaultConflictResolver(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Conflict/DefaultConflictResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultConflictResolver.cs 3 | // 4 | // Copyright (c) 2019 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite 22 | { 23 | internal sealed class DefaultConflictResolver : IConflictResolver 24 | { 25 | /// 26 | /// The callback default conflict resolve method, if conflict occurs. 27 | /// 28 | public Document? Resolve(Conflict conflict) 29 | { 30 | if (conflict.RemoteDocument == null || conflict.LocalDocument == null) 31 | return null; 32 | 33 | return conflict.LocalDocument.Timestamp > conflict.RemoteDocument.Timestamp 34 | ? conflict.LocalDocument 35 | : conflict.RemoteDocument; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/DI/CouchbaseDependencyAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // CouchbaseDependencyAttribute.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Diagnostics.CodeAnalysis; 21 | 22 | namespace Couchbase.Lite.DI 23 | { 24 | /// 25 | /// An attribute to indicate that the specified class implements a dependency for 26 | /// Couchbase Lite (e.g. 27 | /// 28 | [ExcludeFromCodeCoverage] 29 | [AttributeUsage(AttributeTargets.Class)] 30 | public sealed class CouchbaseDependencyAttribute : Attribute 31 | { 32 | #region Properties 33 | 34 | /// 35 | /// Gets or sets if the dependency should be created when it is 36 | /// first requested (true) or immediately upon registration. 37 | /// 38 | public bool Lazy { get; set; } 39 | 40 | /// 41 | /// Gets or sets if the dependency is transient (i.e. should be created 42 | /// on each request) 43 | /// 44 | public bool Transient { get; set; } 45 | 46 | #endregion 47 | } 48 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/DI/IDefaultDirectoryResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IDefaultPathResolver.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.DI 20 | { 21 | 22 | /// 23 | /// An interface for resolving the default directory for a Couchbase Lite database 24 | /// since we may be operating in a sandboxed environment 25 | /// 26 | public interface IDefaultDirectoryResolver 27 | { 28 | #region Public Methods 29 | 30 | /// 31 | /// Gets the default directory for a Couchbase Lite database to live in 32 | /// 33 | /// The default directory for a Couchbase Lite database to live in 34 | string DefaultDirectory(); 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/DI/IMainThreadTaskScheduler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IMainThreadTaskScheduler.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Threading.Tasks; 20 | 21 | namespace Couchbase.Lite.DI 22 | { 23 | /// 24 | /// An interface for an object that can behave as a 25 | /// that invokes its tasks on the UI (main) thread of an application. Not applicable 26 | /// for all platforms, as some do not have main threads set up in a way that is usable 27 | /// (e.g. .NET Core) 28 | /// 29 | public interface IMainThreadTaskScheduler 30 | { 31 | #region Properties 32 | 33 | /// 34 | /// Gets if the currently executing thread is the main thread 35 | /// of the application 36 | /// 37 | bool IsMainThread { get; } 38 | 39 | #endregion 40 | 41 | #region Public Methods 42 | 43 | /// 44 | /// Returns the object as a so that 45 | /// it can be used for various .NET framework methods 46 | /// 47 | /// The main thread scheduler cast to a 48 | TaskScheduler AsTaskScheduler(); 49 | 50 | #endregion 51 | } 52 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/DI/IProxy.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IProxy.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Net; 21 | using System.Threading.Tasks; 22 | 23 | namespace Couchbase.Lite.DI 24 | { 25 | internal interface IProxy 26 | { 27 | Task CreateProxyAsync(Uri destination); 28 | } 29 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/DI/IReachability.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IReachability.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | using System; 19 | using Couchbase.Lite.Sync; 20 | 21 | namespace Couchbase.Lite.DI 22 | { 23 | /// 24 | /// An interface for describing whether a given URL is reachable via 25 | /// network connection or not. 26 | /// 27 | public interface IReachability 28 | { 29 | #region Variables 30 | 31 | /// 32 | /// Fired when the status of connectivity changes 33 | /// 34 | event EventHandler StatusChanged; 35 | 36 | #endregion 37 | 38 | #region Properties 39 | 40 | /// 41 | /// The URL to track connectivity to 42 | /// 43 | Uri? Url { get; set; } 44 | 45 | #endregion 46 | 47 | #region Public Methods 48 | 49 | /// 50 | /// Start monitoring for changes in network status 51 | /// 52 | void Start(); 53 | 54 | /// 55 | /// Stop monitoring for changes in network status 56 | /// 57 | void Stop(); 58 | 59 | #endregion 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/DI/IRuntimePlatform.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IRuntimePlatform.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.DI 20 | { 21 | /// 22 | /// An interface for getting OS and hardware information from a runtime platform 23 | /// 24 | public interface IRuntimePlatform 25 | { 26 | /// 27 | /// Gets the operating system name and version (and possibly other info) 28 | /// 29 | string OSDescription { get; } 30 | 31 | /// 32 | /// Gets the name of the device that is running the program, if possible 33 | /// 34 | string HardwareName { get; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Database/CollectionChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionChangedEventArgs.cs 3 | // 4 | // Copyright (c) 2022 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Collections.Generic; 20 | using System.Diagnostics; 21 | 22 | namespace Couchbase.Lite 23 | { 24 | /// 25 | /// The parameters of a collection changed event 26 | /// 27 | #pragma warning disable CS0618 // Type or member is obsolete 28 | public sealed class CollectionChangedEventArgs : DatabaseChangedEventArgs 29 | #pragma warning restore CS0618 // Type or member is obsolete 30 | { 31 | #region Properties 32 | 33 | /// 34 | /// Gets the collection in which the change occurred 35 | /// 36 | public Collection Collection { get; } 37 | 38 | #endregion 39 | 40 | #region Constructors 41 | 42 | internal CollectionChangedEventArgs(Collection collection, IReadOnlyList documentIDs, 43 | Database database) 44 | :base(database, documentIDs) 45 | { 46 | Collection = collection; 47 | } 48 | 49 | #endregion 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Database/DatabaseChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DatabaseChangedEventArgs.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Diagnostics; 22 | using System.Linq; 23 | 24 | namespace Couchbase.Lite 25 | { 26 | /// 27 | /// [DEPRECATED] The parameters of a database changed event 28 | /// 29 | [Obsolete("DatabaseChangedEventArgs is deprecated, please use CollectionChangedEventArgs")] 30 | public class DatabaseChangedEventArgs : EventArgs 31 | { 32 | #region Properties 33 | 34 | /// 35 | /// Gets the database in which the change occurred 36 | /// 37 | public Database Database { get; } 38 | 39 | /// 40 | /// Gets the document that was changed 41 | /// 42 | public IReadOnlyList DocumentIDs { get; } 43 | 44 | #endregion 45 | 46 | #region Constructors 47 | 48 | internal DatabaseChangedEventArgs(Database database, IReadOnlyList documentIDs) 49 | { 50 | Database = database; 51 | DocumentIDs = documentIDs; 52 | } 53 | 54 | #endregion 55 | } 56 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Document/Document+private.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Document+private.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Unsupported; 20 | 21 | public static class DocumentExtensions 22 | { 23 | public static string? RevisionIDs(this Document doc) 24 | { 25 | return doc.RevisionIDs; 26 | } 27 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Document/DocumentFragment.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DocumentFragment.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.Internal.Doc; 20 | 21 | namespace Couchbase.Lite 22 | { 23 | /// 24 | /// DocumentFragment provides access to a object. It also provides subscript access 25 | /// by key to the data values of the wrapped document. 26 | /// 27 | public sealed class DocumentFragment : IDictionaryFragment 28 | { 29 | #region Properties 30 | 31 | /// 32 | /// Gets the from the document fragment 33 | /// 34 | public Document? Document { get; } 35 | 36 | /// 37 | /// Gets whether or not this document is in the database 38 | /// 39 | public bool Exists => Document != null; 40 | 41 | /// 42 | public IFragment this[string key] => Document?[key] ?? Fragment.Null; 43 | 44 | #endregion 45 | 46 | #region Constructors 47 | 48 | internal DocumentFragment(Document? doc) 49 | { 50 | Document = doc; 51 | } 52 | 53 | #endregion 54 | } 55 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Document/IJSON.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IFragment.cs 3 | // 4 | // Copyright (c) 2022 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite 22 | { 23 | /// 24 | /// An interface desribing an object that can be serialized to JSON 25 | /// 26 | public interface IJSON 27 | { 28 | #region Properties 29 | 30 | /// 31 | /// Converts this object to JSON format string. 32 | /// 33 | /// The contents of this object in JSON format string 34 | /// Thrown if ToJSON is called from , 35 | /// , or 36 | string ToJSON(); 37 | 38 | #endregion 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Info/Defaults_Deprecated.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024-present Couchbase, Inc All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | using Couchbase.Lite.Sync; 18 | using Couchbase.Lite.Logging; 19 | 20 | using System; 21 | 22 | namespace Couchbase.Lite.Info; 23 | 24 | public static partial class Constants 25 | { 26 | /// 27 | /// Default value for (false) 28 | /// Plaintext is not used, and instead binary encoding is used in log files 29 | /// 30 | [Obsolete("Use Constants.UsePlantext instead")] 31 | public static readonly bool DefaultLogFileUsePlainText = DefaultLogFileUsePlaintext; 32 | 33 | /// 34 | /// Default value for (TimeSpan.FromSeconds(300)) 35 | /// Max wait time between retry attempts in seconds 36 | /// 37 | [Obsolete("Use Constants.DefaultReplicatorMaxAttemptsWaitTime (attempt -> attemps) instead")] 38 | public static readonly TimeSpan DefaultReplicatorMaxAttemptWaitTime = DefaultReplicatorMaxAttemptsWaitTime; 39 | } 40 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Log/ConsoleLogger.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ConsoleLogger.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | namespace Couchbase.Lite.Logging 19 | { 20 | /// 21 | /// An interface for an object that will log messages to the 22 | /// relevant debug console. For desktop this is the terminal, 23 | /// WinUI uses the visual studio debug output pane, iOS uses os_log 24 | /// and Android uses logcat. 25 | /// 26 | public interface IConsoleLogger : ILogger 27 | { 28 | #region Properties 29 | 30 | /// 31 | /// Gets or sets the domains that this logger will output 32 | /// 33 | LogDomain Domains { get; set; } 34 | 35 | /// 36 | /// Overrides the Level property 37 | /// with a public setter. 38 | /// 39 | new LogLevel Level { get; set; } 40 | 41 | #endregion 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Log/ILogger.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ILogger.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | namespace Couchbase.Lite.Logging 19 | { 20 | /// 21 | /// An interface for implementing a class that can accept 22 | /// logging messages from Couchbase Lite 23 | /// 24 | public interface ILogger 25 | { 26 | #region Properties 27 | 28 | /// 29 | /// Gets the level that the logger is currently 30 | /// logging 31 | /// 32 | LogLevel Level { get; } 33 | 34 | #endregion 35 | 36 | #region Public Methods 37 | 38 | /// 39 | /// Performs the actual logging to the log storage 40 | /// 41 | /// The level of the message being logged 42 | /// The domain of the message being logged 43 | /// The content of the message being logged 44 | void Log(LogLevel level, LogDomain domain, string message); 45 | 46 | #endregion 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Log/Log.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Log.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.DI; 20 | 21 | namespace Couchbase.Lite.Logging 22 | { 23 | /// 24 | /// The class that stores the three available logging facilities in Couchbase Lite 25 | /// 26 | public sealed class Log 27 | { 28 | #region Properties 29 | 30 | /// 31 | /// Gets the logging facility that logs to a debugging console 32 | /// 33 | public IConsoleLogger Console { get; } = Service.GetRequiredInstance(); 34 | 35 | /// 36 | /// Gets or sets the user defined logging facility 37 | /// 38 | public ILogger? Custom { get; set; } 39 | 40 | /// 41 | /// Gets the logging facility that logs to files on the disk 42 | /// 43 | public FileLogger File { get; } = new FileLogger(); 44 | 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/Collation.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Collation.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Globalization; 20 | using Couchbase.Lite.Internal.Query; 21 | 22 | namespace Couchbase.Lite.Query 23 | { 24 | /// 25 | /// A factory class for creating instances 26 | /// 27 | public static class Collation 28 | { 29 | /// 30 | /// The default locale for the current program, for use with Unicode collation 31 | /// 32 | internal static readonly string DefaultLocale = CultureInfo.CurrentCulture.Name == "" ? 33 | "en" : CultureInfo.CurrentCulture.Name.Replace('-', '_'); 34 | /// 35 | /// Creates an ASCII based collation instance 36 | /// 37 | /// An ASCII based collation instance 38 | public static IASCIICollation ASCII() => new QueryCollation(false); 39 | 40 | /// 41 | /// Creates a Unicode based collation instance (http://unicode.org/reports/tr10/) 42 | /// 43 | /// A Unicode based collation instance 44 | public static IUnicodeCollation Unicode() => new QueryCollation(true); 45 | } 46 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/FullTextExpression.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FullTextExpression.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | using Couchbase.Lite.Internal.Query; 22 | 23 | namespace Couchbase.Lite.Query 24 | { 25 | /// 26 | /// [DEPRECATED] A class that generates expressions that operate on the results of full-text searching 27 | /// 28 | [Obsolete("This class deprecated, please use FullTextFunction.")] 29 | public static class FullTextExpression 30 | { 31 | #region Public Methods 32 | 33 | /// 34 | /// [DEPRECATED] Generates a query expression that will check for matches against a 35 | /// given full text index name 36 | /// 37 | /// The name of the full-text index to perform the 38 | /// check against 39 | /// The generated query expression 40 | [Obsolete("This class deprecated, please use Match(string indexName, string query) in FullTextFunction class.")] 41 | public static IFullTextExpression Index(string name) => 42 | new QueryCompoundExpression("MATCH()", Expression.String(name), Expression.String(String.Empty)); 43 | 44 | #endregion 45 | } 46 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IDataSource.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IDataSource.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the source of data for a query 23 | /// 24 | public interface IDataSource 25 | { 26 | 27 | } 28 | 29 | /// 30 | /// An interface representing a source of data that comes from 31 | /// an 32 | /// 33 | public interface IDataSourceAs : IDataSource 34 | { 35 | #region Public Methods 36 | 37 | /// 38 | /// Attaches an alias to a given data source 39 | /// 40 | /// The alias to attach 41 | /// The datasource, for further operations 42 | IDataSource As(string alias); 43 | 44 | #endregion 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IFrom.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IFrom.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the FROM portion of an 23 | /// 24 | public interface IFrom : IQuery, IJoinRouter, IWhereRouter, IGroupByRouter, IOrderByRouter, ILimitRouter 25 | {} 26 | } 27 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IFromRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IFromRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a portion of a query that can be routed 23 | /// to a FROM portion 24 | /// 25 | public interface IFromRouter 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Routes this IExpression to the nexe FROM portion of a query 31 | /// 32 | /// The data source to use in the FROM portion of the query 33 | /// The next FROM portion of the query for further processing 34 | IFrom From(IDataSource dataSource); 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IFullTextExpression.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IFullTextExpression.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// [DEPRECATED] An interface that represents an expression that is eligible to receive 23 | /// full-text related query clauses 24 | /// 25 | public interface IFullTextExpression 26 | { 27 | /// 28 | /// [DEPRECATED] Returns an expression that will evaluate whether or not the given 29 | /// expression full text matches the current one 30 | /// 31 | /// The text to use for the match operation 32 | /// The expression representing the new operation 33 | IExpression Match(string query); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IGroupBy.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IGroupBy.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the GROUP BY portion of a query 23 | /// 24 | public interface IGroupBy : IQuery, IHavingRouter, IOrderByRouter, ILimitRouter 25 | { 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IGroupByRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IGroupByRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a portion of a query which can take GROUP BY 23 | /// as its next step 24 | /// 25 | public interface IGroupByRouter 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Groups the current query by the given GROUP BY clauses 31 | /// 32 | /// The clauses to group by 33 | /// The query grouped by the given clauses for further processing 34 | IGroupBy GroupBy(params IExpression[] expressions); 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IHaving.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IHaving.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the HAVING portion of a query (i.e. WHERE clause 23 | /// intended for a GROUP BY clause) 24 | /// 25 | public interface IHaving : IQuery, IOrderByRouter, ILimitRouter 26 | {} 27 | } 28 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IHavingRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IHavingRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a portion of a query that can take HAVING 23 | /// as its next step 24 | /// 25 | public interface IHavingRouter 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Adds the given expression as a HAVING clause onto this query 31 | /// 32 | /// The expression to use in the HAVING clause 33 | /// The query with the new clause for further processing 34 | IHaving Having(IExpression expression); 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IIndexExpression.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IIndexExpression.cs 3 | // 4 | // Copyright (c) 2022 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// The base interface used when an index is required to be specified 23 | /// in a QueryBuilder query. 24 | /// 25 | public interface IIndexExpression 26 | { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IIndexItem.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IIndexItem.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | namespace Couchbase.Lite.Query 19 | { 20 | /// 21 | /// An interface for an index item for use when creating value based indexes 22 | /// 23 | public interface IValueIndexItem 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// An interface for an index item for use when creating FTS based indexes 30 | /// 31 | public interface IFullTextIndexItem 32 | { 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IJoin.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IJoin.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a query that has just received a JOIN 23 | /// clause 24 | /// 25 | public interface IJoins : IQuery, IWhereRouter, IOrderByRouter, ILimitRouter 26 | {} 27 | 28 | /// 29 | /// An interface representing an with a JOIN clause 30 | /// 31 | public interface IJoin 32 | { 33 | } 34 | 35 | /// 36 | /// An interface representing an with a 37 | /// partially constructed JOIN clause that has not yet received its ON clause 38 | /// 39 | public interface IJoinOn : IJoin 40 | { 41 | #region Public Methods 42 | 43 | /// 44 | /// Adds the ON clause to the current JOIN clause 45 | /// 46 | /// The expression to use as the ON clause 47 | /// The query for further processing 48 | IJoin On(IExpression expression); 49 | 50 | #endregion 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IJoinRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IJoinRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a portion of an that can accept JOIN 23 | /// as its next clause 24 | /// 25 | public interface IJoinRouter 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Create and appends the list of JOINS to the current 31 | /// 32 | /// The join clauses to add 33 | /// The query with the join statement, for further processing 34 | IJoins Join(params IJoin[] joins); 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/ILimit.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ILimit.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a query that has had a limit and optionally an 23 | /// offset applied 24 | /// 25 | public interface ILimit : IQuery 26 | {} 27 | } 28 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/ILimitRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ILimitRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a query that can accept LIMIT as its next clause 23 | /// 24 | public interface ILimitRouter 25 | { 26 | #region Public Methods 27 | 28 | /// 29 | /// Limits a query to the given count (ulong, parameter, etc) 30 | /// 31 | /// The amount to limit the query to 32 | /// The query for further processing 33 | ILimit Limit(IExpression limit); 34 | 35 | /// 36 | /// Limits a query to the given count and also offsets it by 37 | /// a given count (ulong, parameter, etc) 38 | /// 39 | /// The amount to limit the query to 40 | /// The amount to offset the query by 41 | /// The query for further processing 42 | ILimit Limit(IExpression limit, IExpression? offset); 43 | 44 | #endregion 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IMetaExpression.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IMetaExpression.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// Represents an expression that is meant to retrieve metadata information 23 | /// inside of an 24 | /// 25 | public interface IMetaExpression : IExpression 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Specifies the source to retrieve the information from 31 | /// if multiple sources are used in a query 32 | /// 33 | /// The name of the data source 34 | /// The expression with the alias added 35 | IExpression From(string alias); 36 | 37 | #endregion 38 | } 39 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IOrderBy.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IOrderBy.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the ORDER BY portion of an 23 | /// 24 | public interface IOrderBy : IQuery, ILimitRouter 25 | {} 26 | 27 | /// 28 | /// An interface representing an arbitrary sorting for an 29 | /// 30 | public interface IOrdering 31 | { 32 | } 33 | 34 | /// 35 | /// An interface representing the way that an should be 36 | /// sorted 37 | /// 38 | public interface ISortOrder : IOrdering 39 | { 40 | #region Public Methods 41 | 42 | /// 43 | /// Returns an IExpression that will sort in ascending order 44 | /// 45 | /// An IExpression that will sort in ascending order 46 | IOrdering Ascending(); 47 | 48 | /// 49 | /// Returns an IExpression that will sort in desecending order 50 | /// 51 | /// An IExpression that will sort in desecending order 52 | IOrdering Descending(); 53 | 54 | #endregion 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IOrderByRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IOrderByRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a portion of a query that can be routed 23 | /// to an ORDER BY portion 24 | /// 25 | public interface IOrderByRouter 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Routes this IExpression to the next ORDER BY portion of the query 31 | /// 32 | /// An array of order by operations to consider in the 33 | /// ORDER BY portion of the query 34 | /// The next ORDER BY portion of the query 35 | IOrderBy OrderBy(params IOrdering[] orderings); 36 | 37 | #endregion 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IPropertyExpression.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IPropertyExpression.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface for an expression that will retrieve a property 23 | /// from a keypath 24 | /// 25 | public interface IPropertyExpression : IExpression 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Specifies where to retrieve the property from (necessary 31 | /// in instances where the query is coming from multiple sources) 32 | /// 33 | /// The alias of the source to retrieve from 34 | /// The expression, for further processing 35 | IExpression From(string alias); 36 | 37 | #endregion 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IQueryFactory.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IQueryFactory.cs 3 | // 4 | // Copyright (c) 2022 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite.Query 22 | { 23 | /// 24 | /// An interface describing an object that is capable of creating an object 25 | /// 26 | public interface IQueryFactory 27 | { 28 | /// 29 | /// Creates a Query object from the given SQL string. 30 | /// 31 | /// SQL Expression 32 | /// Thrown if 33 | /// is null 34 | /// Thrown if an error condition is returned from LiteCore 35 | /// Throw if compiling returns an error 36 | IQuery CreateQuery(string queryExpression); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IQueryIndex.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IQueryIndex.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using LiteCore.Interop; 20 | using System; 21 | 22 | namespace Couchbase.Lite.Query; 23 | 24 | /// 25 | /// An interface representing an existing index in a collection 26 | /// 27 | public partial interface IQueryIndex : IDisposable 28 | { 29 | /// 30 | /// The collection that this index belongs to 31 | /// 32 | Collection Collection { get; } 33 | 34 | /// 35 | /// The name of the index 36 | /// 37 | string Name { get; } 38 | } 39 | 40 | internal sealed unsafe partial class QueryIndexImpl : IQueryIndex 41 | { 42 | private C4IndexWrapper _index; 43 | 44 | public Collection Collection { get; } 45 | 46 | public string Name { get; } 47 | 48 | public QueryIndexImpl(C4IndexWrapper index, Collection collection, string name) 49 | { 50 | Collection = collection; 51 | Name = name; 52 | _index = index; 53 | } 54 | 55 | public void Dispose() 56 | { 57 | _index.Dispose(); 58 | } 59 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IResultSet.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IResultSet.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | 22 | namespace Couchbase.Lite.Query 23 | { 24 | /// 25 | /// An interface representing an enumerable collection of results 26 | /// from a given . 27 | /// 28 | /// 29 | /// Multiple enumerations are not supported. If you wish to enumerate 30 | /// more than once, then use or another LINQ 31 | /// method to materialize the results. 32 | /// 33 | public interface IResultSet : IEnumerable, IDisposable 34 | { 35 | /// 36 | /// Cross platform API entry to get all results in a list. Same 37 | /// as ToList() 38 | /// 39 | /// A list of results from the result set 40 | List AllResults(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/ISelect.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ISelect.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the SELECT portion of an 23 | /// 24 | public interface ISelect : IFromRouter 25 | {} 26 | } 27 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/ISelectResult.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ISelectResult.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface that holds information about what to 23 | /// select out of an 24 | /// 25 | public interface ISelectResult 26 | {} 27 | 28 | /// 29 | /// An interface representing a select result "FROM" a certain data 30 | /// source 31 | /// 32 | public interface ISelectResultFrom : ISelectResult 33 | { 34 | /// 35 | /// Specifies the source of this select result 36 | /// 37 | /// The alias of the data source to select from 38 | /// The modified select result 39 | ISelectResult From(string alias); 40 | } 41 | 42 | /// 43 | /// An interface reprsenting a select result that can be aliased to 44 | /// an arbitrary name 45 | /// 46 | public interface ISelectResultAs : ISelectResult 47 | { 48 | /// 49 | /// Adds an alias to the select result 50 | /// 51 | /// The alias to assign to the select result 52 | /// The modified select result 53 | ISelectResult As(string alias); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IVariableExpression.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IVariableExpression.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// A type of expression that represents the variable portion of an 23 | /// array based expression such as 24 | /// 25 | public interface IVariableExpression : IExpression 26 | { 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IWhere.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IWhere.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing the WHERE portion of an 23 | /// 24 | public interface IWhere : IQuery, IGroupByRouter, IOrderByRouter, ILimitRouter 25 | {} 26 | } 27 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/IWhereRouter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IWhereRouter.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Query 20 | { 21 | /// 22 | /// An interface representing a portion of a query that can be routed to 23 | /// a WHERE portion of the query. 24 | /// 25 | public interface IWhereRouter 26 | { 27 | #region Public Methods 28 | 29 | /// 30 | /// Routes this portion of the query to the next WHERE portion of the 31 | /// query 32 | /// 33 | /// The expression to evaluate in the WHERE portion 34 | /// The next WHERE portion of the query 35 | IWhere Where(IExpression expression); 36 | 37 | #endregion 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Query/ValueIndexConfiguration.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ValueIndexConfiguration.cs 3 | // 4 | // Copyright (c) 2021 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.Internal.Query; 20 | using LiteCore.Interop; 21 | 22 | namespace Couchbase.Lite.Query 23 | { 24 | /// 25 | /// An class for an index based on a simple property value 26 | /// 27 | public sealed class ValueIndexConfiguration : IndexConfiguration 28 | { 29 | #region Properties 30 | internal override C4IndexOptions Options => new C4IndexOptions(); 31 | #endregion 32 | 33 | #region Constructors 34 | 35 | /// 36 | /// Starts the creation of an index based on a simple property 37 | /// 38 | /// The expressions to use to create the index 39 | /// The beginning of a value based index 40 | public ValueIndexConfiguration(params string[] expressions) 41 | : base(C4IndexType.ValueIndex, expressions) 42 | { 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/RuntimeException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RuntimeException.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite 22 | { 23 | /// 24 | /// An exception that is thrown in rare circumstances where the runtime returns 25 | /// an unexpected value for a method (usually null) 26 | /// 27 | public sealed class RuntimeException : Exception 28 | { 29 | internal RuntimeException(string message) : base(message) 30 | { 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Sync/Authenticator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Authenticator.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Sync 20 | { 21 | /// 22 | /// An abstract base class for authenticator classes. This class 23 | /// has no public methods. 24 | /// 25 | public abstract class Authenticator 26 | { 27 | #region Internal Methods 28 | 29 | internal abstract void Authenticate(ReplicatorOptionsDictionary options); 30 | 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Sync/IEndpoint.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IEndpoint.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Sync 20 | { 21 | /// 22 | /// Represents an endpoint in a replication 23 | /// 24 | public interface IEndpoint 25 | { 26 | 27 | } 28 | 29 | internal interface IEndpointInternal : IEndpoint 30 | { 31 | void Visit(ReplicatorConfiguration config); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Sync/ProxyAuthenticator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ProxyAuthenticator.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.Sync; 20 | using System; 21 | 22 | /// 23 | /// A class for storing credentials for a proxy that needs authentication 24 | /// 25 | public sealed class ProxyAuthenticator 26 | { 27 | /// 28 | /// Gets the username sent to the proxy 29 | /// 30 | public string Username { get; init; } 31 | 32 | /// 33 | /// Gets the password sent to the proxy 34 | /// 35 | public string Password { get; init; } 36 | 37 | /// 38 | /// Default constructor 39 | /// 40 | /// The username to send to the proxy 41 | /// The password to send to the proxy 42 | public ProxyAuthenticator(string username, string password) 43 | { 44 | Username = username; 45 | Password = password; 46 | } 47 | 48 | internal void Authenticate(ReplicatorOptionsDictionary options) 49 | { 50 | var authDict = new AuthOptionsDictionary 51 | { 52 | Username = Username, 53 | Password = Password 54 | }; 55 | 56 | options.ProxyAuth = authDict; 57 | } 58 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Sync/ReplicationActivityLevel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ReplicationActivityLevel.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite.Sync 20 | { 21 | /// 22 | /// An enum describing states for a 23 | /// 24 | public enum ReplicatorActivityLevel 25 | { 26 | /// 27 | /// The replication is finished or hit a fatal error 28 | /// 29 | Stopped, 30 | /// 31 | /// The replicator has detected that there is no Internet connection available 32 | /// 33 | Offline, 34 | /// 35 | /// The replicator is connecting to the remote host 36 | /// 37 | Connecting, 38 | /// 39 | /// The replication is inactive; either waiting for changes or offline 40 | /// because the remote host is unreachable 41 | /// 42 | Idle, 43 | /// 44 | /// The replication is actively transferring data 45 | /// 46 | Busy 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/API/Sync/ReplicatorStatus.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ReplicatorStatus.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite.Sync 22 | { 23 | /// 24 | /// A struct describing the current status of a 25 | /// 26 | public struct ReplicatorStatus 27 | { 28 | /// 29 | /// Gets the current state of the replication (i.e. whether or not it is 30 | /// actively processing changes) 31 | /// 32 | public ReplicatorActivityLevel Activity { get; } 33 | 34 | /// 35 | /// Gets the current progress of the replication 36 | /// 37 | public ReplicatorProgress Progress { get; } 38 | 39 | /// 40 | /// Gets the last error that occurred, if any 41 | /// 42 | public Exception? Error { get; } 43 | 44 | internal ReplicatorStatus(ReplicatorActivityLevel activity, ReplicatorProgress progress, Exception? error) 45 | { 46 | Activity = activity; 47 | Progress = progress; 48 | Error = error; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Couchbase.Lite.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9b92b9d6-5dd3-477a-883b-1b40d5deef3b 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Document/DocContext.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DocContext.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.Internal.Serialization; 20 | 21 | using LiteCore.Interop; 22 | 23 | namespace Couchbase.Lite.Internal.Doc 24 | { 25 | internal unsafe class DocContext : MContext 26 | { 27 | #region Properties 28 | 29 | public Database Db { get; } 30 | 31 | public C4DocumentWrapper? Doc { get; } 32 | 33 | #endregion 34 | 35 | #region Constructors 36 | 37 | public DocContext(Database database, C4DocumentWrapper? doc) 38 | : base(new FLSlice()) 39 | { 40 | Db = database; 41 | Doc = doc?.Retain(); 42 | } 43 | 44 | #endregion 45 | 46 | #region Public Methods 47 | 48 | public object? ToObject(FLValue* value, bool dotNetType) 49 | { 50 | return FLValueConverter.ToCouchbaseObject(value, Db, dotNetType); 51 | } 52 | 53 | #endregion 54 | 55 | #region Overrides 56 | 57 | protected override void Dispose(bool disposing) 58 | { 59 | base.Dispose(disposing); 60 | 61 | if (disposing) { 62 | Doc?.Dispose(); 63 | } 64 | } 65 | 66 | #endregion 67 | } 68 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Linq/IDocumentModel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IDocumentModel.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if CBL_LINQ 19 | using Newtonsoft.Json; 20 | 21 | namespace Couchbase.Lite.Linq 22 | { 23 | public interface IDocumentModel 24 | { 25 | [JsonIgnore] 26 | Document Document { get; set; } 27 | } 28 | } 29 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Linq/LiteCoreOrderingExpressionVisitor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // LiteCoreOrderingExpressionVisitor.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if CBL_LINQ 19 | using System.Collections.Generic; 20 | using System.Linq; 21 | using System.Linq.Expressions; 22 | 23 | using Remotion.Linq.Clauses; 24 | 25 | namespace Couchbase.Lite.Internal.Linq 26 | { 27 | internal sealed class LiteCoreOrderingExpressionVisitor : LiteCoreExpressionVisitor 28 | { 29 | #region Public Methods 30 | 31 | public static IList GetJsonExpression(Expression expression, OrderingDirection direction) 32 | { 33 | var visitor = new LiteCoreOrderingExpressionVisitor(); 34 | visitor.Visit(expression); 35 | return visitor.GetJsonExpression(direction); 36 | } 37 | 38 | public IList GetJsonExpression(OrderingDirection direction) 39 | { 40 | var retVal = _query.First() as IList; 41 | if (direction == OrderingDirection.Asc) { 42 | return retVal; 43 | } 44 | 45 | retVal.Insert(0, "DESC"); 46 | return new List { retVal }; 47 | } 48 | 49 | #endregion 50 | } 51 | } 52 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Linq/LiteCoreWhereExpressionVisitor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // LiteCoreExpressionTreeVisitor.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if CBL_LINQ 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Diagnostics.CodeAnalysis; 22 | using System.Linq; 23 | using System.Linq.Expressions; 24 | using System.Text; 25 | 26 | using Remotion.Linq.Clauses; 27 | using Remotion.Linq.Clauses.Expressions; 28 | using Remotion.Linq.Clauses.ResultOperators; 29 | 30 | namespace Couchbase.Lite.Internal.Linq 31 | { 32 | internal sealed class LiteCoreWhereExpressionVisitor : LiteCoreExpressionVisitor 33 | { 34 | 35 | 36 | #region Public Methods 37 | 38 | public static IList GetJsonExpression(Expression expression) 39 | { 40 | var visitor = new LiteCoreWhereExpressionVisitor(); 41 | visitor.Visit(expression); 42 | return visitor.GetJsonExpression(); 43 | } 44 | 45 | public IList GetJsonExpression() 46 | { 47 | if(_query.Count > 1) { 48 | _query.Insert(0, "AND"); 49 | } 50 | 51 | return _query.First() as IList; 52 | } 53 | 54 | #endregion 55 | 56 | 57 | 58 | } 59 | } 60 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Query/DataSource.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DataSource.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Diagnostics; 20 | 21 | using Couchbase.Lite.Query; 22 | using Couchbase.Lite.Support; 23 | 24 | namespace Couchbase.Lite.Internal.Query 25 | { 26 | internal abstract class QueryDataSource : IDataSource 27 | { 28 | #region Properties 29 | 30 | internal virtual string? ColumnName => null; 31 | 32 | internal object Source { get; } 33 | 34 | internal ThreadSafety ThreadSafety { get; } 35 | 36 | #endregion 37 | 38 | #region Constructors 39 | 40 | protected QueryDataSource(object source, ThreadSafety threadSafety) 41 | { 42 | Source = source; 43 | ThreadSafety = threadSafety; 44 | } 45 | 46 | #endregion 47 | 48 | #region Public Methods 49 | 50 | public abstract object ToJSON(); 51 | 52 | #endregion 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Query/LimitedQuery.cs: -------------------------------------------------------------------------------- 1 | // 2 | // LimitedQuery.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.Internal.Logging; 20 | using Couchbase.Lite.Query; 21 | using Couchbase.Lite.Util; 22 | 23 | namespace Couchbase.Lite.Internal.Query 24 | { 25 | internal abstract class LimitedQuery : XQuery, ILimitRouter, ILimit 26 | { 27 | #region Constants 28 | 29 | private const string Tag = nameof(LimitedQuery); 30 | 31 | #endregion 32 | 33 | #region ILimitRouter 34 | 35 | public ILimit Limit(IExpression limit) 36 | { 37 | CBDebug.MustNotBeNull(WriteLog.To.Query, Tag, nameof(limit), limit); 38 | 39 | LimitValue = limit; 40 | return this; 41 | } 42 | 43 | public ILimit Limit(IExpression limit, IExpression? offset) 44 | { 45 | CBDebug.MustNotBeNull(WriteLog.To.Query, Tag, nameof(limit), limit); 46 | 47 | LimitValue = limit; 48 | SkipValue = offset; 49 | return this; 50 | } 51 | 52 | #endregion 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Query/QueryIndexItem.cs: -------------------------------------------------------------------------------- 1 | // 2 | // QueryIndexItem.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using Couchbase.Lite.Query; 20 | using Couchbase.Lite.Util; 21 | 22 | namespace Couchbase.Lite.Internal.Query 23 | { 24 | internal sealed class QueryIndexItem : IValueIndexItem, IFullTextIndexItem 25 | { 26 | public readonly QueryExpression Expression; 27 | 28 | internal QueryIndexItem(IExpression expression) 29 | { 30 | Expression = Misc.TryCast(expression); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Query/QueryResultContext.cs: -------------------------------------------------------------------------------- 1 | // 2 | // QueryResultContext.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | using Couchbase.Lite.Internal.Doc; 19 | 20 | using LiteCore.Interop; 21 | 22 | namespace Couchbase.Lite.Internal.Query 23 | { 24 | internal sealed unsafe class QueryResultContext : DocContext 25 | { 26 | #region Variables 27 | 28 | private readonly C4QueryEnumeratorWrapper _enumerator; 29 | 30 | #endregion 31 | 32 | #region Constructors 33 | 34 | public QueryResultContext(Database db, C4QueryEnumeratorWrapper enumerator) 35 | : base(db, null) 36 | { 37 | _enumerator = enumerator; 38 | } 39 | 40 | #endregion 41 | 42 | #region Overrides 43 | 44 | protected override void Dispose(bool disposing) 45 | { 46 | base.Dispose(disposing); 47 | if (disposing) { 48 | _enumerator.Dispose(); 49 | } 50 | } 51 | 52 | #endregion 53 | } 54 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Query/Where.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Where.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | using Couchbase.Lite.Internal.Logging; 19 | using Couchbase.Lite.Query; 20 | using Couchbase.Lite.Util; 21 | 22 | namespace Couchbase.Lite.Internal.Query 23 | { 24 | internal sealed class Where : LimitedQuery, IWhere 25 | { 26 | #region Constants 27 | 28 | private const string Tag = nameof(Where); 29 | 30 | #endregion 31 | 32 | #region Constructors 33 | 34 | internal Where(XQuery query, IExpression expression) 35 | { 36 | Copy(query); 37 | WhereImpl = expression as QueryExpression; 38 | } 39 | 40 | #endregion 41 | 42 | #region IGroupByRouter 43 | 44 | public IGroupBy GroupBy(params IExpression[] expressions) 45 | { 46 | CBDebug.ItemsMustNotBeNull(WriteLog.To.Query, Tag, nameof(expressions), expressions); 47 | return new QueryGroupBy(this, expressions); 48 | } 49 | 50 | #endregion 51 | 52 | #region IOrderByRouter 53 | 54 | public IOrderBy OrderBy(params IOrdering[] orderings) 55 | { 56 | CBDebug.ItemsMustNotBeNull(WriteLog.To.Query, Tag, nameof(orderings), orderings); 57 | return new QueryOrderBy(this, orderings); 58 | } 59 | 60 | #endregion 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/Android/AndroidRuntimePlatform.cs: -------------------------------------------------------------------------------- 1 | // 2 | // AndroidRuntimePlatform.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if __ANDROID__ 19 | using System; 20 | using Android.OS; 21 | using Couchbase.Lite.DI; 22 | 23 | namespace Couchbase.Lite.Support 24 | { 25 | [CouchbaseDependency] 26 | internal sealed class AndroidRuntimePlatform : IRuntimePlatform 27 | { 28 | public string OSDescription => $"Android {Build.VERSION.Release} [API {(int)Build.VERSION.SdkInt}]"; 29 | 30 | public string HardwareName 31 | { 32 | get { 33 | var manufacturer = Build.Manufacturer; 34 | var model = Build.Model; 35 | if(model == null) { 36 | return $"{manufacturer ?? "Unknown Manufacturer"} Unknown Model"; 37 | } 38 | 39 | if (manufacturer == null || model.StartsWith(manufacturer, StringComparison.InvariantCultureIgnoreCase)) { 40 | return Capitalize(model); 41 | } else { 42 | return $"{Capitalize(manufacturer)} {model}"; 43 | } 44 | } 45 | } 46 | 47 | private string Capitalize(string input) 48 | { 49 | if(String.IsNullOrWhiteSpace(input) || Char.IsUpper(input[0])) { 50 | return input; 51 | } 52 | 53 | return $"{Char.ToUpperInvariant(input[0])}{input.Substring((1))}"; 54 | } 55 | } 56 | } 57 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/Android/DefaultDirectoryResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultDirectoryResolver.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if __ANDROID__ 19 | using Android.Content; 20 | using Couchbase.Lite.DI; 21 | using LiteCore.Interop; 22 | 23 | namespace Couchbase.Lite.Support 24 | { 25 | internal sealed class DefaultDirectoryResolver : IDefaultDirectoryResolver 26 | { 27 | private readonly Context _context; 28 | 29 | public DefaultDirectoryResolver(Context context) 30 | { 31 | _context = context; 32 | } 33 | 34 | public string DefaultDirectory() 35 | { 36 | if(_context.FilesDir == null) { 37 | throw new CouchbaseLiteException(C4ErrorCode.UnexpectedError, 38 | "Android files directory is null, cannot calculate default directory!"); 39 | } 40 | 41 | return _context.FilesDir.AbsolutePath; 42 | } 43 | } 44 | } 45 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/Freezer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Freezer.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Runtime.CompilerServices; 21 | 22 | namespace Couchbase.Lite.Support 23 | { 24 | internal sealed class Freezer 25 | { 26 | #region Variables 27 | 28 | private bool _frozen; 29 | private string? _message; 30 | 31 | #endregion 32 | 33 | #region Public Methods 34 | 35 | public void Freeze(string message) 36 | { 37 | _frozen = true; 38 | _message = message; 39 | } 40 | 41 | public void PerformAction(Action a, [CallerMemberName]string? caller = null) 42 | { 43 | if (_frozen) { 44 | throw new InvalidOperationException($"{CouchbaseLiteErrorMessage.ReadOnlyObject} '{caller}' ({_message})"); 45 | } 46 | 47 | a(); 48 | } 49 | 50 | public void SetValue(ref T location, T newValue, [CallerMemberName]string? caller = null) 51 | { 52 | if (_frozen) { 53 | throw new InvalidOperationException($"{CouchbaseLiteErrorMessage.ReadOnlyObject} '{caller}' ({_message})"); 54 | } 55 | 56 | location = newValue; 57 | } 58 | 59 | #endregion 60 | } 61 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/IStoppable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IStoppable.cs 3 | // 4 | // Copyright (c) 2020 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace Couchbase.Lite 20 | { 21 | interface IStoppable 22 | { 23 | void Stop(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/IThreadSafety.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IThreadSafety.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite.Support 22 | { 23 | internal interface IThreadSafety 24 | { 25 | IDisposable BeginLockedScope(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/SerialQueue.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SerialQueue.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Threading.Tasks; 21 | 22 | namespace Dispatch 23 | { 24 | /// Useful extension methods for queues 25 | internal static class IDispatchQueueExtensions 26 | { 27 | public static Task DispatchAfter(this IDispatchQueue queue, TimeSpan dueTime, Func func) 28 | { 29 | var tcs = new TaskCompletionSource(); 30 | queue.DispatchAfter(dueTime, () => { 31 | try { 32 | tcs.SetResult(func()); 33 | } catch (Exception e) { 34 | tcs.TrySetException(e); 35 | } 36 | }); 37 | return tcs.Task; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/ThreadSafety.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ThreadSafety.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | using System; 19 | using System.Threading; 20 | 21 | namespace Couchbase.Lite.Support 22 | { 23 | internal sealed class ThreadSafety : IThreadSafety 24 | { 25 | 26 | private readonly object _lock = new object(); 27 | 28 | public IDisposable BeginLockedScope() 29 | { 30 | bool lockTaken = false; 31 | #if !NO_THREADSAFE 32 | Monitor.Enter(_lock, ref lockTaken); 33 | #endif 34 | return new ScopeExit(_lock, lockTaken); 35 | } 36 | 37 | private sealed class ScopeExit : IDisposable 38 | { 39 | private readonly object _lock; 40 | private bool _mustUnlock; 41 | 42 | public ScopeExit(object locker, bool mustUnlock) 43 | { 44 | _lock = locker; 45 | _mustUnlock = mustUnlock; 46 | } 47 | 48 | public void Dispose() 49 | { 50 | #if !NO_THREADSAFE 51 | if (_mustUnlock) { 52 | Monitor.Exit(_lock); 53 | _mustUnlock = false; 54 | } 55 | #endif 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/iOS/DefaultDirectoryResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultDirectoryResolver.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if __IOS__ 19 | using System.IO; 20 | using Couchbase.Lite.DI; 21 | using Foundation; 22 | 23 | namespace Couchbase.Lite.Support 24 | { 25 | [CouchbaseDependency] 26 | internal sealed class DefaultDirectoryResolver : IDefaultDirectoryResolver 27 | { 28 | public string DefaultDirectory() 29 | { 30 | var dirID = NSSearchPathDirectory.ApplicationSupportDirectory; 31 | 32 | var paths = NSSearchPath.GetDirectories(dirID, NSSearchPathDomain.User, true); 33 | var path = paths[0]; 34 | 35 | return Path.Combine(path, "CouchbaseLite"); 36 | } 37 | } 38 | } 39 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/iOS/iOSRuntimePlatform.cs: -------------------------------------------------------------------------------- 1 | // 2 | // iOSRuntimePlatform.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #if __IOS__ 19 | using Couchbase.Lite.DI; 20 | using Foundation; 21 | using UIKit; 22 | 23 | namespace Couchbase.Lite.Support 24 | { 25 | [CouchbaseDependency] 26 | internal sealed class iOSRuntimePlatform : IRuntimePlatform 27 | { 28 | #if MACCATALYST 29 | public string OSDescription => $"macOS (Catalyst) {NSProcessInfo.ProcessInfo.OperatingSystemVersion}"; 30 | 31 | public string HardwareName => ""; 32 | #else 33 | public string OSDescription => $"iOS {NSProcessInfo.ProcessInfo.OperatingSystemVersion}"; 34 | 35 | public string HardwareName => UIDevice.CurrentDevice.Model; 36 | #endif 37 | } 38 | } 39 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Support/netdesktop/DefaultDirectoryResolver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultDirectoryResolver.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // Windows 2012 doesn't define the more generic variants 20 | #if (NETFRAMEWORK || NET462 || NET6_0_OR_GREATER) && !__MOBILE__ && !CBL_PLATFORM_WINUI 21 | using System; 22 | using System.IO; 23 | using Couchbase.Lite.DI; 24 | 25 | namespace Couchbase.Lite.Support 26 | { 27 | // NOTE: AppContext.BaseDirectory is not entirely reliable, but there is no other choice 28 | // It seems to usually be in the right place? 29 | 30 | [CouchbaseDependency] 31 | internal sealed class DefaultDirectoryResolver : IDefaultDirectoryResolver 32 | { 33 | #region IDefaultDirectoryResolver 34 | 35 | public string DefaultDirectory() 36 | { 37 | var baseDirectory = AppContext.BaseDirectory ?? 38 | throw new RuntimeException("BaseDirectory was null, cannot continue..."); 39 | return Path.Combine(baseDirectory, "CouchbaseLite"); 40 | } 41 | 42 | #endregion 43 | } 44 | } 45 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Util/AtomicBool.cs: -------------------------------------------------------------------------------- 1 | // 2 | // AtomicBool.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | using System.Threading; 19 | 20 | namespace Couchbase.Lite.Util 21 | { 22 | internal struct AtomicBool 23 | { 24 | private int _value; 25 | 26 | public AtomicBool(bool value) 27 | { 28 | _value = value ? 1 : 0; 29 | } 30 | 31 | public bool Set(bool value) 32 | { 33 | return Interlocked.Exchange(ref _value, value ? 1 : 0) != 0; 34 | } 35 | 36 | public bool CompareExchange(bool value, bool condition) 37 | { 38 | return Interlocked.CompareExchange(ref _value, value ? 1 : 0, condition ? 1 : 0) != 0; 39 | } 40 | 41 | public static implicit operator bool(AtomicBool value) 42 | { 43 | return value._value != 0; 44 | } 45 | 46 | public static implicit operator AtomicBool(bool value) 47 | { 48 | return new AtomicBool(value); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Util/DisposalWatchdog.cs: -------------------------------------------------------------------------------- 1 | // 2 | // DisposalWatchdog.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | 21 | namespace Couchbase.Lite.Util 22 | { 23 | internal sealed class DisposalWatchdog : IDisposable 24 | { 25 | #region Variables 26 | 27 | private readonly string _name; 28 | 29 | #endregion 30 | 31 | #region Properties 32 | 33 | public bool IsDisposed { get; private set; } 34 | 35 | #endregion 36 | 37 | #region Constructors 38 | 39 | public DisposalWatchdog(string name) 40 | { 41 | _name = name; 42 | } 43 | 44 | #endregion 45 | 46 | #region Public Methods 47 | 48 | public void CheckDisposed() 49 | { 50 | if (IsDisposed) { 51 | throw new ObjectDisposedException(_name); 52 | } 53 | } 54 | 55 | #endregion 56 | 57 | #region IDisposable 58 | 59 | public void Dispose() 60 | { 61 | IsDisposed = true; 62 | } 63 | 64 | #endregion 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Shared/Util/RunOnce.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RefCountedDisposable.cs 3 | // 4 | // Copyright (c) 2019 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.Collections.Concurrent; 21 | using System.Diagnostics; 22 | 23 | namespace Couchbase.Lite.Util 24 | { 25 | internal static class Run 26 | { 27 | #region Constants 28 | 29 | private static readonly ConcurrentDictionary Instances = 30 | new ConcurrentDictionary(); 31 | 32 | #endregion 33 | 34 | #region Public Methods 35 | 36 | public static void Once(string identifier, Action a) 37 | { 38 | if (Instances.TryAdd(identifier, 0)) { 39 | a(); 40 | } 41 | } 42 | 43 | #endregion 44 | 45 | #region Internal Methods 46 | 47 | #if DEBUG 48 | 49 | internal static void Clear(string identifier) 50 | { 51 | Instances.TryRemove(identifier, out var tmp); 52 | } 53 | 54 | #endif 55 | 56 | #endregion 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Support.Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Couchbase.Lite")] 4 | [assembly: InternalsVisibleTo("Couchbase.Lite.Tests.Maui")] 5 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Support.NetDesktop/desktop.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | <_NugetRuntimesPath Condition="'$(_NugetRuntimesPath)' == ''">$(MSBuildThisFileDirectory)..\..\runtimes\ 4 | 5 | 6 | 7 | x64\LiteCore.dll 8 | PreserveNewest 9 | 10 | 11 | arm64\LiteCore.dll 12 | PreserveNewest 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.NetCore/modify_packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd `dirname $0` 4 | sed "s/[0-9].[0-9].[0-9]-b..../$1-$2/g" Couchbase.Lite.Tests.NetCore.csproj > tmp 5 | mv tmp Couchbase.Lite.Tests.NetCore.csproj 6 | popd 7 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.NetCore/replacedb/android140-sqlite-noattachment.cblite2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.NetCore/replacedb/android140-sqlite-noattachment.cblite2.zip -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.NetCore/replacedb/android140-sqlite.cblite2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.NetCore/replacedb/android140-sqlite.cblite2.zip -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.NetCore/replacedb/android200-sqlite.cblite2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.NetCore/replacedb/android200-sqlite.cblite2.zip -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/SelfSigned.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/SelfSigned.cer -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/attachment.png -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/certs.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/certs.p12 -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/certs.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/certs.pfx -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/client-ca.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/client-ca.der -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/client.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/client.p12 -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/client.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/C/tests/data/client.pfx -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/create_new_chain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | echo 4 | echo "You will be prompted for a password, use your own chosen password and keep entering the same one until told otherwise." 5 | read -p "Press Enter to continue" 6 | 7 | openssl genrsa -aes256 -out test-ca.key 4096 8 | openssl req -x509 -new -nodes -key test-ca.key -sha256 -days 3650 -out test-ca.crt -subj "/CN=Test CA/C=JP/ST=Tokyo/L=Tokyo/O=Couchbase" 9 | openssl req -new -nodes -out test-node.csr -newkey rsa:4096 -keyout test-node.key -subj "/CN=Test Node/C=JP/ST=Tokyo/L=Tokyo/O=Couchbase" 10 | 11 | cat > test-node.v3.ext << EOF 12 | authorityKeyIdentifier=keyid,issuer 13 | basicConstraints=CA:FALSE 14 | keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment 15 | EOF 16 | 17 | openssl x509 -req -in test-node.csr -CA test-ca.crt -CAkey test-ca.key -CAcreateserial -out test-node.crt -days 3650 -sha256 -extfile test-node.v3.ext 18 | 19 | rm test-node.v3.ext 20 | rm test-node.csr 21 | rm test-ca.srl 22 | 23 | echo 24 | echo "Use the password 123 if you want the exported p12 to work correctly with the tests" 25 | read -p "Press Enter to continue" 26 | 27 | openssl pkcs12 -export -out client.p12 -inkey test-node.key -in test-node.crt 28 | openssl x509 -in test-ca.crt -out client-ca.der -outform DER 29 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/nested.json: -------------------------------------------------------------------------------- 1 | {"shapes": [{"color": "red", "size": 3}, {"color": "green", "size": 2}, {"color": "blue", "size": 10}]} 2 | {"shapes": []} 3 | {"shapes": [{"color": "red", "size": 8}, {"color": "yellow", "size": 5}]} 4 | {"shapes": [{"color": "cyan", "size": 3}, {"color": "white", "size": 1}]} 5 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/C/tests/data/paths.json: -------------------------------------------------------------------------------- 1 | {"paths":[{"city":"San Francisco"},{"city":"Palo Alto"},{"city":"San Jose"}]} 2 | {"paths":[{"city":"Mountain View"},{"city":"Palo Alto"},{"city":"Belmont"}]} 3 | {"paths":[{"city":"San Francisco"},{"city":"Redwood City"},{"city":"San Mateo"}]} 4 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/Couchbase.Lite.Tests.Shared.shproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {11F38891-8397-49B4-9146-6DAF0A9D7866} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/Util/ForIssueAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ForIssueAttribute.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | #nullable disable 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Text; 24 | 25 | namespace Couchbase.Lite 26 | { 27 | [AttributeUsage(AttributeTargets.Method)] 28 | public sealed class ForIssueAttribute : Attribute 29 | { 30 | public string Issue { get; } 31 | 32 | public ForIssueAttribute(string issue) 33 | { 34 | Issue = issue; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/Util/IMockConnectionErrorLogic.cs: -------------------------------------------------------------------------------- 1 | // 2 | // IMockConnectionErrorLogic.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | #nullable disable 20 | 21 | #if COUCHBASE_ENTERPRISE 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Text; 25 | 26 | using Couchbase.Lite.P2P; 27 | 28 | namespace Couchbase.Lite 29 | { 30 | [Flags] 31 | public enum MockConnectionLifecycleLocation 32 | { 33 | Connect = 1 << 0, 34 | Send = 1 << 1, 35 | Receive = 1 << 2, 36 | Close = 1 << 3 37 | } 38 | 39 | public interface IMockConnectionErrorLogic 40 | { 41 | bool ShouldClose(MockConnectionLifecycleLocation location); 42 | 43 | MessagingException CreateException(); 44 | } 45 | } 46 | #endif -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/Util/ImplementsTestSpecAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ImplementsTestSpecAttribute.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | #nullable disable 20 | 21 | using System; 22 | 23 | namespace Couchbase.Lite 24 | { 25 | [AttributeUsage(AttributeTargets.Class)] 26 | public sealed class ImplementsTestSpecAttribute : Attribute 27 | { 28 | public string TestSpec { get; } 29 | 30 | public string Version { get; } 31 | 32 | public Version GetVersion() => new Version(Version); 33 | 34 | public ImplementsTestSpecAttribute(string testSpec, string version) 35 | { 36 | TestSpec = testSpec; 37 | Version = version; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/Util/XunitLogger.cs: -------------------------------------------------------------------------------- 1 | // 2 | // XunitLogger.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | #nullable disable 19 | 20 | using System; 21 | 22 | using Couchbase.Lite.Logging; 23 | 24 | using Xunit.Abstractions; 25 | 26 | namespace Test.Util 27 | { 28 | internal sealed class XunitLogger : ILogger 29 | { 30 | #region Variables 31 | 32 | private readonly ITestOutputHelper _output; 33 | 34 | #endregion 35 | 36 | #region Properties 37 | 38 | public LogLevel Level { get; set; } = LogLevel.Warning; 39 | 40 | #endregion 41 | 42 | #region Constructors 43 | 44 | public XunitLogger(ITestOutputHelper output) 45 | { 46 | _output = output; 47 | } 48 | 49 | #endregion 50 | 51 | #region ILogger 52 | 53 | public void Log(LogLevel level, LogDomain domain, string message) 54 | { 55 | if (level < Level) { 56 | return; 57 | } 58 | 59 | try { 60 | _output.WriteLine($"{level.ToString().ToUpperInvariant()}) {domain} {message}"); 61 | } catch (Exception) { 62 | // _output is busted, the test is probably already finished. Nothing we can do 63 | } 64 | } 65 | 66 | #endregion 67 | } 68 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/replacedb/android140-sqlite-noattachment.cblite2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/replacedb/android140-sqlite-noattachment.cblite2.zip -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/replacedb/android140-sqlite.cblite2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/replacedb/android140-sqlite.cblite2.zip -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/replacedb/android200-sqlite.cblite2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/couchbase-lite-net/b0ab43f00f27b520e8d6e627f56772d8e8898653/src/Couchbase.Lite.Tests.Shared/replacedb/android200-sqlite.cblite2.zip -------------------------------------------------------------------------------- /src/Couchbase.Lite.Tests.Shared/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", 3 | "diagnosticMessages": true, 4 | "longRunningTestSeconds": 10 5 | } -------------------------------------------------------------------------------- /src/Couchbase.Lite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Couchbase.Lite.Tests.iOS")] 4 | [assembly: InternalsVisibleTo("Couchbase.Lite.Support.Android")] 5 | [assembly: InternalsVisibleTo("Couchbase.Lite.Tests.Android")] 6 | [assembly: InternalsVisibleTo("Couchbase.Lite.Tests.NetCore")] 7 | [assembly: InternalsVisibleTo("Couchbase.Lite.Tests.Maui")] 8 | [assembly: InternalsVisibleTo("Couchbase.Lite.Tests.NetCore.Validation")] -------------------------------------------------------------------------------- /src/LiteCore/parse/config_c4.py: -------------------------------------------------------------------------------- 1 | skip_files = [] 2 | excluded = ["c4log", "c4vlog", "c4error_getMessageC", "c4str", "c4log_getDomain","c4repl_parseURL","c4SliceEqual","c4slice_free"] 3 | force_no_bridge = ["c4repl_getResponseHeaders","c4repl_new","c4socket_gotHTTPResponse", "c4doc_getRevisionHistory"] 4 | default_param_name = {"C4SliceResult":"slice","C4WriteStream*":"stream","C4ReadStream*":"stream","C4Error*":"outError", 5 | "C4BlobStore*":"store","C4BlobKey":"key","C4Slice":"slice","C4Key*":"key","bool":"b","double":"d","C4KeyReader*":"reader", 6 | "C4DatabaseObserver*":"observer","C4DocumentObserver*":"observer","C4View*":"view","C4OnCompactCallback":"callback", 7 | "C4Database*":"db","C4SequenceNumber":"sequence","C4StringResult":"str","C4String":"str","C4Query*":"query","C4CertNameAttributeID":"y", 8 | "C4Socket*":"socket"} 9 | param_bridge_types = ["C4Slice", "FLSlice", "size_t", "size_t*", "C4Slice[]", "C4String", "FLString", "C4String[]"] 10 | return_bridge_types = ["C4SliceResult", "C4Slice", "size_t", "byte*", "C4StringResult", "C4String", "FLSliceResult", "FLStringResult"] 11 | type_map = {"int32_t":"int","uint32_t":"uint","int64_t":"long","uint64_t":"ulong","size_t":"UIntPtr", 12 | "size_t*":"UIntPtr*","C4SequenceNumber":"ulong","C4SequenceNumber*":"ulong*","unsigned":"uint", 13 | "FLSharedKeys":"FLSharedKeys*","char*":"byte*","FLEncoder":"FLEncoder*","C4LogDomain":"C4LogDomain*", 14 | "FLDict":"FLDict*","C4FullTextID":"ulong","C4RemoteID":"uint","C4String*":"FLSlice*","FLDoc":"FLDoc*", 15 | "C4Timestamp": "long", "C4Timestamp*": "long*","FLMutableArray":"FLMutableArray*", "uint16_t":"ushort", 16 | "unsigned*":"uint*","C4CertNameAttributeID":"FLSlice", "float[]": "float*", "FLValue": "FLValue*"} 17 | reserved = ["string","params","ref"] 18 | -------------------------------------------------------------------------------- /src/LiteCore/parse/config_fleece.py: -------------------------------------------------------------------------------- 1 | skip_files = ["Fleece+CoreFoundation.h"] 2 | excluded = ["FLStr","operatorslice","operatorFLSlice","FLMutableArray_Retain","FLMutableArray_Release","FLMutableDict_Retain","FLMutableDict_Release","FLEncoder_NewWritingToFile","FLSliceResult_Free"] 3 | default_param_name = {"FLValue":"value","FLSliceResult":"slice","FLSlice":"slice","FLArray":"array","FLArrayIterator*":"i","FLDictIterator*":"i","FLDict":"dict","FLDictKey":"key","FLKeyPath":"keyPath","FLDictKey*":"dictKey","FLSharedKeys":"shared","FLEncoder":"encoder","long":"l","ulong":"u","bool":"b","float":"f","double":"d","FLError*":"outError","int64_t":"l","uint64_t":"u","FLString":"str","FLStringResult":"str"} 4 | param_bridge_types = ["FLSlice", "FLString", "size_t", "size_t*"] 5 | force_no_bridge = ["FLSlice_Compare", "FLSlice_Equal","FLSliceResult_Retain","FLSliceResult_Release","FLSlice_Copy","FLDoc_FromResultData"] 6 | return_bridge_types = ["FLSliceResult", "FLSlice", "size_t", "FLString", "FLStringResult"] 7 | type_map = {"int32_t":"int","uint32_t":"uint","int64_t":"long","uint64_t":"ulong","size_t":"UIntPtr","size_t*":"UIntPtr*", 8 | "unsigned":"uint","FLValue":"FLValue*","FLDict":"FLDict*","FLArray":"FLArray*","FLEncoder":"FLEncoder*", 9 | "FLSharedKeys":"FLSharedKeys*","FLKeyPath":"FLKeyPath*","FLDoc":"FLDoc*","FLDeepIterator":"FLDeepIterator*", 10 | "FLTimestamp":"long","FLSlot":"FLSlot*","FLMutableArray":"FLMutableArray*","FLMutableDict":"FLMutableDict*"} 11 | literals = {"FLSlice_Compare":".nobridge .int FLSlice_Compare FLSlice:left FLSlice:right"} 12 | reserved = ["string","base"] 13 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4ExternalKeyCallbacks.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4ExternalKeyCallbacks 2 | { 3 | public IntPtr publicKeyData; 4 | public IntPtr decrypt; 5 | public IntPtr sign; 6 | public IntPtr free; 7 | } -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4ExtraInfo_literal.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4ExtraInfo 2 | { 3 | public void* pointer; 4 | private IntPtr _destructor; 5 | 6 | public C4ExtraInfoDestructor? destructor 7 | { 8 | get => Marshal.GetDelegateForFunctionPointer(_destructor); 9 | set => _destructor = value != null ? Marshal.GetFunctionPointerForDelegate(value) : IntPtr.Zero; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4ListenerConfig.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4ListenerConfig 2 | { 3 | public ushort port; 4 | public FLSlice networkInterface; 5 | public C4ListenerAPIs apis; 6 | public C4TLSConfig* tlsConfig; 7 | public IntPtr httpAuthCallback; 8 | public void* callbackContext; 9 | public FLSlice directory; 10 | private byte _allowCreateDBs; 11 | private byte _allowDeleteDBs; 12 | private byte _allowCreateCollections; 13 | private byte _allowDeleteCollections; 14 | private byte _allowPush; 15 | private byte _allowPull; 16 | private byte _enableDeltaSync; 17 | 18 | public bool allowCreateDBs 19 | { 20 | get { 21 | return Convert.ToBoolean(_allowCreateDBs); 22 | } 23 | set { 24 | _allowCreateDBs = Convert.ToByte(value); 25 | } 26 | } 27 | 28 | public bool allowDeleteDBs 29 | { 30 | get { 31 | return Convert.ToBoolean(_allowDeleteDBs); 32 | } 33 | set { 34 | _allowDeleteDBs = Convert.ToByte(value); 35 | } 36 | } 37 | 38 | public bool allowPush 39 | { 40 | get { 41 | return Convert.ToBoolean(_allowPush); 42 | } 43 | set { 44 | _allowPush = Convert.ToByte(value); 45 | } 46 | } 47 | 48 | public bool allowPull 49 | { 50 | get { 51 | return Convert.ToBoolean(_allowPull); 52 | } 53 | set { 54 | _allowPull = Convert.ToByte(value); 55 | } 56 | } 57 | 58 | public bool enableDeltaSync 59 | { 60 | get { 61 | return Convert.ToBoolean(_enableDeltaSync); 62 | } 63 | set { 64 | _enableDeltaSync = Convert.ToByte(value); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4PredictiveModel.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4PredictiveModel 2 | { 3 | public void* context; 4 | public IntPtr prediction; 5 | public IntPtr unregistered; 6 | } 7 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4ReplicationCollection.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4ReplicationCollection 2 | { 3 | public C4CollectionSpec collection; 4 | public C4ReplicatorMode push; 5 | public C4ReplicatorMode pull; 6 | public FLSlice optionsDictFleece; 7 | public IntPtr pushFilter; 8 | public IntPtr pullFilter; 9 | public void* callbackContext; 10 | } -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4ReplicatorParameters.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4ReplicatorParameters 2 | { 3 | public FLSlice optionsDictFleece; 4 | public IntPtr onStatusChanged; 5 | public IntPtr onDocumentEnded; 6 | public IntPtr onBlobProgress; 7 | public IntPtr propertyEncryptor; 8 | public IntPtr propertyDecryptor; 9 | public void* callbackContext; 10 | public C4SocketFactory* socketFactory; 11 | public C4ReplicationCollection* collections; 12 | public IntPtr collectionCount; 13 | } 14 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4SocketFactory.cs: -------------------------------------------------------------------------------- 1 | internal unsafe partial struct C4SocketFactory 2 | { 3 | public C4SocketFraming framing; 4 | public void* context; 5 | public IntPtr open; 6 | public IntPtr write; 7 | public IntPtr completedReceive; 8 | public IntPtr close; 9 | public IntPtr requestClose; 10 | public IntPtr dispose; 11 | } 12 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/C4TLSConfig.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct C4TLSConfig 2 | { 3 | public C4PrivateKeyRepresentation privateKeyRepresentation; 4 | public C4KeyPair* key; 5 | public C4Cert* certificate; 6 | private byte _requireClientCerts; 7 | public C4Cert* rootClientCerts; 8 | public IntPtr certAuthCallback; 9 | public void* tlsCallbackContext; 10 | 11 | public bool requireClientCerts 12 | { 13 | get { 14 | return Convert.ToBoolean(_requireClientCerts); 15 | } 16 | set { 17 | _requireClientCerts = Convert.ToByte(value); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/UIntPtr.cs: -------------------------------------------------------------------------------- 1 | public ulong {0} 2 | {{ 3 | get {{ 4 | return _{0}.ToUInt64(); 5 | }} 6 | set {{ 7 | _{0} = (UIntPtr)value; 8 | }} 9 | }} -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/bool.cs: -------------------------------------------------------------------------------- 1 | public bool {0} 2 | {{ 3 | get {{ 4 | return Convert.ToBoolean(_{0}); 5 | }} 6 | set {{ 7 | _{0} = Convert.ToByte(value); 8 | }} 9 | }} -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/delegate.cs: -------------------------------------------------------------------------------- 1 | public {0}? {1} 2 | {{ 3 | get {{ 4 | return Marshal.GetDelegateForFunctionPointer<{0}>(_{1}); 5 | }} 6 | set {{ 7 | _{1} = value != null ? Marshal.GetFunctionPointerForDelegate(value) : IntPtr.Zero; 8 | }} 9 | }} -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/header.cs: -------------------------------------------------------------------------------- 1 | // 2 | // %(filename)s 3 | // 4 | // Copyright (c) %(year)d Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | 32 | using System; 33 | using System.Linq; 34 | using System.Runtime.InteropServices; 35 | using System.Threading; 36 | 37 | using LiteCore.Util; 38 | 39 | namespace LiteCore.Interop 40 | { 41 | %(structs)s 42 | } 43 | 44 | #pragma warning restore IDE0051 // Remove unused private members 45 | #pragma warning restore IDE0044 // Add readonly modifier 46 | #pragma warning restore CS0649 // Member never assigned to 47 | #pragma warning restore CS0169 // Member never used 48 | -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_c4/string.cs: -------------------------------------------------------------------------------- 1 | public string? {0} 2 | {{ 3 | get {{ 4 | return Marshal.PtrToStringAnsi(_{0}); 5 | }} 6 | set {{ 7 | var old = Interlocked.Exchange(ref _{0}, Marshal.StringToHGlobalAnsi(value)); 8 | Marshal.FreeHGlobal(old); 9 | }} 10 | }} -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_fleece/FLArrayIterator_literal.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct FLArrayIterator 2 | { 3 | #pragma warning disable CS0169 4 | 5 | private void* _private1; 6 | private uint _private2; 7 | private byte _private3; 8 | private void* _private4; 9 | 10 | #pragma warning restore CS0169 11 | } -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_fleece/FLDictIterator_literal.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct FLDictIterator 2 | { 3 | #pragma warning disable CS0169 4 | 5 | private void* _private1; 6 | private uint _private2; 7 | private byte _private3; 8 | 9 | // _private4[4] 10 | private void* _private4a; 11 | private void* _private4b; 12 | private void* _private4c; 13 | private void* _private4d; 14 | private int _private5; 15 | 16 | #pragma warning restore CS0169 17 | } -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_fleece/FLDictKey_literal.cs: -------------------------------------------------------------------------------- 1 | internal unsafe struct FLDictKey 2 | { 3 | #pragma warning disable CS0169 4 | 5 | private FLSlice _private1; 6 | private void* _private2; 7 | private uint _private3; 8 | private uint _private4; 9 | private byte _private5; 10 | 11 | #pragma warning restore CS0169 12 | } -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_fleece/UIntPtr.cs: -------------------------------------------------------------------------------- 1 | public ulong {0} 2 | {{ 3 | get {{ 4 | return _{0}.ToUInt64(); 5 | }} 6 | set {{ 7 | _{0} = (UIntPtr)value; 8 | }} 9 | }} -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_fleece/bool.cs: -------------------------------------------------------------------------------- 1 | public bool {0} 2 | {{ 3 | get {{ 4 | return Convert.ToBoolean(_{0}); 5 | }} 6 | set {{ 7 | _{0} = Convert.ToByte(value); 8 | }} 9 | }} -------------------------------------------------------------------------------- /src/LiteCore/parse/templates_fleece/header.cs: -------------------------------------------------------------------------------- 1 | // 2 | // %(filename)s 3 | // 4 | // Copyright (c) %(year)d Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | %(structs)s 41 | } 42 | 43 | #pragma warning restore IDE0051 // Remove unused private members 44 | #pragma warning restore IDE0044 // Add readonly modifier 45 | #pragma warning restore CS0649 // Member never assigned to 46 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Constants.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.cs 3 | // 4 | // Copyright (c) 2016 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | namespace LiteCore 20 | { 21 | [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 22 | internal static class Constants 23 | { 24 | internal const string DllName = "LiteCore"; 25 | 26 | internal static readonly string ObjectTypeProperty = "@type"; 27 | 28 | internal static readonly string ObjectTypeBlob = "blob"; 29 | 30 | internal static readonly string? C4LanguageDefault = null; 31 | 32 | internal static readonly string C4LanguageNone = ""; 33 | 34 | internal static readonly string C4PlaceholderValue = "*"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4BlobStore.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4BlobStore.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Diagnostics.CodeAnalysis; 20 | 21 | namespace LiteCore.Interop 22 | { 23 | internal static unsafe partial class Native 24 | { 25 | public static ulong c4stream_read(C4ReadStream *stream, byte[] buffer, C4Error *outError) 26 | { 27 | return c4stream_read(stream, buffer, buffer.Length, outError); 28 | } 29 | 30 | public static bool c4stream_write(C4WriteStream* stream, byte[] bytes, C4Error* outError) 31 | { 32 | return c4stream_write(stream, bytes, (ulong)bytes.Length, outError); 33 | } 34 | } 35 | 36 | internal partial struct C4BlobKey 37 | { 38 | public const int Size = 20; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4BlobStoreTypes_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4BlobStoreTypes_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | 32 | using System; 33 | using System.Linq; 34 | using System.Runtime.InteropServices; 35 | using System.Threading; 36 | 37 | using LiteCore.Util; 38 | 39 | namespace LiteCore.Interop 40 | { 41 | 42 | 43 | internal unsafe partial struct C4BlobKey 44 | { 45 | public fixed byte bytes[20]; 46 | } 47 | } 48 | 49 | #pragma warning restore IDE0051 // Remove unused private members 50 | #pragma warning restore IDE0044 // Add readonly modifier 51 | #pragma warning restore CS0649 // Member never assigned to 52 | #pragma warning restore CS0169 // Member never used 53 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4DocEnumerator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4DocEnumerator.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Diagnostics.CodeAnalysis; 20 | 21 | namespace LiteCore.Interop 22 | { 23 | 24 | [ExcludeFromCodeCoverage] 25 | internal partial struct C4EnumeratorOptions 26 | { 27 | public static readonly C4EnumeratorOptions Default = new C4EnumeratorOptions { 28 | flags = C4EnumeratorFlags.IncludeNonConflicted | C4EnumeratorFlags.IncludeBodies 29 | }; 30 | } 31 | 32 | internal partial struct C4DocumentInfo 33 | { 34 | public const long TimestampError = -1; 35 | public const long TimestampNone = 0; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4Observer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4Observer.cs 3 | // 4 | // Copyright (c) 2016 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Runtime.InteropServices; 20 | 21 | namespace LiteCore.Interop 22 | { 23 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 24 | internal unsafe delegate void C4CollectionObserverCallback(C4CollectionObserver* observer, void* context); 25 | 26 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 27 | internal unsafe delegate void C4DocumentObserverCallback(C4DocumentObserver* observer, C4Collection* collection, FLSlice docID, ulong sequence, void* context); 28 | 29 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 30 | internal unsafe delegate void C4QueryObserverCallback(C4QueryObserver* observer, C4Query* query, void* context); 31 | } -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4PredictiveQuery_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4PredictiveQuery_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | 32 | using System; 33 | using System.Linq; 34 | using System.Runtime.InteropServices; 35 | using System.Threading; 36 | 37 | using LiteCore.Util; 38 | 39 | namespace LiteCore.Interop 40 | { 41 | 42 | 43 | internal unsafe struct C4PredictiveModel 44 | { 45 | public void* context; 46 | public IntPtr prediction; 47 | public IntPtr unregistered; 48 | } 49 | 50 | } 51 | 52 | #pragma warning restore IDE0051 // Remove unused private members 53 | #pragma warning restore IDE0044 // Add readonly modifier 54 | #pragma warning restore CS0649 // Member never assigned to 55 | #pragma warning restore CS0169 // Member never used 56 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4PredictiveQuery_native.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4PredictiveQuery_native.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | 27 | using System; 28 | using System.Linq; 29 | using System.Runtime.InteropServices; 30 | 31 | using LiteCore.Util; 32 | 33 | namespace LiteCore.Interop 34 | { 35 | 36 | internal unsafe static partial class Native 37 | { 38 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 39 | public static extern void c4pred_registerModel([MarshalAs(UnmanagedType.LPStr)]string name, C4PredictiveModel x); 40 | 41 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 42 | [return: MarshalAs(UnmanagedType.U1)] 43 | public static extern bool c4pred_unregisterModel([MarshalAs(UnmanagedType.LPStr)]string name); 44 | 45 | 46 | } 47 | 48 | internal unsafe static partial class NativeRaw 49 | { 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/C4Private.cs: -------------------------------------------------------------------------------- 1 | // 2 | // C4Private.cs 3 | // 4 | // Copyright (c) 2016 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Runtime.InteropServices; 20 | 21 | namespace LiteCore.Interop 22 | { 23 | internal static class NativePrivate 24 | { 25 | #region Public Methods 26 | 27 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 28 | public static extern void c4log_warnOnErrors(bool warn); 29 | 30 | #endregion 31 | } 32 | } -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLDeepIterator_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLDeepIterator_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | 41 | 42 | internal unsafe struct FLDeepIterator 43 | { 44 | } 45 | 46 | internal unsafe struct FLPathComponent 47 | { 48 | public FLSlice key; 49 | public uint index; 50 | } 51 | } 52 | 53 | #pragma warning restore IDE0051 // Remove unused private members 54 | #pragma warning restore IDE0044 // Add readonly modifier 55 | #pragma warning restore CS0649 // Member never assigned to 56 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLDoc_native.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLDoc_native.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | 27 | using System; 28 | using System.Linq; 29 | using System.Runtime.InteropServices; 30 | 31 | using LiteCore.Util; 32 | 33 | namespace LiteCore.Interop 34 | { 35 | 36 | internal unsafe static partial class Native 37 | { 38 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 39 | public static extern FLDoc* FLDoc_FromResultData(FLSliceResult data, FLTrust x, FLSharedKeys* shared, FLSlice externData); 40 | 41 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 42 | public static extern void FLDoc_Release(FLDoc* x); 43 | 44 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 45 | public static extern FLValue* FLDoc_GetRoot(FLDoc* x); 46 | 47 | 48 | } 49 | 50 | internal unsafe static partial class NativeRaw 51 | { 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLEncoder_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLEncoder_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | internal enum FLEncoderFormat 41 | { 42 | EncodeFleece, 43 | EncodeJSON, 44 | EncodeJSON5 45 | } 46 | } 47 | 48 | #pragma warning restore IDE0051 // Remove unused private members 49 | #pragma warning restore IDE0044 // Add readonly modifier 50 | #pragma warning restore CS0649 // Member never assigned to 51 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLExpert_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLExpert_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | 41 | 42 | internal unsafe struct FLSharedKeyScope 43 | { 44 | } 45 | } 46 | 47 | #pragma warning restore IDE0051 // Remove unused private members 48 | #pragma warning restore IDE0044 // Add readonly modifier 49 | #pragma warning restore CS0649 // Member never assigned to 50 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLExpert_native.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLExpert_native.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | 27 | using System; 28 | using System.Linq; 29 | using System.Runtime.InteropServices; 30 | 31 | using LiteCore.Util; 32 | 33 | namespace LiteCore.Interop 34 | { 35 | 36 | internal unsafe static partial class Native 37 | { 38 | public static FLValue* FLValue_FromData(byte[]? data, FLTrust trust) 39 | { 40 | fixed(byte *data_ = data) { 41 | return NativeRaw.FLValue_FromData(new FLSlice(data_, data == null ? 0 : (ulong)data.Length), trust); 42 | } 43 | } 44 | 45 | 46 | } 47 | 48 | internal unsafe static partial class NativeRaw 49 | { 50 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 51 | public static extern FLValue* FLValue_FromData(FLSlice data, FLTrust trust); 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLJSON_native.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLJSON_native.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | 27 | using System; 28 | using System.Linq; 29 | using System.Runtime.InteropServices; 30 | 31 | using LiteCore.Util; 32 | 33 | namespace LiteCore.Interop 34 | { 35 | 36 | internal unsafe static partial class Native 37 | { 38 | public static string? FLValue_ToJSON(FLValue* value) 39 | { 40 | using(var retVal = NativeRaw.FLValue_ToJSON(value)) { 41 | return ((FLSlice)retVal).CreateString(); 42 | } 43 | } 44 | 45 | 46 | } 47 | 48 | internal unsafe static partial class NativeRaw 49 | { 50 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 51 | public static extern FLSliceResult FLValue_ToJSON(FLValue* value); 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLKeyPath_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLKeyPath_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | 41 | 42 | internal unsafe struct FLKeyPath 43 | { 44 | } 45 | } 46 | 47 | #pragma warning restore IDE0051 // Remove unused private members 48 | #pragma warning restore IDE0044 // Add readonly modifier 49 | #pragma warning restore CS0649 // Member never assigned to 50 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLMutable_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLMutable_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | internal enum FLCopyFlags 41 | { 42 | DefaultCopy = 0, 43 | DeepCopy = 1, 44 | CopyImmutables = 2, 45 | DeepCopyImmutables = (DeepCopy | CopyImmutables), 46 | } 47 | } 48 | 49 | #pragma warning restore IDE0051 // Remove unused private members 50 | #pragma warning restore IDE0044 // Add readonly modifier 51 | #pragma warning restore CS0649 // Member never assigned to 52 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLSlice_native.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLSlice_native.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | 27 | using System; 28 | using System.Linq; 29 | using System.Runtime.InteropServices; 30 | 31 | using LiteCore.Util; 32 | 33 | namespace LiteCore.Interop 34 | { 35 | 36 | internal unsafe static partial class Native 37 | { 38 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 39 | public static extern int FLSlice_Compare(FLSlice left, FLSlice right); 40 | 41 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 42 | public static extern FLSliceResult FLSlice_Copy(FLSlice slice); 43 | 44 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] 45 | public static extern void _FLBuf_Release(void* x); 46 | 47 | 48 | } 49 | 50 | internal unsafe static partial class NativeRaw 51 | { 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/FLValue_defs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // FLValue_defs.cs 3 | // 4 | // Copyright (c) 2024 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | // -------------------------------------------------- 20 | // 21 | // This file was generated by generate_bindings.ps1 22 | // 23 | // -------------------------------------------------- 24 | 25 | #nullable enable 26 | #pragma warning disable IDE0051 // Remove unused private members 27 | #pragma warning disable IDE0044 // Add readonly modifier 28 | #pragma warning disable CS0649 // Member never assigned to 29 | #pragma warning disable CS0169 // Member never used 30 | 31 | using System; 32 | using System.Linq; 33 | using System.Runtime.InteropServices; 34 | using System.Threading; 35 | 36 | using LiteCore.Util; 37 | 38 | namespace LiteCore.Interop 39 | { 40 | internal enum FLValueType 41 | { 42 | Undefined = -1, 43 | Null = 0, 44 | Boolean, 45 | Number, 46 | String, 47 | Data, 48 | Array, 49 | Dict 50 | } 51 | } 52 | 53 | #pragma warning restore IDE0051 // Remove unused private members 54 | #pragma warning restore IDE0044 // Add readonly modifier 55 | #pragma warning restore CS0649 // Member never assigned to 56 | #pragma warning restore CS0169 // Member never used -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/Misc_native.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Misc_native.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Runtime.InteropServices; 21 | 22 | namespace LiteCore.Interop 23 | { 24 | [ExcludeFromCodeCoverage] 25 | internal unsafe static partial class Native 26 | { 27 | [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] 28 | public static extern C4LogDomain* c4log_getDomain(string name, 29 | [MarshalAs(UnmanagedType.U1)] bool create); 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/NativeActivate.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NativeActivate.cs 3 | // 4 | // Copyright (c) 2018 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | using System; 20 | using System.IO; 21 | using System.Reflection; 22 | 23 | using Couchbase.Lite.Support; 24 | 25 | namespace LiteCore.Interop 26 | { 27 | internal partial class Native 28 | { 29 | #region Constructors 30 | 31 | static Native() 32 | { 33 | #if NET6_0_OR_GREATER 34 | if(OperatingSystem.IsIOS()) { 35 | System.Diagnostics.Debug.WriteLine("Setting DllImportResolver"); 36 | System.Runtime.InteropServices.NativeLibrary.SetDllImportResolver(typeof(Native).Assembly, (libraryName, assembly, searchPath) => 37 | { 38 | System.Diagnostics.Debug.WriteLine($"DllImportResolver called for {libraryName}"); 39 | if (libraryName == Constants.DllName) { 40 | libraryName = "@rpath/LiteCore.framework/LiteCore"; 41 | } 42 | 43 | return System.Runtime.InteropServices.NativeLibrary.Load(libraryName); 44 | }); 45 | } 46 | #endif 47 | 48 | #if NEEDS_LITECORE_LOAD 49 | NetDesktop.LoadLiteCore(); 50 | #endif 51 | } 52 | 53 | #endregion 54 | } 55 | } -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/bridge_literals.txt: -------------------------------------------------------------------------------- 1 | c4stream_read 2 | public static ulong c4stream_read(C4ReadStream *stream, byte[] buffer, int count, C4Error *outError) 3 | { 4 | return NativeRaw.c4stream_read(stream, buffer, (UIntPtr)count, outError).ToUInt64(); 5 | } 6 | 7 | 8 | c4stream_write 9 | public static bool c4stream_write(C4WriteStream* stream, byte[] bytes, ulong length, C4Error* outError) 10 | { 11 | return NativeRaw.c4stream_write(stream, bytes, (UIntPtr)length, outError); 12 | } 13 | 14 | 15 | c4doc_put 16 | public static C4Document* c4doc_put(C4Database *database, C4DocPutRequest *request, ulong* outCommonAncestorIndex, C4Error *outError) 17 | { 18 | var uintptr = new UIntPtr(); 19 | var retVal = NativeRaw.c4doc_put(database, request, &uintptr, outError); 20 | if(outCommonAncestorIndex != null) { 21 | *outCommonAncestorIndex = uintptr.ToUInt64(); 22 | } 23 | 24 | return retVal; 25 | } 26 | 27 | 28 | FLDictKey_Init 29 | // Note: Allocates unmanaged heap memory; should only be used with constants 30 | public static FLDictKey FLDictKey_Init(string str) 31 | { 32 | return NativeRaw.FLDictKey_Init(FLSlice.Constant(str)); 33 | } 34 | 35 | FLJSON5_ToJSON 36 | public static string? FLJSON5_ToJSON(string json5, FLSlice* outErrorMessage, UIntPtr* outErrPos, FLError* err) 37 | { 38 | using(var json5_ = new C4String(json5)) { 39 | using(var retVal = NativeRaw.FLJSON5_ToJSON((FLSlice)json5_.AsFLSlice(), outErrorMessage, outErrPos, err)) { 40 | return ((FLSlice)retVal).CreateString(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/raw_literals.txt: -------------------------------------------------------------------------------- 1 | c4stream_read 2 | public static extern UIntPtr c4stream_read(C4ReadStream* stream, [Out]byte[] buffer, UIntPtr maxBytesToRead, C4Error* outError); 3 | 4 | c4stream_write 5 | [return:MarshalAs(UnmanagedType.U1)] 6 | public static extern bool c4stream_write(C4WriteStream* stream, byte[] bytes, UIntPtr length, C4Error* outError); 7 | 8 | FLDict_GetWithKeys 9 | public static extern UIntPtr FLDict_GetWithKeys(FLDict* dict, [Out]FLDictKey[] keys, [Out]FLValue[] values, UIntPtr count); 10 | 11 | FLEncoder_GetErrorMessage 12 | [return: MarshalAs(UnmanagedType.LPStr)] 13 | public static extern string FLEncoder_GetErrorMessage(FLEncoder* encoder); 14 | 15 | c4dbobs_getChanges 16 | public static extern C4CollectionObservation c4dbobs_getChanges(C4CollectionObserver* observer, [Out]C4CollectionChange[] outChanges, uint maxChanges); 17 | 18 | c4log_getDomain 19 | public static extern C4LogDomain* c4log_getDomain(byte* name, [MarshalAs(UnmanagedType.U1)]bool create); 20 | 21 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4SliceResult_bridge.template: -------------------------------------------------------------------------------- 1 | byte[]? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4SliceResult_raw_return.template: -------------------------------------------------------------------------------- 1 | FLSliceResult 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4SliceResult_return.template: -------------------------------------------------------------------------------- 1 | {0}using(var retVal = NativeRaw.{1}{2}) {{ 2 | {0} return ((FLSlice)retVal).ToArrayFast(); 3 | {0}}} 4 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4Slice_bridge.template: -------------------------------------------------------------------------------- 1 | byte[]? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4Slice_bridge_param.template: -------------------------------------------------------------------------------- 1 | new FLSlice({0}_, {0} == null ? 0 : (ulong){0}.Length) 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4Slice_raw.template: -------------------------------------------------------------------------------- 1 | FLSlice {0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4Slice_raw_return.template: -------------------------------------------------------------------------------- 1 | FLSlice 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4Slice_return.template: -------------------------------------------------------------------------------- 1 | {0}return (NativeRaw.{1}{2}).ToArrayFast(); 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4Slice_using.template: -------------------------------------------------------------------------------- 1 | fixed(byte *{0}_ = {0}) 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4StringResult_bridge.template: -------------------------------------------------------------------------------- 1 | string? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4StringResult_raw_return.template: -------------------------------------------------------------------------------- 1 | FLSliceResult 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4StringResult_return.template: -------------------------------------------------------------------------------- 1 | {0}using(var retVal = NativeRaw.{1}{2}) {{ 2 | {0} return ((FLSlice)retVal).CreateString(); 3 | {0}}} 4 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String[]_raw.template: -------------------------------------------------------------------------------- 1 | FLSlice[] {0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String_bridge.template: -------------------------------------------------------------------------------- 1 | string? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String_bridge_param.template: -------------------------------------------------------------------------------- 1 | {}_.AsFLSlice() 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String_raw.template: -------------------------------------------------------------------------------- 1 | FLSlice {0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String_raw_return.template: -------------------------------------------------------------------------------- 1 | FLSlice 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String_return.template: -------------------------------------------------------------------------------- 1 | {0}return NativeRaw.{1}{2}.CreateString(); -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/C4String_using.template: -------------------------------------------------------------------------------- 1 | using(var {0}_ = new C4String({0})) 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLSliceResult_bridge.template: -------------------------------------------------------------------------------- 1 | byte[]? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLSliceResult_return.template: -------------------------------------------------------------------------------- 1 | {0}using(var retVal = NativeRaw.{1}{2}) {{ 2 | {0} return ((FLSlice)retVal).ToArrayFast(); 3 | {0}}} 4 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLSlice_bridge.template: -------------------------------------------------------------------------------- 1 | byte[]? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLSlice_bridge_param.template: -------------------------------------------------------------------------------- 1 | new FLSlice({0}_, {0} == null ? 0 : (ulong){0}.Length) 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLSlice_return.template: -------------------------------------------------------------------------------- 1 | {0}return (NativeRaw.{1}{2}).ToArrayFast(); 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLSlice_using.template: -------------------------------------------------------------------------------- 1 | fixed(byte *{0}_ = {0}) 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLStringResult_bridge.template: -------------------------------------------------------------------------------- 1 | string? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLStringResult_ptr_raw.template: -------------------------------------------------------------------------------- 1 | FLSlice* {0} -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLStringResult_raw_return.template: -------------------------------------------------------------------------------- 1 | FLSliceResult 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLStringResult_return.template: -------------------------------------------------------------------------------- 1 | {0}using(var retVal = NativeRaw.{1}{2}) {{ 2 | {0} return ((FLSlice)retVal).CreateString(); 3 | {0}}} 4 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLString_bridge.template: -------------------------------------------------------------------------------- 1 | string? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLString_bridge_param.template: -------------------------------------------------------------------------------- 1 | (FLSlice){}_.AsFLSlice() 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLString_raw.template: -------------------------------------------------------------------------------- 1 | FLSlice {0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLString_raw_return.template: -------------------------------------------------------------------------------- 1 | FLSlice 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLString_return.template: -------------------------------------------------------------------------------- 1 | {0}return NativeRaw.{1}{2}.CreateString(); 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/FLString_using.template: -------------------------------------------------------------------------------- 1 | using(var {0}_ = new C4String({0})) 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/UIntPtr_bridge.template: -------------------------------------------------------------------------------- 1 | ulong 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/UIntPtr_bridge_param.template: -------------------------------------------------------------------------------- 1 | (UIntPtr){0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/UIntPtr_return.template: -------------------------------------------------------------------------------- 1 | {0}return NativeRaw.{1}{2}.ToUInt64(); 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/bool_raw.template: -------------------------------------------------------------------------------- 1 | [MarshalAs(UnmanagedType.U1)]bool {0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/byte_ptr_bridge.template: -------------------------------------------------------------------------------- 1 | string? 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/byte_ptr_raw.template: -------------------------------------------------------------------------------- 1 | [MarshalAs(UnmanagedType.LPStr)]string {0} 2 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Interop/templates/byte_ptr_return.template: -------------------------------------------------------------------------------- 1 | {0}var retVal = NativeRaw.{1}{2}; 2 | {0}return Marshal.PtrToStringAnsi((IntPtr)retVal); 3 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/LiteCore.Shared.shproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | c37dc024-8762-4be4-9034-b2b5970c652c 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/LiteCore/src/LiteCore.Shared/Util/Hasher.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Hasher.cs 3 | // 4 | // Copyright (c) 2017 Couchbase, Inc All rights reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | using System.Collections.Generic; 19 | using System.Diagnostics.CodeAnalysis; 20 | 21 | namespace LiteCore.Util 22 | { 23 | // https://stackoverflow.com/a/18613926/1155387 24 | [ExcludeFromCodeCoverage] 25 | internal struct Hasher 26 | { 27 | private int _hashCode; 28 | 29 | public static readonly Hasher Start = new Hasher(17); 30 | 31 | public Hasher(int hashCode) 32 | { 33 | _hashCode = hashCode; 34 | } 35 | 36 | public Hasher Add(T obj) where T : notnull 37 | { 38 | var h = EqualityComparer.Default.GetHashCode(obj); 39 | _hashCode = _hashCode * 31 + h; 40 | return this; 41 | } 42 | 43 | public static implicit operator int(Hasher hasher) => hasher.GetHashCode(); 44 | 45 | public override int GetHashCode() => _hashCode; 46 | 47 | public override bool Equals(object? obj) 48 | { 49 | if (obj is Hasher other) { 50 | return _hashCode == other._hashCode; 51 | } 52 | 53 | return false; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/build/do_build.ps1: -------------------------------------------------------------------------------- 1 | Push-Location $PSScriptRoot\..\Couchbase.Lite 2 | if(-Not $env:NUGET_VERSION) { 3 | Pop-Location 4 | throw "NUGET_VERSION not defined, aborting..." 5 | } 6 | 7 | $VSInstall = (& 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -requires Microsoft.NetCore.Component.SDK -requires Microsoft.NetCore.Component.Runtime.8.0 -property resolvedInstallationPath) 8 | if(-Not $VSInstall) { 9 | Pop-Location 10 | throw "Unable to locate VS installation" 11 | } 12 | 13 | $MSBuild = "$VSInstall\MSBuild\Current\Bin\MSBuild.exe" 14 | 15 | Write-Host 16 | Write-Host *** RESTORING PACKAGES *** 17 | Write-Host 18 | dotnet restore 19 | Push-Location .. 20 | & $MSBuild /t:Restore Couchbase.Lite.sln 21 | 22 | Write-Host *** BUILDING *** 23 | Write-Host 24 | 25 | & $MSBuild Couchbase.Lite.sln /p:Configuration=Packaging /p:Version=$env:NUGET_VERSION 26 | 27 | Pop-Location 28 | Pop-Location 29 | -------------------------------------------------------------------------------- /src/build/get_litecore_source.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from configparser import ConfigParser 5 | from pathlib import Path 6 | from git import Repo, RemoteProgress 7 | import os 8 | 9 | class CloneProgress(RemoteProgress): 10 | def update(self, op_code, cur_count, max_count = 100.0, message = ""): 11 | op_string = "" 12 | if op_code & RemoteProgress.CHECKING_OUT: 13 | op_string = "CHECKING_OUT" 14 | elif op_code & RemoteProgress.COMPRESSING: 15 | op_string = "COMPRESSING" 16 | elif op_code & RemoteProgress.RECEIVING: 17 | op_string = "RECEIVING" 18 | elif op_code & RemoteProgress.RESOLVING: 19 | op_string = "RESOLVING" 20 | else: 21 | op_string = str(op_code) 22 | 23 | print(f"\033[K{op_string}: {cur_count} of {max_count} completed...", end="\r") 24 | 25 | class SubmoduleProgress(RemoteProgress): 26 | def update(self, op_code, cur_count, max_count = 100.0, message = ""): 27 | # TODO: Why do these still print on multiple lines? 28 | # Something about the message itself 29 | print("\033[K" + message, end="\r") 30 | 31 | def checkout_litecore(): 32 | script_path = Path(__file__).parent 33 | ini_path = script_path / ".." / ".." / "core_version.ini" 34 | parser = ConfigParser() 35 | parser.read(ini_path) 36 | git_revision = parser["hashes"]["ce"] 37 | os.chdir(script_path / ".." / ".." / "vendor") 38 | if not Path("couchbase-lite-core").is_dir(): 39 | Repo.clone_from("https://github.com/couchbase/couchbase-lite-core", "couchbase-lite-core", progress=CloneProgress()) 40 | 41 | repo = Repo("couchbase-lite-core") 42 | repo.head.set_commit(git_revision) 43 | repo.submodule_update(recursive=True, init=True, progress=SubmoduleProgress()) 44 | print(f"Checked out couchbase-lite-core @ {git_revision}") 45 | 46 | if __name__ == "__main__": 47 | checkout_litecore() -------------------------------------------------------------------------------- /src/build/get_litecore_source_requirements.txt: -------------------------------------------------------------------------------- 1 | GitPython -------------------------------------------------------------------------------- /src/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "9.0.0", 4 | "rollForward": "latestMinor" 5 | } 6 | } --------------------------------------------------------------------------------