@@ -11,18 +11,18 @@ ContextFilter::ContextFilter(
11
11
: all_attributes_private_(all_attributes_private),
12
12
global_private_attributes_ (std::move(global_private_attributes)) {}
13
13
14
- ContextFilter::JsonValue ContextFilter::filter (Context const & context) {
14
+ ContextFilter::JsonValue ContextFilter::Filter (Context const & context) {
15
15
// Context should be validated before calling this method.
16
16
assert (context.Valid ());
17
17
if (context.Kinds ().size () == 1 ) {
18
- auto kind = context.Kinds ()[0 ];
19
- return filter_single_context (kind, INCLUDE_KIND,
20
- context.Attributes (kind. data () ));
18
+ std::string const & kind = context.Kinds ()[0 ];
19
+ return FilterSingleContext (kind, INCLUDE_KIND,
20
+ context.Attributes (kind));
21
21
}
22
- return filter_multi_context (context);
22
+ return FilterMultiContext (context);
23
23
}
24
24
25
- void ContextFilter::emplace (ContextFilter::StackItem& item,
25
+ void ContextFilter::Emplace (ContextFilter::StackItem& item,
26
26
ContextFilter::JsonValue&& addition) {
27
27
if (item.parent .is_object ()) {
28
28
item.parent .as_object ().emplace (item.path .back (), std::move (addition));
@@ -31,7 +31,7 @@ void ContextFilter::emplace(ContextFilter::StackItem& item,
31
31
}
32
32
}
33
33
34
- bool ContextFilter::redact (std::vector<std::string>& redactions,
34
+ bool ContextFilter::Redact (std::vector<std::string>& redactions,
35
35
std::vector<std::string_view> path,
36
36
Attributes const & attributes) {
37
37
if (all_attributes_private_) {
@@ -58,7 +58,7 @@ bool ContextFilter::redact(std::vector<std::string>& redactions,
58
58
return false ;
59
59
}
60
60
61
- ContextFilter::JsonValue ContextFilter::filter_single_context (
61
+ ContextFilter::JsonValue ContextFilter::FilterSingleContext (
62
62
std::string_view kind,
63
63
bool include_kind,
64
64
Attributes const & attributes) {
@@ -75,7 +75,7 @@ ContextFilter::JsonValue ContextFilter::filter_single_context(
75
75
}
76
76
77
77
if (!attributes.Name ().empty () &&
78
- !redact (redactions, std::vector<std::string_view>{" name" },
78
+ !Redact (redactions, std::vector<std::string_view>{" name" },
79
79
attributes)) {
80
80
filtered.as_object ().insert_or_assign (" name" , attributes.Name ());
81
81
}
@@ -90,20 +90,20 @@ ContextFilter::JsonValue ContextFilter::filter_single_context(
90
90
stack.pop_back ();
91
91
92
92
// Check if the attribute needs to be redacted.
93
- if (!item.path .empty () && redact (redactions, item.path , attributes)) {
93
+ if (!item.path .empty () && Redact (redactions, item.path , attributes)) {
94
94
continue ;
95
95
}
96
96
97
97
if (item.value .IsObject ()) {
98
- JsonValue* nested = append_container (item, JsonObject ());
98
+ JsonValue* nested = AppendContainer (item, JsonObject ());
99
99
100
100
for (auto const & pair : item.value .AsObject ()) {
101
101
auto new_path = std::vector<std::string_view>(item.path );
102
102
new_path.push_back (pair.first );
103
103
stack.push_back (StackItem{pair.second , new_path, *nested});
104
104
}
105
105
} else if (item.value .IsArray ()) {
106
- JsonValue* nested = append_container (item, JsonArray ());
106
+ JsonValue* nested = AppendContainer (item, JsonArray ());
107
107
108
108
// Array contents are added in reverse, this is a recursive
109
109
// algorithm so they will get reversed again when the stack
@@ -120,7 +120,7 @@ ContextFilter::JsonValue ContextFilter::filter_single_context(
120
120
rev_from++;
121
121
}
122
122
} else {
123
- append_simple_type (item);
123
+ AppendSimpleType (item);
124
124
}
125
125
}
126
126
@@ -137,19 +137,19 @@ ContextFilter::JsonValue ContextFilter::filter_single_context(
137
137
return filtered;
138
138
}
139
139
140
- void ContextFilter::append_simple_type (ContextFilter::StackItem& item) {
140
+ void ContextFilter::AppendSimpleType (ContextFilter::StackItem& item) {
141
141
switch (item.value .Type ()) {
142
142
case Value::Type::kNull :
143
- emplace (item, JsonValue ());
143
+ Emplace (item, JsonValue ());
144
144
break ;
145
145
case Value::Type::kBool :
146
- emplace (item, item.value .AsBool ());
146
+ Emplace (item, item.value .AsBool ());
147
147
break ;
148
148
case Value::Type::kNumber :
149
- emplace (item, item.value .AsDouble ());
149
+ Emplace (item, item.value .AsDouble ());
150
150
break ;
151
151
case Value::Type::kString :
152
- emplace (item, item.value .AsString ().c_str ());
152
+ Emplace (item, item.value .AsString ().c_str ());
153
153
break ;
154
154
case Value::Type::kObject :
155
155
case Value::Type::kArray :
@@ -158,7 +158,7 @@ void ContextFilter::append_simple_type(ContextFilter::StackItem& item) {
158
158
}
159
159
}
160
160
161
- ContextFilter::JsonValue* ContextFilter::append_container (
161
+ ContextFilter::JsonValue* ContextFilter::AppendContainer (
162
162
ContextFilter::StackItem& item,
163
163
JsonValue&& value) {
164
164
if (item.parent .is_object ()) {
@@ -169,15 +169,15 @@ ContextFilter::JsonValue* ContextFilter::append_container(
169
169
return &item.parent .as_array ().back ();
170
170
}
171
171
172
- ContextFilter::JsonValue ContextFilter::filter_multi_context (
172
+ ContextFilter::JsonValue ContextFilter::FilterMultiContext (
173
173
Context const & context) {
174
174
JsonValue filtered = JsonObject ();
175
175
filtered.as_object ().emplace (" kind" , " multi" );
176
176
177
- for (auto const & kind : context.Kinds ()) {
177
+ for (std::string const & kind : context.Kinds ()) {
178
178
filtered.as_object ().emplace (
179
- kind, filter_single_context (kind, EXCLUDE_KIND,
180
- context.Attributes (kind. data () )));
179
+ kind,
180
+ FilterSingleContext (kind, EXCLUDE_KIND, context.Attributes (kind)));
181
181
}
182
182
183
183
return filtered;
0 commit comments