/proc/self/cwd/external/com_github_google_libprotobuf_mutator/src/field_instance.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2016 Google Inc. All rights reserved. |
2 | | // |
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 | | #ifndef SRC_FIELD_INSTANCE_H_ |
16 | | #define SRC_FIELD_INSTANCE_H_ |
17 | | |
18 | | #include <memory> |
19 | | #include <string> |
20 | | |
21 | | #include "port/protobuf.h" |
22 | | |
23 | | namespace protobuf_mutator { |
24 | | |
25 | | // Helper class for common protobuf fields operations. |
26 | | class ConstFieldInstance { |
27 | | public: |
28 | | static const size_t kInvalidIndex = -1; |
29 | | |
30 | | struct Enum { |
31 | | size_t index; |
32 | | size_t count; |
33 | | }; |
34 | | |
35 | | ConstFieldInstance() |
36 | 0 | : message_(nullptr), descriptor_(nullptr), index_(kInvalidIndex) {} |
37 | | |
38 | | ConstFieldInstance(const protobuf::Message* message, |
39 | | const protobuf::FieldDescriptor* field, size_t index) |
40 | 0 | : message_(message), descriptor_(field), index_(index) { |
41 | 0 | assert(message_); |
42 | 0 | assert(descriptor_); |
43 | 0 | assert(index_ != kInvalidIndex); |
44 | 0 | assert(descriptor_->is_repeated()); |
45 | 0 | } |
46 | | |
47 | | ConstFieldInstance(const protobuf::Message* message, |
48 | | const protobuf::FieldDescriptor* field) |
49 | 1.09k | : message_(message), descriptor_(field), index_(kInvalidIndex) { |
50 | 1.09k | assert(message_); |
51 | 0 | assert(descriptor_); |
52 | 0 | assert(!descriptor_->is_repeated()); |
53 | 1.09k | } |
54 | | |
55 | 0 | void GetDefault(int32_t* out) const { |
56 | 0 | *out = descriptor_->default_value_int32(); |
57 | 0 | } |
58 | | |
59 | 0 | void GetDefault(int64_t* out) const { |
60 | 0 | *out = descriptor_->default_value_int64(); |
61 | 0 | } |
62 | | |
63 | 0 | void GetDefault(uint32_t* out) const { |
64 | 0 | *out = descriptor_->default_value_uint32(); |
65 | 0 | } |
66 | | |
67 | 0 | void GetDefault(uint64_t* out) const { |
68 | 0 | *out = descriptor_->default_value_uint64(); |
69 | 0 | } |
70 | | |
71 | 0 | void GetDefault(double* out) const { |
72 | 0 | *out = descriptor_->default_value_double(); |
73 | 0 | } |
74 | | |
75 | 0 | void GetDefault(float* out) const { |
76 | 0 | *out = descriptor_->default_value_float(); |
77 | 0 | } |
78 | | |
79 | 0 | void GetDefault(bool* out) const { *out = descriptor_->default_value_bool(); } |
80 | | |
81 | 0 | void GetDefault(Enum* out) const { |
82 | 0 | const protobuf::EnumValueDescriptor* value = |
83 | 0 | descriptor_->default_value_enum(); |
84 | 0 | const protobuf::EnumDescriptor* type = value->type(); |
85 | 0 | *out = {static_cast<size_t>(value->index()), |
86 | 0 | static_cast<size_t>(type->value_count())}; |
87 | 0 | } |
88 | | |
89 | 545 | void GetDefault(std::string* out) const { |
90 | 545 | *out = descriptor_->default_value_string(); |
91 | 545 | } |
92 | | |
93 | 549 | void GetDefault(std::unique_ptr<protobuf::Message>* out) const { |
94 | 549 | out->reset(reflection() |
95 | 549 | .GetMessageFactory() |
96 | 549 | ->GetPrototype(descriptor_->message_type()) |
97 | 549 | ->New()); |
98 | 549 | } |
99 | | |
100 | 0 | void Load(int32_t* value) const { |
101 | 0 | *value = is_repeated() |
102 | 0 | ? reflection().GetRepeatedInt32(*message_, descriptor_, index_) |
103 | 0 | : reflection().GetInt32(*message_, descriptor_); |
104 | 0 | } |
105 | | |
106 | 0 | void Load(int64_t* value) const { |
107 | 0 | *value = is_repeated() |
108 | 0 | ? reflection().GetRepeatedInt64(*message_, descriptor_, index_) |
109 | 0 | : reflection().GetInt64(*message_, descriptor_); |
110 | 0 | } |
111 | | |
112 | 0 | void Load(uint32_t* value) const { |
113 | 0 | *value = is_repeated() ? reflection().GetRepeatedUInt32(*message_, |
114 | 0 | descriptor_, index_) |
115 | 0 | : reflection().GetUInt32(*message_, descriptor_); |
116 | 0 | } |
117 | | |
118 | 0 | void Load(uint64_t* value) const { |
119 | 0 | *value = is_repeated() ? reflection().GetRepeatedUInt64(*message_, |
120 | 0 | descriptor_, index_) |
121 | 0 | : reflection().GetUInt64(*message_, descriptor_); |
122 | 0 | } |
123 | | |
124 | 0 | void Load(double* value) const { |
125 | 0 | *value = is_repeated() ? reflection().GetRepeatedDouble(*message_, |
126 | 0 | descriptor_, index_) |
127 | 0 | : reflection().GetDouble(*message_, descriptor_); |
128 | 0 | } |
129 | | |
130 | 0 | void Load(float* value) const { |
131 | 0 | *value = is_repeated() |
132 | 0 | ? reflection().GetRepeatedFloat(*message_, descriptor_, index_) |
133 | 0 | : reflection().GetFloat(*message_, descriptor_); |
134 | 0 | } |
135 | | |
136 | 0 | void Load(bool* value) const { |
137 | 0 | *value = is_repeated() |
138 | 0 | ? reflection().GetRepeatedBool(*message_, descriptor_, index_) |
139 | 0 | : reflection().GetBool(*message_, descriptor_); |
140 | 0 | } |
141 | | |
142 | 0 | void Load(Enum* value) const { |
143 | 0 | const protobuf::EnumValueDescriptor* value_descriptor = |
144 | 0 | is_repeated() |
145 | 0 | ? reflection().GetRepeatedEnum(*message_, descriptor_, index_) |
146 | 0 | : reflection().GetEnum(*message_, descriptor_); |
147 | 0 | *value = {static_cast<size_t>(value_descriptor->index()), |
148 | 0 | static_cast<size_t>(value_descriptor->type()->value_count())}; |
149 | 0 | if (value->index >= value->count) GetDefault(value); |
150 | 0 | } |
151 | | |
152 | 0 | void Load(std::string* value) const { |
153 | 0 | *value = is_repeated() ? reflection().GetRepeatedString(*message_, |
154 | 0 | descriptor_, index_) |
155 | 0 | : reflection().GetString(*message_, descriptor_); |
156 | 0 | } |
157 | | |
158 | 0 | void Load(std::unique_ptr<protobuf::Message>* value) const { |
159 | 0 | const protobuf::Message& source = |
160 | 0 | is_repeated() |
161 | 0 | ? reflection().GetRepeatedMessage(*message_, descriptor_, index_) |
162 | 0 | : reflection().GetMessage(*message_, descriptor_); |
163 | 0 | value->reset(source.New()); |
164 | 0 | (*value)->CopyFrom(source); |
165 | 0 | } |
166 | | |
167 | | template <class T> |
168 | 0 | bool CanStore(const T& value) const { |
169 | 0 | return true; |
170 | 0 | } Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<int>(int const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<long>(long const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<unsigned int>(unsigned int const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<unsigned long>(unsigned long const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<double>(double const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<float>(float const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<bool>(bool const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<protobuf_mutator::ConstFieldInstance::Enum>(protobuf_mutator::ConstFieldInstance::Enum const&) const Unexecuted instantiation: bool protobuf_mutator::ConstFieldInstance::CanStore<std::__1::unique_ptr<google::protobuf::Message, std::__1::default_delete<google::protobuf::Message> > >(std::__1::unique_ptr<google::protobuf::Message, std::__1::default_delete<google::protobuf::Message> > const&) const |
171 | | |
172 | 0 | bool CanStore(const std::string& value) const { |
173 | 0 | if (!EnforceUtf8()) return true; |
174 | 0 | using protobuf::internal::WireFormatLite; |
175 | 0 | return WireFormatLite::VerifyUtf8String(value.data(), value.length(), |
176 | 0 | WireFormatLite::PARSE, ""); |
177 | 0 | } |
178 | | |
179 | 0 | std::string name() const { return descriptor_->name(); } |
180 | | |
181 | 1.09k | protobuf::FieldDescriptor::CppType cpp_type() const { |
182 | 1.09k | return descriptor_->cpp_type(); |
183 | 1.09k | } |
184 | | |
185 | 0 | const protobuf::EnumDescriptor* enum_type() const { |
186 | 0 | return descriptor_->enum_type(); |
187 | 0 | } |
188 | | |
189 | 0 | const protobuf::Descriptor* message_type() const { |
190 | 0 | return descriptor_->message_type(); |
191 | 0 | } |
192 | | |
193 | 0 | bool EnforceUtf8() const { return descriptor_->requires_utf8_validation(); } |
194 | | |
195 | 2.18k | const protobuf::FieldDescriptor* descriptor() const { return descriptor_; } |
196 | | |
197 | 0 | std::string DebugString() const { |
198 | 0 | std::string s = descriptor_->DebugString(); |
199 | 0 | if (is_repeated()) s += "[" + std::to_string(index_) + "]"; |
200 | 0 | return s + " of\n" + message_->DebugString(); |
201 | 0 | } |
202 | | |
203 | | protected: |
204 | 2.18k | bool is_repeated() const { return descriptor_->is_repeated(); } |
205 | | |
206 | 1.64k | const protobuf::Reflection& reflection() const { |
207 | 1.64k | return *message_->GetReflection(); |
208 | 1.64k | } |
209 | | |
210 | 0 | size_t index() const { return index_; } |
211 | | |
212 | | private: |
213 | | template <class Fn, class T> |
214 | | friend struct FieldFunction; |
215 | | |
216 | | const protobuf::Message* message_; |
217 | | const protobuf::FieldDescriptor* descriptor_; |
218 | | size_t index_; |
219 | | }; |
220 | | |
221 | | class FieldInstance : public ConstFieldInstance { |
222 | | public: |
223 | | static const size_t kInvalidIndex = -1; |
224 | | |
225 | 0 | FieldInstance() : ConstFieldInstance(), message_(nullptr) {} |
226 | | |
227 | | FieldInstance(protobuf::Message* message, |
228 | | const protobuf::FieldDescriptor* field, size_t index) |
229 | 0 | : ConstFieldInstance(message, field, index), message_(message) {} |
230 | | |
231 | | FieldInstance(protobuf::Message* message, |
232 | | const protobuf::FieldDescriptor* field) |
233 | 1.09k | : ConstFieldInstance(message, field), message_(message) {} |
234 | | |
235 | 0 | void Delete() const { |
236 | 0 | if (!is_repeated()) return reflection().ClearField(message_, descriptor()); |
237 | 0 | int field_size = reflection().FieldSize(*message_, descriptor()); |
238 | | // API has only method to delete the last message, so we move method from |
239 | | // the |
240 | | // middle to the end. |
241 | 0 | for (int i = index() + 1; i < field_size; ++i) |
242 | 0 | reflection().SwapElements(message_, descriptor(), i, i - 1); |
243 | 0 | reflection().RemoveLast(message_, descriptor()); |
244 | 0 | } |
245 | | |
246 | | template <class T> |
247 | 1.09k | void Create(const T& value) const { |
248 | 1.09k | if (!is_repeated()) return Store(value); |
249 | 0 | InsertRepeated(value); |
250 | 0 | } Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<int>(int const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<long>(long const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<unsigned int>(unsigned int const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<unsigned long>(unsigned long const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<double>(double const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<float>(float const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<bool>(bool const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::Create<protobuf_mutator::ConstFieldInstance::Enum>(protobuf_mutator::ConstFieldInstance::Enum const&) const void protobuf_mutator::FieldInstance::Create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const Line | Count | Source | 247 | 545 | void Create(const T& value) const { | 248 | 545 | if (!is_repeated()) return Store(value); | 249 | 0 | InsertRepeated(value); | 250 | 0 | } |
void protobuf_mutator::FieldInstance::Create<std::__1::unique_ptr<google::protobuf::Message, std::__1::default_delete<google::protobuf::Message> > >(std::__1::unique_ptr<google::protobuf::Message, std::__1::default_delete<google::protobuf::Message> > const&) const Line | Count | Source | 247 | 549 | void Create(const T& value) const { | 248 | 549 | if (!is_repeated()) return Store(value); | 249 | 0 | InsertRepeated(value); | 250 | 0 | } |
|
251 | | |
252 | 0 | void Store(int32_t value) const { |
253 | 0 | if (is_repeated()) |
254 | 0 | reflection().SetRepeatedInt32(message_, descriptor(), index(), value); |
255 | 0 | else |
256 | 0 | reflection().SetInt32(message_, descriptor(), value); |
257 | 0 | } |
258 | | |
259 | 0 | void Store(int64_t value) const { |
260 | 0 | if (is_repeated()) |
261 | 0 | reflection().SetRepeatedInt64(message_, descriptor(), index(), value); |
262 | 0 | else |
263 | 0 | reflection().SetInt64(message_, descriptor(), value); |
264 | 0 | } |
265 | | |
266 | 0 | void Store(uint32_t value) const { |
267 | 0 | if (is_repeated()) |
268 | 0 | reflection().SetRepeatedUInt32(message_, descriptor(), index(), value); |
269 | 0 | else |
270 | 0 | reflection().SetUInt32(message_, descriptor(), value); |
271 | 0 | } |
272 | | |
273 | 0 | void Store(uint64_t value) const { |
274 | 0 | if (is_repeated()) |
275 | 0 | reflection().SetRepeatedUInt64(message_, descriptor(), index(), value); |
276 | 0 | else |
277 | 0 | reflection().SetUInt64(message_, descriptor(), value); |
278 | 0 | } |
279 | | |
280 | 0 | void Store(double value) const { |
281 | 0 | if (is_repeated()) |
282 | 0 | reflection().SetRepeatedDouble(message_, descriptor(), index(), value); |
283 | 0 | else |
284 | 0 | reflection().SetDouble(message_, descriptor(), value); |
285 | 0 | } |
286 | | |
287 | 0 | void Store(float value) const { |
288 | 0 | if (is_repeated()) |
289 | 0 | reflection().SetRepeatedFloat(message_, descriptor(), index(), value); |
290 | 0 | else |
291 | 0 | reflection().SetFloat(message_, descriptor(), value); |
292 | 0 | } |
293 | | |
294 | 0 | void Store(bool value) const { |
295 | 0 | if (is_repeated()) |
296 | 0 | reflection().SetRepeatedBool(message_, descriptor(), index(), value); |
297 | 0 | else |
298 | 0 | reflection().SetBool(message_, descriptor(), value); |
299 | 0 | } |
300 | | |
301 | 0 | void Store(const Enum& value) const { |
302 | 0 | assert(value.index < value.count); |
303 | 0 | const protobuf::EnumValueDescriptor* enum_value = |
304 | 0 | descriptor()->enum_type()->value(value.index); |
305 | 0 | if (is_repeated()) |
306 | 0 | reflection().SetRepeatedEnum(message_, descriptor(), index(), enum_value); |
307 | 0 | else |
308 | 0 | reflection().SetEnum(message_, descriptor(), enum_value); |
309 | 0 | } |
310 | | |
311 | 545 | void Store(const std::string& value) const { |
312 | 545 | if (is_repeated()) |
313 | 0 | reflection().SetRepeatedString(message_, descriptor(), index(), value); |
314 | 545 | else |
315 | 545 | reflection().SetString(message_, descriptor(), value); |
316 | 545 | } |
317 | | |
318 | 549 | void Store(const std::unique_ptr<protobuf::Message>& value) const { |
319 | 549 | protobuf::Message* mutable_message = |
320 | 549 | is_repeated() ? reflection().MutableRepeatedMessage( |
321 | 0 | message_, descriptor(), index()) |
322 | 549 | : reflection().MutableMessage(message_, descriptor()); |
323 | 549 | mutable_message->Clear(); |
324 | 549 | if (value) mutable_message->CopyFrom(*value); |
325 | 549 | } |
326 | | |
327 | | private: |
328 | | template <class T> |
329 | 0 | void InsertRepeated(const T& value) const { |
330 | 0 | PushBackRepeated(value); |
331 | 0 | size_t field_size = reflection().FieldSize(*message_, descriptor()); |
332 | 0 | if (field_size == 1) return; |
333 | | // API has only method to add field to the end of the list. So we add |
334 | | // descriptor() |
335 | | // and move it into the middle. |
336 | 0 | for (size_t i = field_size - 1; i > index(); --i) |
337 | 0 | reflection().SwapElements(message_, descriptor(), i, i - 1); |
338 | 0 | } Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<int>(int const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<long>(long const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<unsigned int>(unsigned int const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<unsigned long>(unsigned long const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<double>(double const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<float>(float const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<bool>(bool const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<protobuf_mutator::ConstFieldInstance::Enum>(protobuf_mutator::ConstFieldInstance::Enum const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const Unexecuted instantiation: void protobuf_mutator::FieldInstance::InsertRepeated<std::__1::unique_ptr<google::protobuf::Message, std::__1::default_delete<google::protobuf::Message> > >(std::__1::unique_ptr<google::protobuf::Message, std::__1::default_delete<google::protobuf::Message> > const&) const |
339 | | |
340 | 0 | void PushBackRepeated(int32_t value) const { |
341 | 0 | assert(is_repeated()); |
342 | 0 | reflection().AddInt32(message_, descriptor(), value); |
343 | 0 | } |
344 | | |
345 | 0 | void PushBackRepeated(int64_t value) const { |
346 | 0 | assert(is_repeated()); |
347 | 0 | reflection().AddInt64(message_, descriptor(), value); |
348 | 0 | } |
349 | | |
350 | 0 | void PushBackRepeated(uint32_t value) const { |
351 | 0 | assert(is_repeated()); |
352 | 0 | reflection().AddUInt32(message_, descriptor(), value); |
353 | 0 | } |
354 | | |
355 | 0 | void PushBackRepeated(uint64_t value) const { |
356 | 0 | assert(is_repeated()); |
357 | 0 | reflection().AddUInt64(message_, descriptor(), value); |
358 | 0 | } |
359 | | |
360 | 0 | void PushBackRepeated(double value) const { |
361 | 0 | assert(is_repeated()); |
362 | 0 | reflection().AddDouble(message_, descriptor(), value); |
363 | 0 | } |
364 | | |
365 | 0 | void PushBackRepeated(float value) const { |
366 | 0 | assert(is_repeated()); |
367 | 0 | reflection().AddFloat(message_, descriptor(), value); |
368 | 0 | } |
369 | | |
370 | 0 | void PushBackRepeated(bool value) const { |
371 | 0 | assert(is_repeated()); |
372 | 0 | reflection().AddBool(message_, descriptor(), value); |
373 | 0 | } |
374 | | |
375 | 0 | void PushBackRepeated(const Enum& value) const { |
376 | 0 | assert(value.index < value.count); |
377 | 0 | const protobuf::EnumValueDescriptor* enum_value = |
378 | 0 | descriptor()->enum_type()->value(value.index); |
379 | 0 | assert(is_repeated()); |
380 | 0 | reflection().AddEnum(message_, descriptor(), enum_value); |
381 | 0 | } |
382 | | |
383 | 0 | void PushBackRepeated(const std::string& value) const { |
384 | 0 | assert(is_repeated()); |
385 | 0 | reflection().AddString(message_, descriptor(), value); |
386 | 0 | } |
387 | | |
388 | 0 | void PushBackRepeated(const std::unique_ptr<protobuf::Message>& value) const { |
389 | 0 | assert(is_repeated()); |
390 | 0 | protobuf::Message* mutable_message = |
391 | 0 | reflection().AddMessage(message_, descriptor()); |
392 | 0 | mutable_message->Clear(); |
393 | 0 | if (value) mutable_message->CopyFrom(*value); |
394 | 0 | } |
395 | | |
396 | | protobuf::Message* message_; |
397 | | }; |
398 | | |
399 | | template <class Fn, class R = void> |
400 | | struct FieldFunction { |
401 | | template <class Field, class... Args> |
402 | 1.09k | R operator()(const Field& field, const Args&... args) const { |
403 | 1.09k | assert(field.descriptor()); |
404 | 0 | using protobuf::FieldDescriptor; |
405 | 1.09k | switch (field.cpp_type()) { |
406 | 0 | case FieldDescriptor::CPPTYPE_INT32: |
407 | 0 | return static_cast<const Fn*>(this)->template ForType<int32_t>(field, |
408 | 0 | args...); |
409 | 0 | case FieldDescriptor::CPPTYPE_INT64: |
410 | 0 | return static_cast<const Fn*>(this)->template ForType<int64_t>(field, |
411 | 0 | args...); |
412 | 0 | case FieldDescriptor::CPPTYPE_UINT32: |
413 | 0 | return static_cast<const Fn*>(this)->template ForType<uint32_t>( |
414 | 0 | field, args...); |
415 | 0 | case FieldDescriptor::CPPTYPE_UINT64: |
416 | 0 | return static_cast<const Fn*>(this)->template ForType<uint64_t>( |
417 | 0 | field, args...); |
418 | 0 | case FieldDescriptor::CPPTYPE_DOUBLE: |
419 | 0 | return static_cast<const Fn*>(this)->template ForType<double>(field, |
420 | 0 | args...); |
421 | 0 | case FieldDescriptor::CPPTYPE_FLOAT: |
422 | 0 | return static_cast<const Fn*>(this)->template ForType<float>(field, |
423 | 0 | args...); |
424 | 0 | case FieldDescriptor::CPPTYPE_BOOL: |
425 | 0 | return static_cast<const Fn*>(this)->template ForType<bool>(field, |
426 | 0 | args...); |
427 | 0 | case FieldDescriptor::CPPTYPE_ENUM: |
428 | 0 | return static_cast<const Fn*>(this) |
429 | 0 | ->template ForType<ConstFieldInstance::Enum>(field, args...); |
430 | 545 | case FieldDescriptor::CPPTYPE_STRING: |
431 | 545 | return static_cast<const Fn*>(this)->template ForType<std::string>( |
432 | 545 | field, args...); |
433 | 549 | case FieldDescriptor::CPPTYPE_MESSAGE: |
434 | 549 | return static_cast<const Fn*>(this) |
435 | 549 | ->template ForType<std::unique_ptr<protobuf::Message>>(field, |
436 | 549 | args...); |
437 | 1.09k | } |
438 | 0 | assert(false && "Unknown type"); |
439 | 0 | abort(); |
440 | 1.09k | } Unexecuted instantiation: mutator.cc:bool protobuf_mutator::FieldFunction<protobuf_mutator::(anonymous namespace)::CanCopyAndDifferentField, bool>::operator()<protobuf_mutator::ConstFieldInstance, protobuf_mutator::ConstFieldInstance, int>(protobuf_mutator::ConstFieldInstance const&, protobuf_mutator::ConstFieldInstance const&, int const&) const mutator.cc:void protobuf_mutator::FieldFunction<protobuf_mutator::(anonymous namespace)::CreateDefaultField, void>::operator()<protobuf_mutator::FieldInstance>(protobuf_mutator::FieldInstance const&) const Line | Count | Source | 402 | 1.09k | R operator()(const Field& field, const Args&... args) const { | 403 | 1.09k | assert(field.descriptor()); | 404 | 0 | using protobuf::FieldDescriptor; | 405 | 1.09k | switch (field.cpp_type()) { | 406 | 0 | case FieldDescriptor::CPPTYPE_INT32: | 407 | 0 | return static_cast<const Fn*>(this)->template ForType<int32_t>(field, | 408 | 0 | args...); | 409 | 0 | case FieldDescriptor::CPPTYPE_INT64: | 410 | 0 | return static_cast<const Fn*>(this)->template ForType<int64_t>(field, | 411 | 0 | args...); | 412 | 0 | case FieldDescriptor::CPPTYPE_UINT32: | 413 | 0 | return static_cast<const Fn*>(this)->template ForType<uint32_t>( | 414 | 0 | field, args...); | 415 | 0 | case FieldDescriptor::CPPTYPE_UINT64: | 416 | 0 | return static_cast<const Fn*>(this)->template ForType<uint64_t>( | 417 | 0 | field, args...); | 418 | 0 | case FieldDescriptor::CPPTYPE_DOUBLE: | 419 | 0 | return static_cast<const Fn*>(this)->template ForType<double>(field, | 420 | 0 | args...); | 421 | 0 | case FieldDescriptor::CPPTYPE_FLOAT: | 422 | 0 | return static_cast<const Fn*>(this)->template ForType<float>(field, | 423 | 0 | args...); | 424 | 0 | case FieldDescriptor::CPPTYPE_BOOL: | 425 | 0 | return static_cast<const Fn*>(this)->template ForType<bool>(field, | 426 | 0 | args...); | 427 | 0 | case FieldDescriptor::CPPTYPE_ENUM: | 428 | 0 | return static_cast<const Fn*>(this) | 429 | 0 | ->template ForType<ConstFieldInstance::Enum>(field, args...); | 430 | 545 | case FieldDescriptor::CPPTYPE_STRING: | 431 | 545 | return static_cast<const Fn*>(this)->template ForType<std::string>( | 432 | 545 | field, args...); | 433 | 549 | case FieldDescriptor::CPPTYPE_MESSAGE: | 434 | 549 | return static_cast<const Fn*>(this) | 435 | 549 | ->template ForType<std::unique_ptr<protobuf::Message>>(field, | 436 | 549 | args...); | 437 | 1.09k | } | 438 | 0 | assert(false && "Unknown type"); | 439 | 0 | abort(); | 440 | 1.09k | } |
Unexecuted instantiation: mutator.cc:void protobuf_mutator::FieldFunction<protobuf_mutator::(anonymous namespace)::CreateField, void>::operator()<protobuf_mutator::FieldInstance, int, std::__1::vector<google::protobuf::Message const*, std::__1::allocator<google::protobuf::Message const*> >, protobuf_mutator::Mutator*>(protobuf_mutator::FieldInstance const&, int const&, std::__1::vector<google::protobuf::Message const*, std::__1::allocator<google::protobuf::Message const*> > const&, protobuf_mutator::Mutator* const&) const Unexecuted instantiation: mutator.cc:void protobuf_mutator::FieldFunction<protobuf_mutator::(anonymous namespace)::MutateField, void>::operator()<protobuf_mutator::FieldInstance, int, std::__1::vector<google::protobuf::Message const*, std::__1::allocator<google::protobuf::Message const*> >, protobuf_mutator::Mutator*>(protobuf_mutator::FieldInstance const&, int const&, std::__1::vector<google::protobuf::Message const*, std::__1::allocator<google::protobuf::Message const*> > const&, protobuf_mutator::Mutator* const&) const Unexecuted instantiation: mutator.cc:void protobuf_mutator::FieldFunction<protobuf_mutator::(anonymous namespace)::DeleteField, void>::operator()<protobuf_mutator::FieldInstance>(protobuf_mutator::FieldInstance const&) const Unexecuted instantiation: mutator.cc:void protobuf_mutator::FieldFunction<protobuf_mutator::(anonymous namespace)::CopyField, void>::operator()<protobuf_mutator::ConstFieldInstance, protobuf_mutator::FieldInstance>(protobuf_mutator::ConstFieldInstance const&, protobuf_mutator::FieldInstance const&) const |
441 | | }; |
442 | | |
443 | | } // namespace protobuf_mutator |
444 | | |
445 | | #endif // SRC_FIELD_INSTANCE_H_ |