File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 18
18
19
19
#include < optional>
20
20
#include < span>
21
+ #include < string>
21
22
#include < string_view>
23
+ #include < variant>
22
24
#include < vector>
23
25
24
26
namespace oi ::result {
@@ -31,6 +33,12 @@ struct Element {
31
33
struct IsSetStats {
32
34
bool is_set;
33
35
};
36
+ struct Pointer {
37
+ uintptr_t p;
38
+ };
39
+ struct Scalar {
40
+ uint64_t n;
41
+ };
34
42
35
43
std::string_view name;
36
44
std::vector<std::string_view>
@@ -40,6 +48,8 @@ struct Element {
40
48
size_t exclusive_size;
41
49
42
50
std::optional<uintptr_t > pointer;
51
+ std::variant<std::nullopt_t , Pointer, Scalar, std::string> data = {
52
+ std::nullopt };
43
53
std::optional<ContainerStats> container_stats;
44
54
std::optional<IsSetStats> is_set_stats;
45
55
};
Original file line number Diff line number Diff line change 17
17
18
18
#include < algorithm>
19
19
#include < stdexcept>
20
+ #include < variant>
20
21
21
22
template <class >
22
23
inline constexpr bool always_false_v = false ;
@@ -99,6 +100,18 @@ void Json::print(IntrospectionResult::const_iterator& it,
99
100
out_ << tab << " \" pointer\" :" << space << *(it->pointer ) << ' ,' << endl
100
101
<< indent;
101
102
}
103
+
104
+ if (auto * s = std::get_if<result::Element::Scalar>(&it->data )) {
105
+ out_ << tab << " \" data\" :" << space << s->n << ' ,' << endl << indent;
106
+ } else if (auto * p = std::get_if<result::Element::Pointer>(&it->data )) {
107
+ out_ << tab << " \" data\" :" << space << " \" 0x" << std::hex << p->p
108
+ << std::dec << " \" ," << endl
109
+ << indent;
110
+ } else if (auto * str = std::get_if<std::string>(&it->data )) {
111
+ out_ << tab << " \" data\" :" << space << " \" " << *str << " \" ," << endl
112
+ << indent;
113
+ }
114
+
102
115
if (it->container_stats .has_value ()) {
103
116
out_ << tab << " \" length\" :" << space << it->container_stats ->length
104
117
<< ' ,' << endl
You can’t perform that action at this time.
0 commit comments