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 #endif 36 } 37 38 SqliteConfig::~SqliteConfig() = default; 39 GetPath() const40std::string SqliteConfig::GetPath() const 41 { 42 return path; 43 } 44 SetPath(std::string newPath)45void SqliteConfig::SetPath(std::string newPath) 46 { 47 this->path = newPath; 48 } 49 50 GetStorageMode() const51StorageMode SqliteConfig::GetStorageMode() const 52 { 53 return storageMode; 54 } 55 GetJournalMode() const56std::string SqliteConfig::GetJournalMode() const 57 { 58 return journalMode; 59 } 60 GetSyncMode() const61std::string SqliteConfig::GetSyncMode() const 62 { 63 return syncMode; 64 } 65 IsReadOnly() const66bool SqliteConfig::IsReadOnly() const 67 { 68 return readOnly; 69 } 70 GetDatabaseFileType() const71std::string SqliteConfig::GetDatabaseFileType() const 72 { 73 return databaseFileType; 74 } 75 76 #if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) IsEncrypt() const77bool SqliteConfig::IsEncrypt() const 78 { 79 return isEncrypt; 80 } 81 GetBundleName() const82std::string SqliteConfig::GetBundleName() const 83 { 84 return bundleName; 85 } IsCreateNecessary() const86bool SqliteConfig::IsCreateNecessary() const 87 { 88 return isCreateNecessary; 89 } 90 SetCreateNecessary(bool CreateNecessary)91void SqliteConfig::SetCreateNecessary(bool CreateNecessary) 92 { 93 this->isCreateNecessary = CreateNecessary; 94 } 95 96 #endif 97 } // namespace NativeRdb 98 } // namespace OHOS