Hi I tried to compile a simple code as example of protobuf. But I used to have the following error messages. Codes are attached. Could you help me correct these bugs ? Thanks
/usr/bin/ld: /tmp/ccdiZiDW.o: in function `main': ex1.cc:(.text+0x142): undefined reference to `tutorial::SearchRequest::~SearchRequest()' /usr/bin/ld: ex1.cc:(.text+0x16b): undefined reference to `tutorial::SearchRequest::~SearchRequest()' /usr/bin/ld: /tmp/ccdiZiDW.o: in function `google::protobuf::internal::ArenaStringPtr::Set(char const*, google::protobuf::Arena*)': ex1.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr3SetEPKcPNS0_5ArenaE[_ZN6google8protobuf8internal14ArenaStringPtr3SetEPKcPNS0_5ArenaE]+0x4e): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(absl::lts_20230125::string_view, google::protobuf::Arena*)' /usr/bin/ld: /tmp/ccdiZiDW.o: in function `tutorial::SearchRequest::SearchRequest()': ex1.cc:(.text._ZN8tutorial13SearchRequestC2Ev[_ZN8tutorial13SearchRequestC5Ev]+0x1d): undefined reference to `tutorial::SearchRequest::SearchRequest(google::protobuf::Arena*)' collect2: error: ld returned 1 exit status -- 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/79041063-f686-4819-a52e-ca211557eef0n%40googlegroups.com.
#include<iostream>
#include<string>
#include"proto_ex1.pb.h"
using namespace std;
int main(){
tutorial::SearchRequest p;
p.set_queary("seongjoon");
p.set_page_number(100);
p.set_results_per_page(20);
cout<<"\n name is : " << p.queary();
cout<<"\n pagenumber is : " << p.page_number();
cout<<"\n results per page is: " << p.results_per_page();
cout<<"hello world"<<endl;
}
proto_ex1.proto
Description: Binary data
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto_ex1.proto
#include "proto_ex1.pb.h"
#include <algorithm>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
#include "google/protobuf/reflection_ops.h"
#include "google/protobuf/wire_format.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal;
namespace tutorial {
template <typename>
PROTOBUF_CONSTEXPR SearchRequest::SearchRequest(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{}
, /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_.queary_)*/ {
&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized {}
}
, /*decltype(_impl_.page_number_)*/ 0
, /*decltype(_impl_.results_per_page_)*/ 0
} {}
struct SearchRequestDefaultTypeInternal {
PROTOBUF_CONSTEXPR SearchRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
~SearchRequestDefaultTypeInternal() {}
union {
SearchRequest _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SearchRequestDefaultTypeInternal _SearchRequest_default_instance_;
} // namespace tutorial
static ::_pb::Metadata file_level_metadata_proto_5fex1_2eproto[1];
static constexpr const ::_pb::EnumDescriptor**
file_level_enum_descriptors_proto_5fex1_2eproto = nullptr;
static constexpr const ::_pb::ServiceDescriptor**
file_level_service_descriptors_proto_5fex1_2eproto = nullptr;
const ::uint32_t TableStruct_proto_5fex1_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::tutorial::SearchRequest, _impl_._has_bits_),
PROTOBUF_FIELD_OFFSET(::tutorial::SearchRequest, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_
~0u, // no _split_
~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::tutorial::SearchRequest, _impl_.queary_),
PROTOBUF_FIELD_OFFSET(::tutorial::SearchRequest, _impl_.page_number_),
PROTOBUF_FIELD_OFFSET(::tutorial::SearchRequest, _impl_.results_per_page_),
0,
1,
2,
};
static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 11, -1, sizeof(::tutorial::SearchRequest)},
};
static const ::_pb::Message* const file_default_instances[] = {
&::tutorial::_SearchRequest_default_instance_._instance,
};
const char descriptor_table_protodef_proto_5fex1_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
"\n\017proto_ex1.proto\022\010tutorial\"\215\001\n\rSearchRe"
"quest\022\023\n\006queary\030\001 \001(\tH\000\210\001\001\022\030\n\013page_numbe"
"r\030\002 \001(\005H\001\210\001\001\022\035\n\020results_per_page\030\003 \001(\005H\002"
"\210\001\001B\t\n\007_quearyB\016\n\014_page_numberB\023\n\021_resul"
"ts_per_pageb\006proto3"
};
static ::absl::once_flag descriptor_table_proto_5fex1_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_proto_5fex1_2eproto = {
false,
false,
179,
descriptor_table_protodef_proto_5fex1_2eproto,
"proto_ex1.proto",
&descriptor_table_proto_5fex1_2eproto_once,
nullptr,
0,
1,
schemas,
file_default_instances,
TableStruct_proto_5fex1_2eproto::offsets,
file_level_metadata_proto_5fex1_2eproto,
file_level_enum_descriptors_proto_5fex1_2eproto,
file_level_service_descriptors_proto_5fex1_2eproto,
};
// This function exists to be marked as weak.
// It can significantly speed up compilation by breaking up LLVM's SCC
// in the .pb.cc translation units. Large translation units see a
// reduction of more than 35% of walltime for optimized builds. Without
// the weak attribute all the messages in the file, including all the
// vtables and everything they use become part of the same SCC through
// a cycle like:
// GetMetadata -> descriptor table -> default instances ->
// vtables -> GetMetadata
// By adding a weak function here we break the connection from the
// individual vtables back into the descriptor table.
PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_proto_5fex1_2eproto_getter() {
return &descriptor_table_proto_5fex1_2eproto;
}
// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_proto_5fex1_2eproto(&descriptor_table_proto_5fex1_2eproto);
namespace tutorial {
// ===================================================================
class SearchRequest::_Internal {
public:
using HasBits = decltype(std::declval<SearchRequest>()._impl_._has_bits_);
static constexpr ::int32_t kHasBitsOffset =
8 * PROTOBUF_FIELD_OFFSET(SearchRequest, _impl_._has_bits_);
static void set_has_queary(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_page_number(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
static void set_has_results_per_page(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
};
SearchRequest::SearchRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) {
SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:tutorial.SearchRequest)
}
SearchRequest::SearchRequest(const SearchRequest& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
SearchRequest* const _this = this; (void)_this;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.queary_) {}
, decltype(_impl_.page_number_) {}
, decltype(_impl_.results_per_page_) {}
};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.queary_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.queary_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_impl_.queary_.Set(from._internal_queary(), _this->GetArenaForAllocation());
}
::memcpy(&_impl_.page_number_, &from._impl_.page_number_,
static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.results_per_page_) -
reinterpret_cast<char*>(&_impl_.page_number_)) + sizeof(_impl_.results_per_page_));
// @@protoc_insertion_point(copy_constructor:tutorial.SearchRequest)
}
inline void SearchRequest::SharedCtor(::_pb::Arena* arena) {
(void)arena;
new (&_impl_) Impl_{
decltype(_impl_._has_bits_){}
, /*decltype(_impl_._cached_size_)*/{}
, decltype(_impl_.queary_) {}
, decltype(_impl_.page_number_) { 0 }
, decltype(_impl_.results_per_page_) { 0 }
};
_impl_.queary_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.queary_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
SearchRequest::~SearchRequest() {
// @@protoc_insertion_point(destructor:tutorial.SearchRequest)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
(void)arena;
return;
}
SharedDtor();
}
inline void SearchRequest::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.queary_.Destroy();
}
void SearchRequest::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size);
}
void SearchRequest::Clear() {
// @@protoc_insertion_point(message_clear_start:tutorial.SearchRequest)
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) {
_impl_.queary_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000006u) {
::memset(&_impl_.page_number_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.results_per_page_) -
reinterpret_cast<char*>(&_impl_.page_number_)) + sizeof(_impl_.results_per_page_));
}
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* SearchRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::uint32_t tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional string queary = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_queary();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "tutorial.SearchRequest.queary"));
} else {
goto handle_unusual;
}
continue;
// optional int32 page_number = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) {
_Internal::set_has_page_number(&has_bits);
_impl_.page_number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else {
goto handle_unusual;
}
continue;
// optional int32 results_per_page = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_Internal::set_has_results_per_page(&has_bits);
_impl_.results_per_page_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else {
goto handle_unusual;
}
continue;
default:
goto handle_unusual;
} // switch
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto message_done;
}
ptr = UnknownFieldParse(
tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
} // while
message_done:
_impl_._has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto message_done;
#undef CHK_
}
::uint8_t* SearchRequest::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:tutorial.SearchRequest)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
// optional string queary = 1;
if (cached_has_bits & 0x00000001u) {
const std::string& _s = this->_internal_queary();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "tutorial.SearchRequest.queary");
target = stream->WriteStringMaybeAliased(1, _s, target);
}
// optional int32 page_number = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteInt32ToArray(
2, this->_internal_page_number(), target);
}
// optional int32 results_per_page = 3;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteInt32ToArray(
3, this->_internal_results_per_page(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:tutorial.SearchRequest)
return target;
}
::size_t SearchRequest::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:tutorial.SearchRequest)
::size_t total_size = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000007u) {
// optional string queary = 1;
if (cached_has_bits & 0x00000001u) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_queary());
}
// optional int32 page_number = 2;
if (cached_has_bits & 0x00000002u) {
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
this->_internal_page_number());
}
// optional int32 results_per_page = 3;
if (cached_has_bits & 0x00000004u) {
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
this->_internal_results_per_page());
}
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SearchRequest::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
SearchRequest::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SearchRequest::GetClassData() const { return &_class_data_; }
void SearchRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<SearchRequest*>(&to_msg);
auto& from = static_cast<const SearchRequest&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:tutorial.SearchRequest)
ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._impl_._has_bits_[0];
if (cached_has_bits & 0x00000007u) {
if (cached_has_bits & 0x00000001u) {
_this->_internal_set_queary(from._internal_queary());
}
if (cached_has_bits & 0x00000002u) {
_this->_impl_.page_number_ = from._impl_.page_number_;
}
if (cached_has_bits & 0x00000004u) {
_this->_impl_.results_per_page_ = from._impl_.results_per_page_;
}
_this->_impl_._has_bits_[0] |= cached_has_bits;
}
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
void SearchRequest::CopyFrom(const SearchRequest& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:tutorial.SearchRequest)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool SearchRequest::IsInitialized() const {
return true;
}
void SearchRequest::InternalSwap(SearchRequest* other) {
using std::swap;
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.queary_, lhs_arena,
&other->_impl_.queary_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(SearchRequest, _impl_.results_per_page_)
+ sizeof(SearchRequest::_impl_.results_per_page_)
- PROTOBUF_FIELD_OFFSET(SearchRequest, _impl_.page_number_)>(
reinterpret_cast<char*>(&_impl_.page_number_),
reinterpret_cast<char*>(&other->_impl_.page_number_));
}
::PROTOBUF_NAMESPACE_ID::Metadata SearchRequest::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_proto_5fex1_2eproto_getter, &descriptor_table_proto_5fex1_2eproto_once,
file_level_metadata_proto_5fex1_2eproto[0]);
}
// @@protoc_insertion_point(namespace_scope)
} // namespace tutorial
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::tutorial::SearchRequest*
Arena::CreateMaybeMessage< ::tutorial::SearchRequest >(Arena* arena) {
return Arena::CreateMessageInternal< ::tutorial::SearchRequest >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto_ex1.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_proto_5fex1_2eproto_2epb_2eh
#define GOOGLE_PROTOBUF_INCLUDED_proto_5fex1_2eproto_2epb_2eh
#include <limits>
#include <string>
#include <type_traits>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4023000
#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 // PROTOBUF_VERSION
#if 4023002 < 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 // PROTOBUF_MIN_PROTOC_VERSION
#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_util.h"
#include "google/protobuf/metadata_lite.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/unknown_field_set.h"
// @@protoc_insertion_point(includes)
// Must be included last.
#include "google/protobuf/port_def.inc"
#define PROTOBUF_INTERNAL_EXPORT_proto_5fex1_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_proto_5fex1_2eproto {
static const ::uint32_t offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
descriptor_table_proto_5fex1_2eproto;
namespace tutorial {
class SearchRequest;
struct SearchRequestDefaultTypeInternal;
extern SearchRequestDefaultTypeInternal _SearchRequest_default_instance_;
} // namespace tutorial
PROTOBUF_NAMESPACE_OPEN
template <>
::tutorial::SearchRequest* Arena::CreateMaybeMessage<::tutorial::SearchRequest>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace tutorial {
// ===================================================================
// -------------------------------------------------------------------
class SearchRequest final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:tutorial.SearchRequest) */ {
public:
inline SearchRequest() : SearchRequest(nullptr) {}
~SearchRequest() override;
template<typename = void>
explicit PROTOBUF_CONSTEXPR SearchRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
SearchRequest(const SearchRequest& from);
SearchRequest(SearchRequest&& from) noexcept
: SearchRequest() {
*this = ::std::move(from);
}
inline SearchRequest& operator=(const SearchRequest& from) {
CopyFrom(from);
return *this;
}
inline SearchRequest& operator=(SearchRequest&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const SearchRequest& default_instance() {
return *internal_default_instance();
}
static inline const SearchRequest* internal_default_instance() {
return reinterpret_cast<const SearchRequest*>(
&_SearchRequest_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(SearchRequest& a, SearchRequest& b) {
a.Swap(&b);
}
inline void Swap(SearchRequest* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(SearchRequest* other) {
if (other == this) return;
ABSL_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
SearchRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
return CreateMaybeMessage<SearchRequest>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const SearchRequest& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
void MergeFrom( const SearchRequest& from) {
SearchRequest::MergeImpl(*this, from);
}
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::uint8_t* _InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(SearchRequest* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::absl::string_view FullMessageName() {
return "tutorial.SearchRequest";
}
protected:
explicit SearchRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kQuearyFieldNumber = 1,
kPageNumberFieldNumber = 2,
kResultsPerPageFieldNumber = 3,
};
// optional string queary = 1;
bool has_queary() const;
void clear_queary() ;
const std::string& queary() const;
template <typename Arg_ = const std::string&, typename... Args_>
void set_queary(Arg_&& arg, Args_... args);
std::string* mutable_queary();
PROTOBUF_NODISCARD std::string* release_queary();
void set_allocated_queary(std::string* ptr);
private:
const std::string& _internal_queary() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_queary(
const std::string& value);
std::string* _internal_mutable_queary();
public:
// optional int32 page_number = 2;
bool has_page_number() const;
void clear_page_number() ;
::int32_t page_number() const;
void set_page_number(::int32_t value);
private:
::int32_t _internal_page_number() const;
void _internal_set_page_number(::int32_t value);
public:
// optional int32 results_per_page = 3;
bool has_results_per_page() const;
void clear_results_per_page() ;
::int32_t results_per_page() const;
void set_results_per_page(::int32_t value);
private:
::int32_t _internal_results_per_page() const;
void _internal_set_results_per_page(::int32_t value);
public:
// @@protoc_insertion_point(class_scope:tutorial.SearchRequest)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr queary_;
::int32_t page_number_;
::int32_t results_per_page_;
};
union { Impl_ _impl_; };
friend struct ::TableStruct_proto_5fex1_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// -------------------------------------------------------------------
// SearchRequest
// optional string queary = 1;
inline bool SearchRequest::has_queary() const {
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
return value;
}
inline void SearchRequest::clear_queary() {
_impl_.queary_.ClearToEmpty();
_impl_._has_bits_[0] &= ~0x00000001u;
}
inline const std::string& SearchRequest::queary() const {
// @@protoc_insertion_point(field_get:tutorial.SearchRequest.queary)
return _internal_queary();
}
template <typename Arg_, typename... Args_>
inline PROTOBUF_ALWAYS_INLINE void SearchRequest::set_queary(Arg_&& arg,
Args_... args) {
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.queary_.Set(static_cast<Arg_&&>(arg), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:tutorial.SearchRequest.queary)
}
inline std::string* SearchRequest::mutable_queary() {
std::string* _s = _internal_mutable_queary();
// @@protoc_insertion_point(field_mutable:tutorial.SearchRequest.queary)
return _s;
}
inline const std::string& SearchRequest::_internal_queary() const {
return _impl_.queary_.Get();
}
inline void SearchRequest::_internal_set_queary(const std::string& value) {
_impl_._has_bits_[0] |= 0x00000001u;
_impl_.queary_.Set(value, GetArenaForAllocation());
}
inline std::string* SearchRequest::_internal_mutable_queary() {
_impl_._has_bits_[0] |= 0x00000001u;
return _impl_.queary_.Mutable( GetArenaForAllocation());
}
inline std::string* SearchRequest::release_queary() {
// @@protoc_insertion_point(field_release:tutorial.SearchRequest.queary)
if ((_impl_._has_bits_[0] & 0x00000001u) == 0) {
return nullptr;
}
_impl_._has_bits_[0] &= ~0x00000001u;
auto* released = _impl_.queary_.Release();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.queary_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return released;
}
inline void SearchRequest::set_allocated_queary(std::string* value) {
if (value != nullptr) {
_impl_._has_bits_[0] |= 0x00000001u;
} else {
_impl_._has_bits_[0] &= ~0x00000001u;
}
_impl_.queary_.SetAllocated(value, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.queary_.IsDefault()) {
_impl_.queary_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:tutorial.SearchRequest.queary)
}
// optional int32 page_number = 2;
inline bool SearchRequest::has_page_number() const {
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline void SearchRequest::clear_page_number() {
_impl_.page_number_ = 0;
_impl_._has_bits_[0] &= ~0x00000002u;
}
inline ::int32_t SearchRequest::page_number() const {
// @@protoc_insertion_point(field_get:tutorial.SearchRequest.page_number)
return _internal_page_number();
}
inline void SearchRequest::set_page_number(::int32_t value) {
_internal_set_page_number(value);
// @@protoc_insertion_point(field_set:tutorial.SearchRequest.page_number)
}
inline ::int32_t SearchRequest::_internal_page_number() const {
return _impl_.page_number_;
}
inline void SearchRequest::_internal_set_page_number(::int32_t value) {
_impl_._has_bits_[0] |= 0x00000002u;
_impl_.page_number_ = value;
}
// optional int32 results_per_page = 3;
inline bool SearchRequest::has_results_per_page() const {
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
return value;
}
inline void SearchRequest::clear_results_per_page() {
_impl_.results_per_page_ = 0;
_impl_._has_bits_[0] &= ~0x00000004u;
}
inline ::int32_t SearchRequest::results_per_page() const {
// @@protoc_insertion_point(field_get:tutorial.SearchRequest.results_per_page)
return _internal_results_per_page();
}
inline void SearchRequest::set_results_per_page(::int32_t value) {
_internal_set_results_per_page(value);
// @@protoc_insertion_point(field_set:tutorial.SearchRequest.results_per_page)
}
inline ::int32_t SearchRequest::_internal_results_per_page() const {
return _impl_.results_per_page_;
}
inline void SearchRequest::_internal_set_results_per_page(::int32_t value) {
_impl_._has_bits_[0] |= 0x00000004u;
_impl_.results_per_page_ = value;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace tutorial
// @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc"
#endif // GOOGLE_PROTOBUF_INCLUDED_proto_5fex1_2eproto_2epb_2eh
