1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "sqlite_config.h" 17 #include "sqlite_global_config.h" 18 19 namespace OHOS { 20 namespace NativeRdb { SqliteConfig(const RdbStoreConfig & config)21SqliteConfig::SqliteConfig(const RdbStoreConfig &config) 22 { 23 path = config.GetPath(); 24 storageMode = config.GetStorageMode(); 25 readOnly = config.IsReadOnly(); 26 journalMode = config.GetJournalMode(); 27 databaseFileType = config.GetDatabaseFileType(); 28 syncMode = config.GetSyncMode(); 29 if (journalMode.empty()) { 30 journalMode = SqliteGlobalConfig::GetDefaultJournalMode(); 31 } 32 #if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) 33 isEncrypt = config.IsEncrypt(); 34 isCreateNecessary = config.IsCreateNecessary(); 35 bundleName = config.GetBundleName(); 36 #endif 37 } 38 39 SqliteConfig::~SqliteConfig() = default; 40 GetPath() const41std::string SqliteConfig::GetPath() const 42 { 43 return path; 44 } 45 SetPath(std::string newPath)46void SqliteConfig::SetPath(std::string newPath) 47 { 48 this->path = newPath; 49 } 50 51 GetStorageMode() const52StorageMode SqliteConfig::GetStorageMode() const 53 { 54 return storageMode; 55 } 56 GetJournalMode() const57std::string SqliteConfig::GetJournalMode() const 58 { 59 return journalMode; 60 } 61 GetSyncMode() const62std::string SqliteConfig::GetSyncMode() const 63 { 64 return syncMode; 65 } 66 IsReadOnly() const67bool SqliteConfig::IsReadOnly() const 68 { 69 return readOnly; 70 } 71 GetDatabaseFileType() const72std::string SqliteConfig::GetDatabaseFileType() const 73 { 74 return databaseFileType; 75 } 76 77 #if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) IsEncrypt() const78bool SqliteConfig::IsEncrypt() const 79 { 80 return isEncrypt; 81 } 82 GetBundleName() const83std::string SqliteConfig::GetBundleName() const 84 { 85 return bundleName; 86 } IsCreateNecessary() const87bool SqliteConfig::IsCreateNecessary() const 88 { 89 return isCreateNecessary; 90 } 91 SetCreateNecessary(bool CreateNecessary)92void SqliteConfig::SetCreateNecessary(bool CreateNecessary) 93 { 94 this->isCreateNecessary = CreateNecessary; 95 } 96 97 #endif 98 } // namespace NativeRdb 99 } // namespace OHOS