• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024 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 PANDA_TOOLING_INSPECTOR_TYPES_PROPERTY_PREVIEW_H
17 #define PANDA_TOOLING_INSPECTOR_TYPES_PROPERTY_PREVIEW_H
18 
19 #include "tooling/inspector/types/remote_object_type.h"
20 #include "tooling/inspector/json_serialization/serializable.h"
21 
22 #include <optional>
23 #include <string>
24 
25 namespace ark::tooling::inspector {
26 
27 class PropertyPreview final : public JsonSerializable {
28 public:
PropertyPreview(std::string name,RemoteObjectType type)29     PropertyPreview(std::string name, RemoteObjectType type) : name_(std::move(name)), type_(std::move(type)) {}
30 
PropertyPreview(std::string name,RemoteObjectType type,const std::string & value)31     PropertyPreview(std::string name, RemoteObjectType type, const std::string &value)
32         : PropertyPreview(std::move(name), std::move(type))
33     {
34         value_ = value;
35     }
36 
Serialize(JsonObjectBuilder & builder)37     void Serialize(JsonObjectBuilder &builder) const override
38     {
39         type_.Serialize(builder);
40         builder.AddProperty("name", name_);
41 
42         if (value_) {
43             builder.AddProperty("value", *value_);
44         }
45     }
46 
47 private:
48     std::string name_;
49     RemoteObjectType type_;
50     std::optional<std::string> value_;
51 };
52 
53 }  // namespace ark::tooling::inspector
54 
55 #endif  // PANDA_TOOLING_INSPECTOR_TYPES_PROPERTY_PREVIEW_H
56