• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 NWEB_ROM_VALUE_H
17 #define NWEB_ROM_VALUE_H
18 
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace OHOS::NWeb {
25 
26 class NWebRomValue {
27 public:
28     enum class Type : unsigned char {
29         NONE = 0,
30         BOOLEAN,
31         INTEGER,
32         DOUBLE,
33         STRING,
34         BINARY,
35         DICTIONARY,
36         LIST,
37         ERROR,
38         STRINGARRAY,
39         BOOLEANARRAY,
40         DOUBLEARRAY,
41         INT64ARRAY
42     };
43 
44     virtual ~NWebRomValue() = default;
45 
46     virtual Type GetType() = 0;
47 
48     virtual void SetType(Type type) = 0;
49 
50     virtual int GetInt() = 0;
51 
52     virtual void SetInt(int value) = 0;
53 
54     virtual bool GetBool() = 0;
55 
56     virtual void SetBool(bool value) = 0;
57 
58     virtual double GetDouble() = 0;
59 
60     virtual void SetDouble(double value) = 0;
61 
62     virtual std::string GetString() = 0;
63 
64     virtual void SetString(const std::string& value) = 0;
65 
66     virtual const char* GetBinary(int& length) = 0;
67 
68     virtual void SetBinary(int size, const char* value) = 0;
69 
70     virtual std::map<std::string, std::shared_ptr<NWebRomValue>> GetDictValue() = 0;
71 
72     virtual std::vector<std::shared_ptr<NWebRomValue>> GetListValue() = 0;
73 
74     virtual std::shared_ptr<NWebRomValue> NewChildValue() = 0;
75 
76     virtual void SaveDictChildValue(const std::string& key) = 0;
77 
78     virtual void SaveListChildValue() = 0;
79 
80     virtual int64_t GetInt64() = 0;
81 
82     virtual void SetInt64(int64_t value) = 0;
83 
84     virtual std::vector<uint8_t> GetBinary() = 0;
85 
86     virtual void SetBinary(const std::vector<uint8_t>& value) = 0;
87 
88     virtual std::vector<bool> GetBoolArray() = 0;
89 
90     virtual void SetBoolArray(const std::vector<bool>& value) = 0;
91 
92     virtual std::vector<int64_t> GetInt64Array() = 0;
93 
94     virtual void SetInt64Array(const std::vector<int64_t>& value) = 0;
95 
96     virtual std::vector<double> GetDoubleArray() = 0;
97 
98     virtual void SetDoubleArray(const std::vector<double>& value) = 0;
99 
100     virtual std::vector<std::string> GetStringArray() = 0;
101 
102     virtual void SetStringArray(const std::vector<std::string>& value) = 0;
103 
104     virtual std::string GetErrMsg() = 0;
105 
106     virtual void SetErrMsg(const std::string& msg) = 0;
107 
108     virtual std::string GetErrName() = 0;
109 
110     virtual void SetErrName(const std::string& name) = 0;
111 };
112 
113 } // namespace OHOS::NWeb
114 
115 #endif // NWEB_ROM_VALUE_H