Apologies if this has been asked before, but I'm running into an issue
trying to compile the protocol buffer from the tutorial:
https://developers.google.com/protocol-buffers/docs/cpptutorial
I followed the make/make install / etc. instructions in src/README.md, then
ran (in the directory):
protoc --cpp_out=out examples/addressbook.proto
(I didn't specify -I because I was running from the current directory,
which contained *examples*.)
The tutorial indicates that I should see the following code in the
resulting addressbook.pb.h:
// name
inline bool has_name() const;
inline void clear_name();
inline const ::std::string& name() const;
inline void set_name(const ::std::string& value);
inline void set_name(const char* value);
inline ::std::string* mutable_name();
But I don't see anything like that in the file I generated (see attached).
I'm not sure exactly what I'm doing wrong. Is there something obvious, or
somewhere I should look to find out more?
Thank you! And please let me know if you need more information.
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/7602ec37-6eba-4e26-ae55-20157169b2c0%40googlegroups.com.
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: examples/addressbook.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_examples_2faddressbook_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_examples_2faddressbook_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/timestamp.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_examples_2faddressbook_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_examples_2faddressbook_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_examples_2faddressbook_2eproto;
namespace tutorial {
class AddressBook;
class AddressBookDefaultTypeInternal;
extern AddressBookDefaultTypeInternal _AddressBook_default_instance_;
class Person;
class PersonDefaultTypeInternal;
extern PersonDefaultTypeInternal _Person_default_instance_;
class Person_PhoneNumber;
class Person_PhoneNumberDefaultTypeInternal;
extern Person_PhoneNumberDefaultTypeInternal _Person_PhoneNumber_default_instance_;
} // namespace tutorial
PROTOBUF_NAMESPACE_OPEN
template<> ::tutorial::AddressBook* Arena::CreateMaybeMessage<::tutorial::AddressBook>(Arena*);
template<> ::tutorial::Person* Arena::CreateMaybeMessage<::tutorial::Person>(Arena*);
template<> ::tutorial::Person_PhoneNumber* Arena::CreateMaybeMessage<::tutorial::Person_PhoneNumber>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace tutorial {
enum Person_PhoneType : int {
Person_PhoneType_MOBILE = 0,
Person_PhoneType_HOME = 1,
Person_PhoneType_WORK = 2,
Person_PhoneType_Person_PhoneType_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::PROTOBUF_NAMESPACE_ID::int32>::min(),
Person_PhoneType_Person_PhoneType_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::PROTOBUF_NAMESPACE_ID::int32>::max()
bool Person_PhoneType_IsValid(int value);
constexpr Person_PhoneType Person_PhoneType_PhoneType_MIN = Person_PhoneType_MOBILE;
constexpr Person_PhoneType Person_PhoneType_PhoneType_MAX = Person_PhoneType_WORK;
constexpr int Person_PhoneType_PhoneType_ARRAYSIZE = Person_PhoneType_PhoneType_MAX + 1;
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Person_PhoneType_descriptor();
template<typename T>
inline const std::string& Person_PhoneType_Name(T enum_t_value) {
static_assert(::std::is_same<T, Person_PhoneType>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function Person_PhoneType_Name.");
return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
Person_PhoneType_descriptor(), enum_t_value);
inline bool Person_PhoneType_Parse(
const std::string& name, Person_PhoneType* value) {
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<Person_PhoneType>(
Person_PhoneType_descriptor(), name, value);
// ===================================================================
class Person_PhoneNumber :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:tutorial.Person.PhoneNumber) */ {
public:
Person_PhoneNumber();
virtual ~Person_PhoneNumber();
Person_PhoneNumber(const Person_PhoneNumber& from);
Person_PhoneNumber(Person_PhoneNumber&& from) noexcept
: Person_PhoneNumber() {
*this = ::std::move(from);
inline Person_PhoneNumber& operator=(const Person_PhoneNumber& from) {
CopyFrom(from);
return *this;
inline Person_PhoneNumber& operator=(Person_PhoneNumber&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
return *this;
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
static const Person_PhoneNumber& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Person_PhoneNumber* internal_default_instance() {
return reinterpret_cast<const Person_PhoneNumber*>(
&_Person_PhoneNumber_default_instance_);
static constexpr int kIndexInFileMessages =
friend void swap(Person_PhoneNumber& a, Person_PhoneNumber& b) {
a.Swap(&b);
inline void Swap(Person_PhoneNumber* other) {
if (other == this) return;
InternalSwap(other);
// implements Message ----------------------------------------------
inline Person_PhoneNumber* New() const final {
return CreateMaybeMessage<Person_PhoneNumber>(nullptr);
Person_PhoneNumber* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<Person_PhoneNumber>(arena);
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const Person_PhoneNumber& from);
void MergeFrom(const Person_PhoneNumber& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
#else
bool MergePartialFromCodedStream(
::PROTOBUF_NAMESPACE_ID::io::CodedInputStream* input) final;
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void SerializeWithCachedSizes(
::PROTOBUF_NAMESPACE_ID::io::CodedOutputStream* output) const final;
::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Person_PhoneNumber* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "tutorial.Person.PhoneNumber";
private:
inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const {
return nullptr;
inline void* MaybeArenaPtr() const {
return nullptr;
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_examples_2faddressbook_2eproto);
return ::descriptor_table_examples_2faddressbook_2eproto.file_level_metadata[kIndexInFileMessages];
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kNumberFieldNumber = 1,
kTypeFieldNumber = 2,
// string number = 1;
void clear_number();
const std::string& number() const;
void set_number(const std::string& value);
void set_number(std::string&& value);
void set_number(const char* value);
void set_number(const char* value, size_t size);
std::string* mutable_number();
std::string* release_number();
void set_allocated_number(std::string* number);
// .tutorial.Person.PhoneType type = 2;
void clear_type();
::tutorial::Person_PhoneType type() const;
void set_type(::tutorial::Person_PhoneType value);
// @@protoc_insertion_point(class_scope:tutorial.Person.PhoneNumber)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr number_;
int type_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_examples_2faddressbook_2eproto;
// -------------------------------------------------------------------
class Person :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:tutorial.Person) */ {
public:
Person();
virtual ~Person();
Person(const Person& from);
Person(Person&& from) noexcept
: Person() {
*this = ::std::move(from);
inline Person& operator=(const Person& from) {
CopyFrom(from);
return *this;
inline Person& operator=(Person&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
return *this;
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
static const Person& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const Person* internal_default_instance() {
return reinterpret_cast<const Person*>(
&_Person_default_instance_);
static constexpr int kIndexInFileMessages =
friend void swap(Person& a, Person& b) {
a.Swap(&b);
inline void Swap(Person* other) {
if (other == this) return;
InternalSwap(other);
// implements Message ----------------------------------------------
inline Person* New() const final {
return CreateMaybeMessage<Person>(nullptr);
Person* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<Person>(arena);
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const Person& from);
void MergeFrom(const Person& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
#else
bool MergePartialFromCodedStream(
::PROTOBUF_NAMESPACE_ID::io::CodedInputStream* input) final;
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void SerializeWithCachedSizes(
::PROTOBUF_NAMESPACE_ID::io::CodedOutputStream* output) const final;
::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(Person* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "tutorial.Person";
private:
inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const {
return nullptr;
inline void* MaybeArenaPtr() const {
return nullptr;
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_examples_2faddressbook_2eproto);
return ::descriptor_table_examples_2faddressbook_2eproto.file_level_metadata[kIndexInFileMessages];
public:
// nested types ----------------------------------------------------
typedef Person_PhoneNumber PhoneNumber;
typedef Person_PhoneType PhoneType;
static constexpr PhoneType MOBILE =
Person_PhoneType_MOBILE;
static constexpr PhoneType HOME =
Person_PhoneType_HOME;
static constexpr PhoneType WORK =
Person_PhoneType_WORK;
static inline bool PhoneType_IsValid(int value) {
return Person_PhoneType_IsValid(value);
static constexpr PhoneType PhoneType_MIN =
Person_PhoneType_PhoneType_MIN;
static constexpr PhoneType PhoneType_MAX =
Person_PhoneType_PhoneType_MAX;
static constexpr int PhoneType_ARRAYSIZE =
Person_PhoneType_PhoneType_ARRAYSIZE;
static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor*
PhoneType_descriptor() {
return Person_PhoneType_descriptor();
template<typename T>
static inline const std::string& PhoneType_Name(T enum_t_value) {
static_assert(::std::is_same<T, PhoneType>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function PhoneType_Name.");
return Person_PhoneType_Name(enum_t_value);
static inline bool PhoneType_Parse(const std::string& name,
PhoneType* value) {
return Person_PhoneType_Parse(name, value);
// accessors -------------------------------------------------------
enum : int {
kPhonesFieldNumber = 4,
kNameFieldNumber = 1,
kEmailFieldNumber = 3,
kLastUpdatedFieldNumber = 5,
kIdFieldNumber = 2,
// repeated .tutorial.Person.PhoneNumber phones = 4;
int phones_size() const;
void clear_phones();
::tutorial::Person_PhoneNumber* mutable_phones(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person_PhoneNumber >*
mutable_phones();
const ::tutorial::Person_PhoneNumber& phones(int index) const;
::tutorial::Person_PhoneNumber* add_phones();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person_PhoneNumber >&
phones() const;
// string name = 1;
void clear_name();
const std::string& name() const;
void set_name(const std::string& value);
void set_name(std::string&& value);
void set_name(const char* value);
void set_name(const char* value, size_t size);
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
// string email = 3;
void clear_email();
const std::string& email() const;
void set_email(const std::string& value);
void set_email(std::string&& value);
void set_email(const char* value);
void set_email(const char* value, size_t size);
std::string* mutable_email();
std::string* release_email();
void set_allocated_email(std::string* email);
// .google.protobuf.Timestamp last_updated = 5;
bool has_last_updated() const;
void clear_last_updated();
const PROTOBUF_NAMESPACE_ID::Timestamp& last_updated() const;
PROTOBUF_NAMESPACE_ID::Timestamp* release_last_updated();
PROTOBUF_NAMESPACE_ID::Timestamp* mutable_last_updated();
void set_allocated_last_updated(PROTOBUF_NAMESPACE_ID::Timestamp* last_updated);
// int32 id = 2;
void clear_id();
::PROTOBUF_NAMESPACE_ID::int32 id() const;
void set_id(::PROTOBUF_NAMESPACE_ID::int32 value);
// @@protoc_insertion_point(class_scope:tutorial.Person)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person_PhoneNumber > phones_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr email_;
PROTOBUF_NAMESPACE_ID::Timestamp* last_updated_;
::PROTOBUF_NAMESPACE_ID::int32 id_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_examples_2faddressbook_2eproto;
// -------------------------------------------------------------------
class AddressBook :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:tutorial.AddressBook) */ {
public:
AddressBook();
virtual ~AddressBook();
AddressBook(const AddressBook& from);
AddressBook(AddressBook&& from) noexcept
: AddressBook() {
*this = ::std::move(from);
inline AddressBook& operator=(const AddressBook& from) {
CopyFrom(from);
return *this;
inline AddressBook& operator=(AddressBook&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
return *this;
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return GetMetadataStatic().descriptor;
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return GetMetadataStatic().reflection;
static const AddressBook& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const AddressBook* internal_default_instance() {
return reinterpret_cast<const AddressBook*>(
&_AddressBook_default_instance_);
static constexpr int kIndexInFileMessages =
friend void swap(AddressBook& a, AddressBook& b) {
a.Swap(&b);
inline void Swap(AddressBook* other) {
if (other == this) return;
InternalSwap(other);
// implements Message ----------------------------------------------
inline AddressBook* New() const final {
return CreateMaybeMessage<AddressBook>(nullptr);
AddressBook* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<AddressBook>(arena);
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final;
void CopyFrom(const AddressBook& from);
void MergeFrom(const AddressBook& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
#else
bool MergePartialFromCodedStream(
::PROTOBUF_NAMESPACE_ID::io::CodedInputStream* input) final;
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void SerializeWithCachedSizes(
::PROTOBUF_NAMESPACE_ID::io::CodedOutputStream* output) const final;
::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
inline void SharedCtor();
inline void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(AddressBook* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "tutorial.AddressBook";
private:
inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const {
return nullptr;
inline void* MaybeArenaPtr() const {
return nullptr;
public:
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
private:
static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_examples_2faddressbook_2eproto);
return ::descriptor_table_examples_2faddressbook_2eproto.file_level_metadata[kIndexInFileMessages];
public:
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kPeopleFieldNumber = 1,
// repeated .tutorial.Person people = 1;
int people_size() const;
void clear_people();
::tutorial::Person* mutable_people(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person >*
mutable_people();
const ::tutorial::Person& people(int index) const;
::tutorial::Person* add_people();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person >&
people() const;
// @@protoc_insertion_point(class_scope:tutorial.AddressBook)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person > people_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_examples_2faddressbook_2eproto;
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// Person_PhoneNumber
// string number = 1;
inline void Person_PhoneNumber::clear_number() {
number_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline const std::string& Person_PhoneNumber::number() const {
// @@protoc_insertion_point(field_get:tutorial.Person.PhoneNumber.number)
return number_.GetNoArena();
inline void Person_PhoneNumber::set_number(const std::string& value) {
number_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:tutorial.Person.PhoneNumber.number)
inline void Person_PhoneNumber::set_number(std::string&& value) {
number_.SetNoArena(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:tutorial.Person.PhoneNumber.number)
inline void Person_PhoneNumber::set_number(const char* value) {
GOOGLE_DCHECK(value != nullptr);
number_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:tutorial.Person.PhoneNumber.number)
inline void Person_PhoneNumber::set_number(const char* value, size_t size) {
number_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:tutorial.Person.PhoneNumber.number)
inline std::string* Person_PhoneNumber::mutable_number() {
// @@protoc_insertion_point(field_mutable:tutorial.Person.PhoneNumber.number)
return number_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline std::string* Person_PhoneNumber::release_number() {
// @@protoc_insertion_point(field_release:tutorial.Person.PhoneNumber.number)
return number_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline void Person_PhoneNumber::set_allocated_number(std::string* number) {
if (number != nullptr) {
} else {
number_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), number);
// @@protoc_insertion_point(field_set_allocated:tutorial.Person.PhoneNumber.number)
// .tutorial.Person.PhoneType type = 2;
inline void Person_PhoneNumber::clear_type() {
type_ = 0;
inline ::tutorial::Person_PhoneType Person_PhoneNumber::type() const {
// @@protoc_insertion_point(field_get:tutorial.Person.PhoneNumber.type)
return static_cast< ::tutorial::Person_PhoneType >(type_);
inline void Person_PhoneNumber::set_type(::tutorial::Person_PhoneType value) {
type_ = value;
// @@protoc_insertion_point(field_set:tutorial.Person.PhoneNumber.type)
// -------------------------------------------------------------------
// Person
// string name = 1;
inline void Person::clear_name() {
name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline const std::string& Person::name() const {
// @@protoc_insertion_point(field_get:tutorial.Person.name)
return name_.GetNoArena();
inline void Person::set_name(const std::string& value) {
name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:tutorial.Person.name)
inline void Person::set_name(std::string&& value) {
name_.SetNoArena(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:tutorial.Person.name)
inline void Person::set_name(const char* value) {
GOOGLE_DCHECK(value != nullptr);
name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:tutorial.Person.name)
inline void Person::set_name(const char* value, size_t size) {
name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:tutorial.Person.name)
inline std::string* Person::mutable_name() {
// @@protoc_insertion_point(field_mutable:tutorial.Person.name)
return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline std::string* Person::release_name() {
// @@protoc_insertion_point(field_release:tutorial.Person.name)
return name_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline void Person::set_allocated_name(std::string* name) {
if (name != nullptr) {
} else {
name_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:tutorial.Person.name)
// int32 id = 2;
inline void Person::clear_id() {
id_ = 0;
inline ::PROTOBUF_NAMESPACE_ID::int32 Person::id() const {
// @@protoc_insertion_point(field_get:tutorial.Person.id)
return id_;
inline void Person::set_id(::PROTOBUF_NAMESPACE_ID::int32 value) {
id_ = value;
// @@protoc_insertion_point(field_set:tutorial.Person.id)
// string email = 3;
inline void Person::clear_email() {
email_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline const std::string& Person::email() const {
// @@protoc_insertion_point(field_get:tutorial.Person.email)
return email_.GetNoArena();
inline void Person::set_email(const std::string& value) {
email_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:tutorial.Person.email)
inline void Person::set_email(std::string&& value) {
email_.SetNoArena(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:tutorial.Person.email)
inline void Person::set_email(const char* value) {
GOOGLE_DCHECK(value != nullptr);
email_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:tutorial.Person.email)
inline void Person::set_email(const char* value, size_t size) {
email_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:tutorial.Person.email)
inline std::string* Person::mutable_email() {
// @@protoc_insertion_point(field_mutable:tutorial.Person.email)
return email_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline std::string* Person::release_email() {
// @@protoc_insertion_point(field_release:tutorial.Person.email)
return email_.ReleaseNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
inline void Person::set_allocated_email(std::string* email) {
if (email != nullptr) {
} else {
email_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), email);
// @@protoc_insertion_point(field_set_allocated:tutorial.Person.email)
// repeated .tutorial.Person.PhoneNumber phones = 4;
inline int Person::phones_size() const {
return phones_.size();
inline void Person::clear_phones() {
phones_.Clear();
inline ::tutorial::Person_PhoneNumber* Person::mutable_phones(int index) {
// @@protoc_insertion_point(field_mutable:tutorial.Person.phones)
return phones_.Mutable(index);
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person_PhoneNumber >*
Person::mutable_phones() {
// @@protoc_insertion_point(field_mutable_list:tutorial.Person.phones)
return &phones_;
inline const ::tutorial::Person_PhoneNumber& Person::phones(int index) const {
// @@protoc_insertion_point(field_get:tutorial.Person.phones)
return phones_.Get(index);
inline ::tutorial::Person_PhoneNumber* Person::add_phones() {
// @@protoc_insertion_point(field_add:tutorial.Person.phones)
return phones_.Add();
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person_PhoneNumber >&
Person::phones() const {
// @@protoc_insertion_point(field_list:tutorial.Person.phones)
return phones_;
// .google.protobuf.Timestamp last_updated = 5;
inline bool Person::has_last_updated() const {
return this != internal_default_instance() && last_updated_ != nullptr;
inline const PROTOBUF_NAMESPACE_ID::Timestamp& Person::last_updated() const {
const PROTOBUF_NAMESPACE_ID::Timestamp* p = last_updated_;
// @@protoc_insertion_point(field_get:tutorial.Person.last_updated)
return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::Timestamp*>(
&PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_);
inline PROTOBUF_NAMESPACE_ID::Timestamp* Person::release_last_updated() {
// @@protoc_insertion_point(field_release:tutorial.Person.last_updated)
PROTOBUF_NAMESPACE_ID::Timestamp* temp = last_updated_;
last_updated_ = nullptr;
return temp;
inline PROTOBUF_NAMESPACE_ID::Timestamp* Person::mutable_last_updated() {
if (last_updated_ == nullptr) {
auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::Timestamp>(GetArenaNoVirtual());
last_updated_ = p;
// @@protoc_insertion_point(field_mutable:tutorial.Person.last_updated)
return last_updated_;
inline void Person::set_allocated_last_updated(PROTOBUF_NAMESPACE_ID::Timestamp* last_updated) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(last_updated_);
if (last_updated) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(last_updated)->GetArena();
if (message_arena != submessage_arena) {
last_updated = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, last_updated, submessage_arena);
} else {
last_updated_ = last_updated;
// @@protoc_insertion_point(field_set_allocated:tutorial.Person.last_updated)
// -------------------------------------------------------------------
// AddressBook
// repeated .tutorial.Person people = 1;
inline int AddressBook::people_size() const {
return people_.size();
inline void AddressBook::clear_people() {
people_.Clear();
inline ::tutorial::Person* AddressBook::mutable_people(int index) {
// @@protoc_insertion_point(field_mutable:tutorial.AddressBook.people)
return people_.Mutable(index);
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person >*
AddressBook::mutable_people() {
// @@protoc_insertion_point(field_mutable_list:tutorial.AddressBook.people)
return &people_;
inline const ::tutorial::Person& AddressBook::people(int index) const {
// @@protoc_insertion_point(field_get:tutorial.AddressBook.people)
return people_.Get(index);
inline ::tutorial::Person* AddressBook::add_people() {
// @@protoc_insertion_point(field_add:tutorial.AddressBook.people)
return people_.Add();
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::tutorial::Person >&
AddressBook::people() const {
// @@protoc_insertion_point(field_list:tutorial.AddressBook.people)
return people_;
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// @@protoc_insertion_point(namespace_scope)
} // namespace tutorial
PROTOBUF_NAMESPACE_OPEN
template <> struct is_proto_enum< ::tutorial::Person_PhoneType> : ::std::true_type {};
template <>
inline const EnumDescriptor* GetEnumDescriptor< ::tutorial::Person_PhoneType>() {
return ::tutorial::Person_PhoneType_descriptor();
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_examples_2faddressbook_2eproto