Go to the documentation of this file.
47 using internal::WireFormatLite;
102 std::map<std::string, std::string>* variables,
109 if (fixed_size != -1) {
110 (*variables)[
"fixed_size"] =
StrCat(fixed_size);
114 (*variables)[
"full_name"] =
descriptor->full_name();
132 format(
"$type$ $name$_;\n");
139 "$deprecated_attr$$type$ ${1$$name$$}$() const;\n"
140 "$deprecated_attr$void ${1$set_$name$$}$($type$ value);\n",
148 "inline $type$ $classname$::$name$() const {\n"
149 " // @@protoc_insertion_point(field_get:$full_name$)\n"
152 "inline void $classname$::set_$name$($type$ value) {\n"
154 " $name$_ = value;\n"
155 " // @@protoc_insertion_point(field_set:$full_name$)\n"
161 format(
"$name$_ = $default$;\n");
166 format(
"set_$name$(from.$name$());\n");
171 format(
"swap($name$_, other->$name$_);\n");
177 format(
"$name$_ = $default$;\n");
183 format(
"$name$_ = from.$name$_;\n");
191 "DO_((::$proto_ns$::internal::WireFormatLite::ReadPrimitive<\n"
193 "::$proto_ns$::internal::WireFormatLite::$wire_format_field_type$>(\n"
194 " input, &$name$_)));\n");
201 "::$proto_ns$::internal::WireFormatLite::Write$declared_type$("
202 "$number$, this->$name$(), output);\n");
210 "::$proto_ns$::internal::WireFormatLite::Write$declared_type$ToArray("
211 "$number$, this->$name$(), target);\n");
217 if (fixed_size == -1) {
219 "total_size += $tag_size$ +\n"
220 " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
221 " this->$name$());\n");
223 format(
"total_size += $tag_size$ + $fixed_size$;\n");
241 "inline $type$ $classname$::$name$() const {\n"
242 " // @@protoc_insertion_point(field_get:$full_name$)\n"
243 " if (has_$name$()) {\n"
244 " return $field_member$;\n"
246 " return $default$;\n"
248 "inline void $classname$::set_$name$($type$ value) {\n"
249 " if (!has_$name$()) {\n"
250 " clear_$oneof_name$();\n"
251 " set_has_$name$();\n"
253 " $field_member$ = value;\n"
254 " // @@protoc_insertion_point(field_set:$full_name$)\n"
261 format(
"$field_member$ = $default$;\n");
272 format(
"$ns$::_$classname$_default_instance_.$name$_ = $default$;\n");
279 "clear_$oneof_name$();\n"
280 "DO_((::$proto_ns$::internal::WireFormatLite::ReadPrimitive<\n"
282 "::$proto_ns$::internal::WireFormatLite::$wire_format_field_type$>(\n"
283 " input, &$field_member$)));\n"
284 "set_has_$name$();\n");
295 variables_[
"packed_reader"] =
"ReadPackedPrimitive";
296 variables_[
"repeated_reader"] =
"ReadRepeatedPrimitiveNoInline";
298 variables_[
"packed_reader"] =
"ReadPackedPrimitiveNoInline";
299 variables_[
"repeated_reader"] =
"ReadRepeatedPrimitive";
308 format(
"::$proto_ns$::RepeatedField< $type$ > $name$_;\n");
311 format(
"mutable std::atomic<int> _$name$_cached_byte_size_;\n");
319 "$deprecated_attr$$type$ ${1$$name$$}$(int index) const;\n"
320 "$deprecated_attr$void ${1$set_$name$$}$(int index, $type$ value);\n"
321 "$deprecated_attr$void ${1$add_$name$$}$($type$ value);\n"
322 "$deprecated_attr$const ::$proto_ns$::RepeatedField< $type$ >&\n"
323 " ${1$$name$$}$() const;\n"
324 "$deprecated_attr$::$proto_ns$::RepeatedField< $type$ >*\n"
325 " ${1$mutable_$name$$}$();\n",
333 "inline $type$ $classname$::$name$(int index) const {\n"
334 " // @@protoc_insertion_point(field_get:$full_name$)\n"
335 " return $name$_.Get(index);\n"
337 "inline void $classname$::set_$name$(int index, $type$ value) {\n"
338 " $name$_.Set(index, value);\n"
339 " // @@protoc_insertion_point(field_set:$full_name$)\n"
341 "inline void $classname$::add_$name$($type$ value) {\n"
342 " $name$_.Add(value);\n"
343 " // @@protoc_insertion_point(field_add:$full_name$)\n"
345 "inline const ::$proto_ns$::RepeatedField< $type$ >&\n"
346 "$classname$::$name$() const {\n"
347 " // @@protoc_insertion_point(field_list:$full_name$)\n"
350 "inline ::$proto_ns$::RepeatedField< $type$ >*\n"
351 "$classname$::mutable_$name$() {\n"
352 " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
353 " return &$name$_;\n"
360 format(
"$name$_.Clear();\n");
366 format(
"$name$_.MergeFrom(from.$name$_);\n");
372 format(
"$name$_.InternalSwap(&other->$name$_);\n");
383 format(
"$name$_.CopyFrom(from.$name$_);\n");
390 "DO_((::$proto_ns$::internal::WireFormatLite::$repeated_reader$<\n"
392 "::$proto_ns$::internal::WireFormatLite::$wire_format_field_type$>(\n"
393 " $tag_size$, $tag$u, input, this->mutable_$name$())));\n");
400 "DO_((::$proto_ns$::internal::WireFormatLite::$packed_reader$<\n"
402 "::$proto_ns$::internal::WireFormatLite::$wire_format_field_type$>(\n"
403 " input, this->mutable_$name$())));\n");
409 bool array_written =
false;
413 "if (this->$name$_size() > 0) {\n"
414 " ::$proto_ns$::internal::WireFormatLite::WriteTag("
416 "::$proto_ns$::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, "
418 " output->WriteVarint32(_$name$_cached_byte_size_.load(\n"
419 " std::memory_order_relaxed));\n");
427 "::$proto_ns$::internal::WireFormatLite::Write$declared_type$Array(\n"
428 " this->$name$().data(), this->$name$_size(), output);\n");
429 array_written =
true;
433 if (!array_written) {
434 format(
"for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
438 "::$proto_ns$::internal::WireFormatLite::Write$declared_type$NoTag(\n"
439 " this->$name$(i), output);\n");
442 " ::$proto_ns$::internal::WireFormatLite::Write$declared_type$(\n"
443 " $number$, this->$name$(i), output);\n");
455 "if (this->$name$_size() > 0) {\n"
456 " target = ::$proto_ns$::internal::WireFormatLite::WriteTagToArray(\n"
459 "::$proto_ns$::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
462 "::$proto_ns$::io::CodedOutputStream::WriteVarint32ToArray(\n"
463 " _$name$_cached_byte_size_.load(std::memory_order_relaxed),\n"
465 " target = ::$proto_ns$::internal::WireFormatLite::\n"
466 " Write$declared_type$NoTagToArray(this->$name$_, target);\n"
470 "target = ::$proto_ns$::internal::WireFormatLite::\n"
471 " Write$declared_type$ToArray($number$, this->$name$_, target);\n");
481 if (fixed_size == -1) {
483 "size_t data_size = ::$proto_ns$::internal::WireFormatLite::\n"
484 " $declared_type$Size(this->$name$_);\n");
487 "unsigned int count = static_cast<unsigned int>(this->$name$_size());\n"
488 "size_t data_size = $fixed_size$UL * count;\n");
493 "if (data_size > 0) {\n"
494 " total_size += $tag_size$ +\n"
495 " ::$proto_ns$::internal::WireFormatLite::Int32Size(\n"
496 " static_cast<$int32$>(data_size));\n"
498 "int cached_size = ::$proto_ns$::internal::ToCachedSize(data_size);\n"
499 "_$name$_cached_byte_size_.store(cached_size,\n"
500 " std::memory_order_relaxed);\n"
501 "total_size += data_size;\n");
504 "total_size += $tag_size$ *\n"
506 "::$proto_ns$::internal::FromIntSize(this->$name$_size());\n"
507 "total_size += data_size;\n");
bool HasGeneratedMethods(const FileDescriptor *file, const Options &options)
void GenerateCopyConstructorCode(io::Printer *printer) const
void GenerateSwappingCode(io::Printer *printer) const
PrimitiveOneofFieldGenerator(const FieldDescriptor *descriptor, const Options &options)
void GenerateMergeFromCodedStream(io::Printer *printer) const
string StrCat(const AlphaNum &a, const AlphaNum &b)
void GenerateConstructorCode(io::Printer *printer) const
void GenerateSerializeWithCachedSizesToArray(io::Printer *printer) const
void SetCommonFieldVariables(const FieldDescriptor *descriptor, std::map< std::string, std::string > *variables, const Options &options)
~PrimitiveFieldGenerator()
void GenerateByteSize(io::Printer *printer) const
void GenerateSwappingCode(io::Printer *printer) const
void GenerateSerializeWithCachedSizes(io::Printer *printer) const
FieldDescriptorProto_Type
const FieldDescriptor * descriptor_
void GenerateInlineAccessorDefinitions(io::Printer *printer) const
std::map< std::string, std::string > variables_
void GenerateSwappingCode(io::Printer *printer) const
void GenerateClearingCode(io::Printer *printer) const
const FileDescriptor * file() const
void GeneratePrivateMembers(io::Printer *printer) const
void GenerateSerializeWithCachedSizes(io::Printer *printer) const
GLint GLint GLsizei GLint GLenum format
void GenerateClearingCode(io::Printer *printer) const
void GenerateAccessorDeclarations(io::Printer *printer) const
#define GOOGLE_LOG(LEVEL)
void GenerateSerializeWithCachedSizesToArray(io::Printer *printer) const
std::string DefaultValue(const FieldDescriptor *field)
int FixedSize(FieldDescriptor::Type type)
void GenerateMergeFromCodedStream(io::Printer *printer) const
PrimitiveFieldGenerator(const FieldDescriptor *descriptor, const Options &options)
RepeatedPrimitiveFieldGenerator(const FieldDescriptor *descriptor, const Options &options)
void GenerateConstructorCode(io::Printer *printer) const
~RepeatedPrimitiveFieldGenerator()
void GenerateMergeFromCodedStream(io::Printer *printer) const
void GenerateInlineAccessorDefinitions(io::Printer *printer) const
void GenerateAccessorDeclarations(io::Printer *printer) const
const char * PrimitiveTypeName(FieldDescriptor::CppType type)
void GenerateInlineAccessorDefinitions(io::Printer *printer) const
void GenerateMergingCode(io::Printer *printer) const
void GenerateByteSize(io::Printer *printer) const
void GenerateMergeFromCodedStreamWithPacking(io::Printer *printer) const
void GenerateCopyConstructorCode(io::Printer *printer) const
const std::string & FieldDescriptorProto_Type_Name(T enum_t_value)
void GenerateConstructorCode(io::Printer *printer) const
void GenerateMergingCode(io::Printer *printer) const
void GenerateClearingCode(io::Printer *printer) const
~PrimitiveOneofFieldGenerator()
void GeneratePrivateMembers(io::Printer *printer) const
void SetCommonOneofFieldVariables(const FieldDescriptor *descriptor, std::map< std::string, std::string > *variables)
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:49