• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef NATIVE_RDB_SQLITE_UTILS_H
17 #define NATIVE_RDB_SQLITE_UTILS_H
18 
19 #include <map>
20 #include <string>
21 
22 namespace OHOS {
23 namespace NativeRdb {
24 
25 class SqliteUtils {
26 public:
27     static const int STATEMENT_SELECT;
28     static const int STATEMENT_UPDATE;
29     static const int STATEMENT_ATTACH;
30     static const int STATEMENT_DETACH;
31     static const int STATEMENT_BEGIN;
32     static const int STATEMENT_COMMIT;
33     static const int STATEMENT_ROLLBACK;
34     static const int STATEMENT_PRAGMA;
35     static const int STATEMENT_DDL;
36     static const int STATEMENT_OTHER;
37     static const int CONFLICT_CLAUSE_COUNT = 6;
38 
39     static int GetSqlStatementType(const std::string &sql);
40     static bool IsSqlReadOnly(int sqlType);
41     static bool IsSpecial(int sqlType);
42     static int GetConflictClause(int conflictResolution, std::string &conflictClause);
43     static std::string StrToUpper(std::string s);
44     static bool DeleteFile(const std::string path);
45     static int RenameFile(const std::string srcFile, const std::string destFile);
46 
47 private:
48     static const std::map<std::string, int> SQL_TYPE_MAP;
49     static const std::string ON_CONFLICT_CLAUSE[CONFLICT_CLAUSE_COUNT];
50 };
51 
52 } // namespace NativeRdb
53 } // namespace OHOS
54 #endif