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 DATA_ACCESS_H
17 #define DATA_ACCESS_H
18 
19 #include <memory>
20 #include <string>
21 
22 namespace OHOS {
23 namespace bluetooth {
24 class IDataResult {
25 public:
26     virtual ~IDataResult() = default;
Next()27     virtual bool Next()
28     {
29         return true;
30     }
GetColumnCount()31     virtual int GetColumnCount()
32     {
33         return 0;
34     }
GetColumnName(int index)35     virtual std::string GetColumnName(int index)
36     {
37         return "";
38     }
IsNotNull(int index)39     virtual bool IsNotNull(int index)
40     {
41         return true;
42     }
GetInt(int index)43     virtual int GetInt(int index)
44     {
45         return 0;
46     }
GetInt64(int index)47     virtual int64_t GetInt64(int index)
48     {
49         return 0;
50     }
GetString(int index)51     virtual std::string GetString(int index)
52     {
53         return "stub";
54     }
55 };
56 
57 class IDataStatement {
58 public:
59     virtual ~IDataStatement() = default;
Query()60     virtual std::unique_ptr<IDataResult> Query()
61     {
62         return nullptr;
63     }
Update()64     virtual int Update()
65     {
66         return 0;
67     }
Delete()68     virtual int Delete()
69     {
70         return 0;
71     }
Insert()72     virtual int Insert()
73     {
74         return 0;
75     }
ClearParams()76     virtual int ClearParams()
77     {
78         return 0;
79     }
SetParamInt64(int index,int64_t value)80     virtual int SetParamInt64(int index, int64_t value)
81     {
82         return 0;
83     }
SetParamInt(int index,int value)84     virtual int SetParamInt(int index, int value)
85     {
86         return 0;
87     }
SetParamString(int index,const std::string & value)88     virtual int SetParamString(int index, const std::string &value)
89     {
90         return 0;
91     }
SetParam16String(int index,const std::u16string & value)92     virtual int SetParam16String(int index, const std::u16string &value)
93     {
94         return 0;
95     }
96 };
97 
98 class DataAccess {
99 public:
100     static std::unique_ptr<DataAccess> GetConnection(
101         const std::string &dbUri, bool readOnly = true, bool create = false)
102     {
103         return nullptr;
104     }
105     virtual ~DataAccess();
CreateStatement(std::string sql)106     std::unique_ptr<IDataStatement> CreateStatement(std::string sql)
107     {
108         return nullptr;
109     }
GetLastInsertRowid()110     int64_t GetLastInsertRowid()
111     {
112         return 0;
113     }
BeginTransaction()114     bool BeginTransaction()
115     {
116         return true;
117     }
Commit()118     bool Commit()
119     {
120         return true;
121     }
Rollback()122     bool Rollback()
123     {
124         return true;
125     }
126 };
127 }  // namespace bluetooth
128 }  // namespace OHOS
129 #endif