diff --git a/CMakeLists.txt b/CMakeLists.txt index cdeb559..92c81fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,6 @@ add_executable(test_tinyrpc # 引入 abseil-cpp 子目录 add_subdirectory(./third_party/abseil-cpp absl) - set(ABSEL_LIBARARY absl::absl_check absl::absl_log @@ -88,7 +87,6 @@ set(ABSEL_LIBARARY absl::variant ) - # 链接库 target_link_libraries(tinyrpc PRIVATE protobuf) # 链接 Protobuf 库 target_link_libraries(tinyrpc PRIVATE ${ABSEL_LIBARARY}) # 链接 Protobuf 库 diff --git a/includes/net/abstract_dispatcher.hpp b/includes/net/abstract_dispatcher.hpp index dd38442..bb4add1 100644 --- a/includes/net/abstract_dispatcher.hpp +++ b/includes/net/abstract_dispatcher.hpp @@ -1,7 +1,8 @@ #pragma once #include "abstract_coder.hpp" -#include "tcp_connection.hpp" +#include "server_tcp_connect.hpp" + namespace tinyrpc { @@ -10,7 +11,7 @@ namespace tinyrpc { public: AbstractDispatcher() = default; virtual ~AbstractDispatcher() = default; - virtual void dispatcher(TcpConnection& conn, AbstractData& data, AbstractData& respond) = 0; + virtual void dispatcher(ServerTcpConnection& conn, AbstractData& data, AbstractData& respond) = 0; private: diff --git a/includes/net/protocol_type.hpp b/includes/net/protocol_type.hpp new file mode 100644 index 0000000..a4f86ed --- /dev/null +++ b/includes/net/protocol_type.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace tinyrpc { + enum class ProtocolType{ + Tinypb, + }; +} diff --git a/includes/net/tcp/abstract_tcp_connect.hpp b/includes/net/tcp/abstract_tcp_connect.hpp new file mode 100644 index 0000000..ebf1e9d --- /dev/null +++ b/includes/net/tcp/abstract_tcp_connect.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "coroutine.hpp" +#include "fd_event.hpp" +#include "reactor.hpp" +#include "tcp_buffer.hpp" + +namespace tinyrpc { + class TcpServer; + class AbstractTcpConnection { + public: + enum class State{ + Disconnected, + Connected + }; + // enum class Type{ + // Server, + // Client + // }; + + public: + AbstractTcpConnection(int fd, Reactor& reactor, State state = State::Connected); + void clearClient(); + void mainLoopFun(); + State getState() {return m_state;} + // bool getResPackageData(const std::string& msg_req, std::shared_ptr& pb_struct); //cli + virtual ~AbstractTcpConnection(); + + protected: + void input(); + void output(); + virtual void process() = 0; + + protected: + FdEvent *m_fdEvent; + Coroutine m_mainCoroutine; + State m_state{State::Connected}; + TcpBuffer m_writeBuffer{}; + TcpBuffer m_readBuffer{}; + Reactor& m_reactor; + // TcpServer& m_server; + // TcpClient& m_server; + // std::unordered_map> m_respond_datas; // cli + }; + +} \ No newline at end of file diff --git a/includes/net/tcp/client_tcp_connect.hpp b/includes/net/tcp/client_tcp_connect.hpp new file mode 100644 index 0000000..d7f44f1 --- /dev/null +++ b/includes/net/tcp/client_tcp_connect.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "abstract_coder.hpp" +#include "abstract_tcp_connect.hpp" +#include + + +namespace tinyrpc { + class TcpClient; + class ClientTcpConnection : AbstractTcpConnection { + + public: + ClientTcpConnection(int fd, Reactor& reactor, TcpClient& cli); + ~ClientTcpConnection(); + + private: + void process() override; + + private: + TcpClient& m_client; + std::unordered_map> m_respond_datas; // cli + + }; + +} \ No newline at end of file diff --git a/includes/net/tcp/io_thread.hpp b/includes/net/tcp/io_thread.hpp index b36f597..9ddebb5 100644 --- a/includes/net/tcp/io_thread.hpp +++ b/includes/net/tcp/io_thread.hpp @@ -1,6 +1,7 @@ #pragma once +#include "abstract_tcp_connect.hpp" #include "reactor.hpp" -#include "tcp_connection.hpp" +#include "server_tcp_connect.hpp" #include #include #include @@ -21,7 +22,7 @@ namespace tinyrpc { ~IOThread(); void mainFunc(); private: - std::unordered_map> m_clients; + std::unordered_map> m_clients; std::thread m_thread; Reactor* m_reactor{nullptr}; }; diff --git a/includes/net/tcp/server_tcp_connect.hpp b/includes/net/tcp/server_tcp_connect.hpp new file mode 100644 index 0000000..9b9de44 --- /dev/null +++ b/includes/net/tcp/server_tcp_connect.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "abstract_tcp_connect.hpp" +#include "reactor.hpp" + + +namespace tinyrpc { + class TcpServer; + class ServerTcpConnection : AbstractTcpConnection { + + public: + ServerTcpConnection(int fd, Reactor& reactor, TcpServer& ser); + ~ServerTcpConnection(); + + private: + void process() override; + + private: + TcpServer& m_server; + + }; + +} \ No newline at end of file diff --git a/includes/net/tcp/tcp_client.hpp b/includes/net/tcp/tcp_client.hpp new file mode 100644 index 0000000..39941f2 --- /dev/null +++ b/includes/net/tcp/tcp_client.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "abstract_coder.hpp" +#include "client_tcp_connect.hpp" +#include "net_address.hpp" +#include "reactor.hpp" + +namespace tinyrpc { + class TcpClient { + public: + TcpClient(const NetAddress& peerAddr); + AbstractCoder& getCoder() {return *m_coder;} + ~TcpClient(); + private: + int m_fd{-1}; + NetAddress m_local_addr{}; + NetAddress m_peer_addr{}; + Reactor& m_reactor; + ClientTcpConnection *m_connection; + AbstractCoder* m_coder{}; + }; + +} \ No newline at end of file diff --git a/includes/net/tcp/tcp_connection.hpp b/includes/net/tcp/tcp_connection.hpp deleted file mode 100644 index b456f67..0000000 --- a/includes/net/tcp/tcp_connection.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "abstract_coder.hpp" -#include "coroutine.hpp" -#include "fd_event.hpp" -#include "reactor.hpp" -#include "tcp_buffer.hpp" - -namespace tinyrpc { - class TcpServer; - class TcpConnection { - public: - enum class State{ - Disconnected, - Connected - }; - - - public: - TcpConnection(int fd, Reactor& reactor, TcpServer& ser); - void clearClient(); - void mainLoopFun(); - - ~TcpConnection(); - - private: - void input(); - void output(); - void process(); - - - private: - FdEvent *m_fdEvent; - Coroutine m_mainCoroutine; - State m_state{State::Connected}; - TcpBuffer m_writeBuffer{}; - TcpBuffer m_readBuffer{}; - Reactor& m_reactor; - TcpServer& m_server; - }; - -} \ No newline at end of file diff --git a/includes/net/tcp/tcp_server.hpp b/includes/net/tcp/tcp_server.hpp index 460e5c3..279ff0f 100644 --- a/includes/net/tcp/tcp_server.hpp +++ b/includes/net/tcp/tcp_server.hpp @@ -4,7 +4,9 @@ #include "coroutine.hpp" #include "io_thread.hpp" #include "net_address.hpp" +#include "protocol_type.hpp" #include +#include // #include "reactor.hpp" namespace tinyrpc { @@ -28,6 +30,7 @@ namespace tinyrpc { void start(); AbstractCoder& getCoder() {return *m_coder;} AbstractDispatcher& getDispatcher() {return *m_dispatcher;} + void registerService(std::shared_ptr service); private: void mainAcceptCorFun(); private: @@ -41,6 +44,7 @@ namespace tinyrpc { IOThreadPool m_ioThreadPool{4}; AbstractCoder* m_coder{}; AbstractDispatcher* m_dispatcher{}; + ProtocolType m_protocolType{ProtocolType::Tinypb}; }; } \ No newline at end of file diff --git a/includes/net/tinypb/tinypb_closure.hpp b/includes/net/tinypb/tinypb_closure.hpp new file mode 100644 index 0000000..d6e5511 --- /dev/null +++ b/includes/net/tinypb/tinypb_closure.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +namespace tinyrpc { + + class TinypbClosure : public google::protobuf::Closure { + public: + explicit TinypbClosure(const std::function& cb) : m_callback(cb){} + ~TinypbClosure() = default; + + void Run() override { + if(m_callback) { + m_callback(); + } + } + + + private: + std::function m_callback{}; + + + + }; + +} \ No newline at end of file diff --git a/includes/net/tinypb/tinypb_controller.hpp b/includes/net/tinypb/tinypb_controller.hpp new file mode 100644 index 0000000..e49af79 --- /dev/null +++ b/includes/net/tinypb/tinypb_controller.hpp @@ -0,0 +1,90 @@ +#pragma once + +#include "net_address.hpp" +#include + +namespace tinyrpc { + + class TinypbController : public google::protobuf::RpcController { + public: + + + + TinypbController() = default; + + ~TinypbController() = default; + + void Reset() override{} + + bool Failed() const override{return m_is_failed;} + + + // Server-side methods --------------------------------------------- + + std::string ErrorText() const override {return m_error_info;} + + void StartCancel() override{} + + void SetFailed(const std::string& reason) override { + m_is_failed = true; + m_error_info = reason; + } + + bool IsCanceled() const override { + return m_is_canceled; + } + + void NotifyOnCancel(google::protobuf::Closure* callback) override {} + // common methods + + int ErrorCode() const {return m_error_code;} + + void SetErrorCode(const int error_code) {m_error_code = error_code;} + + void SetError(const int err_code, const std::string& err_info) { + SetFailed(err_info); + SetErrorCode(err_code); + } + + void SetPeerAddr(const NetAddress& addr) { + m_peer_addr = addr; + } + + void SetLocalAddr(const NetAddress& addr) { + m_local_addr = addr; + } + + const NetAddress& PeerAddr() {return m_peer_addr;} + + const NetAddress& LocalAddr(){return m_local_addr;} + + void SetTimeout(const int timeout) {m_timeout = timeout;} + + int Timeout() const {return m_timeout;} + + void SetMsgReq(const std::string& msg_req ) {m_msg_req = msg_req;} + void SetMethodName(const std::string& method_name ) {m_method_name = method_name;} + void SetFullName(const std::string& full_name ) {m_full_name = full_name;} + const std::string GetMsgReq() const {return m_msg_req;} + const std::string GetMethodName() const {return m_method_name;} + const std::string GetFullName() const {return m_full_name;} + + + private: + int m_error_code {0}; + bool m_is_failed {false}; + bool m_is_canceled {false}; + std::string m_error_info{}; + std::string m_msg_req{}; + std::string m_method_name{}; + std::string m_full_name{}; + + int m_timeout {5000}; + NetAddress m_peer_addr{}; + NetAddress m_local_addr{}; + + + + }; + +} \ No newline at end of file diff --git a/includes/net/tinypb/tinypb_dispatcher.hpp b/includes/net/tinypb/tinypb_dispatcher.hpp index 2606995..803db72 100644 --- a/includes/net/tinypb/tinypb_dispatcher.hpp +++ b/includes/net/tinypb/tinypb_dispatcher.hpp @@ -1,6 +1,7 @@ #pragma once #include "abstract_dispatcher.hpp" +#include #include #include #include @@ -15,10 +16,11 @@ namespace tinyrpc { public: TinypbDispatcher(); ~TinypbDispatcher(); - void dispatcher(TcpConnection& conn, AbstractData& data, AbstractData& respond) override; + void dispatcher(ServerTcpConnection& conn, AbstractData& data, AbstractData& respond) override; bool parseServiceFullName(const std::string& name, std::string& serviceName, std::string& methodName); + void registerService(std::shared_ptr& service); private: - std::unordered_map m_service_map; + std::unordered_map> m_service_map; }; diff --git a/src/net/tcp/tcp_connection.cc b/src/net/tcp/abstract_tcp_connect.cc similarity index 55% rename from src/net/tcp/tcp_connection.cc rename to src/net/tcp/abstract_tcp_connect.cc index 3f3a5b4..8bc07e6 100644 --- a/src/net/tcp/tcp_connection.cc +++ b/src/net/tcp/abstract_tcp_connect.cc @@ -1,24 +1,17 @@ -#include "tcp_connection.hpp" -#include "abstract_coder.hpp" +#include "abstract_tcp_connect.hpp" #include "coroutine_hook.hpp" -#include "fd_event.hpp" #include "logger.hpp" -#include "reactor.hpp" -#include "tcp_server.hpp" -#include "tinypb_data.hpp" -#include -#include -#include -#include #include + namespace tinyrpc { - TcpConnection::TcpConnection(int fd, Reactor& reactor, TcpServer& ser) : + AbstractTcpConnection::AbstractTcpConnection(int fd, Reactor& reactor, State state) : m_fdEvent(FdEventPool::getInstance()->getFdEvent(fd)), - m_mainCoroutine(std::bind(&TcpConnection::mainLoopFun, this)), - m_reactor(reactor), - m_server(ser) + m_mainCoroutine(std::bind(&AbstractTcpConnection::mainLoopFun, this)), + m_state(state), + m_reactor(reactor) + { Reactor::Task task = [this] { logger() << "conn coroutine is resume"; @@ -29,7 +22,8 @@ namespace tinyrpc { } - void TcpConnection::mainLoopFun() { + + void AbstractTcpConnection::mainLoopFun() { while(m_state == State::Connected) { input(); process(); @@ -38,7 +32,7 @@ namespace tinyrpc { logger() << "this conn loop has already break"; } - void TcpConnection::clearClient() { + void AbstractTcpConnection::clearClient() { logger() << "clearClient"; m_state = State::Disconnected; m_reactor.delFdEvent(m_fdEvent); @@ -47,7 +41,7 @@ namespace tinyrpc { } - void TcpConnection::input() { // 调用 read_hook 读数据到应用层缓冲区 + void AbstractTcpConnection::input() { // 调用 read_hook 读数据到应用层缓冲区 logger() << "input"; if(m_state == State::Disconnected) { logger() << "input: this conn has already break"; @@ -84,7 +78,7 @@ namespace tinyrpc { } - void TcpConnection::output() { + void AbstractTcpConnection::output() { logger() << "output"; if(m_state == State::Disconnected) { return; @@ -113,42 +107,50 @@ namespace tinyrpc { } - void TcpConnection::process() { - logger() << "process"; - // if(m_state == State::Disconnected) { - // return; - // } - // if(m_writeBuffer.getWriteable() < m_readBuffer.getReadable()) { - // m_writeBuffer.resize(m_readBuffer.getReadable() * 2); - // } - // std::memcpy(m_writeBuffer.getWriteAddress(), m_readBuffer.getReadAddress(), m_readBuffer.getReadable()); - // m_writeBuffer.writeOffset(m_readBuffer.getReadable()); - // m_readBuffer.readOffset(m_readBuffer.getReadable()); + // void AbstractTcpConnection::process() { + // logger() << "process"; + + // // if(m_state == State::Disconnected) { + // // return; + // // } + // // if(m_writeBuffer.getWriteable() < m_readBuffer.getReadable()) { + // // m_writeBuffer.resize(m_readBuffer.getReadable() * 2); + // // } + // // std::memcpy(m_writeBuffer.getWriteAddress(), m_readBuffer.getReadAddress(), m_readBuffer.getReadable()); + // // m_writeBuffer.writeOffset(m_readBuffer.getReadable()); + // // m_readBuffer.readOffset(m_readBuffer.getReadable()); - // logger() << "write data " << m_writeBuffer.getReadable() << " byte"; + // // logger() << "write data " << m_writeBuffer.getReadable() << " byte"; - while(m_readBuffer.getReadable() > 0) { - std::unique_ptr data(new TinypbData); + // while(m_readBuffer.getReadable() > 0) { + // std::shared_ptr data(new TinypbData); - bool ret = m_server.getCoder().decoder(m_readBuffer, *data); - if(ret == false) { - logger() << "decode error"; - break; - } - std::unique_ptr resp(new TinypbData); - m_server.getDispatcher().dispatcher(*this, *data, *resp); + // bool ret = m_server.getCoder().decoder(m_readBuffer, *data); + // if(ret == false) { + // logger() << "decode error"; + // break; + // } + // if(m_connectType == Type::Server) { + // std::unique_ptr resp(new TinypbData); + // m_server.getDispatcher().dispatcher(*this, *data, *resp); + // m_server.getCoder().encoder(m_writeBuffer, *resp); + // } else { + // std::shared_ptr tmp = std::dynamic_pointer_cast(data); + // m_respond_datas[tmp->msg_req] = data; + // } - m_server.getCoder().encoder(m_writeBuffer, *resp); - } + // } - } + // } - TcpConnection::~TcpConnection() { + AbstractTcpConnection::~AbstractTcpConnection() { if(m_state == State::Connected) { clearClient(); } - logger() << "TcpConnection fd " << m_fdEvent->getFd() << " destructor"; + + logger() << "AbstractTcpConnection fd " << m_fdEvent->getFd() << " destructor"; } -} \ No newline at end of file +} + diff --git a/src/net/tcp/client_tcp_connect.cc b/src/net/tcp/client_tcp_connect.cc new file mode 100644 index 0000000..c0b83c0 --- /dev/null +++ b/src/net/tcp/client_tcp_connect.cc @@ -0,0 +1,38 @@ +#include "client_tcp_connect.hpp" +#include "abstract_tcp_connect.hpp" +#include "logger.hpp" +#include "tcp_client.hpp" +#include "tinypb_data.hpp" +#include + + + +namespace tinyrpc { + ClientTcpConnection::ClientTcpConnection(int fd, Reactor& reactor, TcpClient& cli) : + AbstractTcpConnection(fd, reactor), + m_client(cli) + { + + } + + ClientTcpConnection::~ClientTcpConnection() { + + } + + void ClientTcpConnection::process() { + while(m_readBuffer.getReadable() > 0) { + std::shared_ptr data(new TinypbData); + + bool ret = m_client.getCoder().decoder(m_readBuffer, *data); + + if(ret == false) { + logger() << "decode error"; + break; + } + + std::shared_ptr tmp = std::dynamic_pointer_cast(data); + m_respond_datas[tmp->msg_req] = data; + + } + } +} \ No newline at end of file diff --git a/src/net/tcp/io_thread.cc b/src/net/tcp/io_thread.cc index 521470a..3387094 100644 --- a/src/net/tcp/io_thread.cc +++ b/src/net/tcp/io_thread.cc @@ -2,7 +2,7 @@ #include "logger.hpp" #include "reactor.hpp" #include "coroutine.hpp" -#include "tcp_connection.hpp" +#include "server_tcp_connect.hpp" #include "tcp_server.hpp" #include #include @@ -26,7 +26,7 @@ namespace tinyrpc { void IOThread::addClient(TcpServer* ser, int fd) { - m_clients[fd] = std::make_shared(fd, *m_reactor, *ser); + m_clients[fd] = std::shared_ptr(new ServerTcpConnection(fd, *m_reactor, *ser)); } diff --git a/src/net/tcp/server_tcp_connect.cc b/src/net/tcp/server_tcp_connect.cc new file mode 100644 index 0000000..47fbf2b --- /dev/null +++ b/src/net/tcp/server_tcp_connect.cc @@ -0,0 +1,35 @@ +#include "server_tcp_connect.hpp" +#include "abstract_tcp_connect.hpp" +#include "logger.hpp" +#include "tcp_server.hpp" +#include "tinypb_data.hpp" + + +namespace tinyrpc { + ServerTcpConnection::ServerTcpConnection(int fd, Reactor& reactor, TcpServer& ser) : + AbstractTcpConnection(fd, reactor), + m_server(ser) + { + + } + ServerTcpConnection::~ServerTcpConnection() { + + } + void ServerTcpConnection::process() { + while(m_readBuffer.getReadable() > 0) { + std::shared_ptr data(new TinypbData); + + bool ret = m_server.getCoder().decoder(m_readBuffer, *data); + + if(ret == false) { + logger() << "decode error"; + break; + } + + std::unique_ptr resp(new TinypbData); + m_server.getDispatcher().dispatcher(*this, *data, *resp); + m_server.getCoder().encoder(m_writeBuffer, *resp); + + } + } +} \ No newline at end of file diff --git a/src/net/tcp/tcp_client.cc b/src/net/tcp/tcp_client.cc new file mode 100644 index 0000000..2ddea7c --- /dev/null +++ b/src/net/tcp/tcp_client.cc @@ -0,0 +1,35 @@ +#include "tcp_client.hpp" +#include "client_tcp_connect.hpp" +#include "fd_event.hpp" +#include "logger.hpp" +#include "net_address.hpp" +#include "reactor.hpp" +#include "tinypb_coder.hpp" +#include + + +namespace tinyrpc { + + TcpClient::TcpClient(const NetAddress& peerAddr) : + m_peer_addr(peerAddr), + m_reactor(*Reactor::getReactor()) + + { + m_fd = socket(AF_INET, SOCK_STREAM, 0); + if (m_fd == -1) { + logger() << "call socket error, fd=-1, sys error=" << strerror(errno); + } + m_local_addr = NetAddress("127.0.0.1", 0); + m_coder = new TinypbCoder(); + m_connection = new ClientTcpConnection(m_fd, m_reactor, *this); + + } + + TcpClient::~TcpClient() { + m_reactor.delFdEvent(FdEventPool::getInstance()->getFdEvent(m_fd)); + if(m_fd != -1) close(m_fd); + delete m_coder; + delete m_connection; + } + +} \ No newline at end of file diff --git a/src/net/tcp/tcp_server.cc b/src/net/tcp/tcp_server.cc index 40f0c5b..7c246b3 100644 --- a/src/net/tcp/tcp_server.cc +++ b/src/net/tcp/tcp_server.cc @@ -4,6 +4,7 @@ #include "logger.hpp" #include "coroutine_hook.hpp" #include "net_address.hpp" +#include "protocol_type.hpp" #include "reactor.hpp" #include "tinypb_coder.hpp" #include "tinypb_dispatcher.hpp" @@ -103,4 +104,12 @@ namespace tinyrpc { } } + + void TcpServer::registerService(std::shared_ptr service) { + if(m_protocolType != ProtocolType::Tinypb) return; + if(service) { + dynamic_cast(m_dispatcher)->registerService(service); + } + + } } \ No newline at end of file diff --git a/src/net/tinypb/tinypb_dispatcher.cc b/src/net/tinypb/tinypb_dispatcher.cc index 1f36245..28a3483 100644 --- a/src/net/tinypb/tinypb_dispatcher.cc +++ b/src/net/tinypb/tinypb_dispatcher.cc @@ -1,8 +1,9 @@ #include "tinypb_dispatcher.hpp" #include "logger.hpp" +#include "tinypb_closure.hpp" +#include "tinypb_controller.hpp" #include "tinypb_data.hpp" #include "error_code.hpp" -#include #include #include @@ -12,16 +13,22 @@ namespace tinyrpc { TinypbDispatcher::~TinypbDispatcher() { } - void TinypbDispatcher::dispatcher(TcpConnection& conn, AbstractData& data, AbstractData& resp) { + void TinypbDispatcher::dispatcher(ServerTcpConnection& conn, AbstractData& data, AbstractData& resp) { logger() << "dispatcher"; - TinypbData& pbdata = dynamic_cast(data); + TinypbData& request = dynamic_cast(data); TinypbData& respond = dynamic_cast(resp); + std::string service_name; std::string method_name; - respond.service_full_name = pbdata.service_full_name; - respond.msg_req = pbdata.msg_req; - bool ret = parseServiceFullName(pbdata.service_full_name, service_name, method_name); + respond.service_full_name = request.service_full_name; + respond.msg_req = request.msg_req; + + logger() << "request service_full_name:" << "[" << request.service_full_name << "]"; + logger() << "request msg_req:" << "[" << request.msg_req << "]"; + + bool ret = parseServiceFullName(request.service_full_name, service_name, method_name); + if(ret == false) { respond.err_code = ERROR_PARSE_SERVICE_NAME; std::stringstream ss; @@ -29,6 +36,7 @@ namespace tinyrpc { respond.err_info = ss.str(); return; } + logger() << "request method_name:" << "[" << method_name << "]"; auto it = m_service_map.find(service_name); @@ -41,7 +49,7 @@ namespace tinyrpc { } - Service* service = it->second; + std::shared_ptr service = it->second; const Method* method = service->GetDescriptor()->FindMethodByName(method_name); // const Method* method = nullptr; @@ -54,7 +62,7 @@ namespace tinyrpc { } std::unique_ptr requestMsg (service->GetRequestPrototype(method).New()); - ret = requestMsg->ParseFromString(pbdata.pb_data); + ret = requestMsg->ParseFromString(request.pb_data); if(ret == false) { respond.err_code = ERROR_FAILED_SERIALIZE; @@ -76,8 +84,14 @@ namespace tinyrpc { logger() << respond.msg_req << "|Set server response data:" << respondMsg->ShortDebugString(); } }; + + std::unique_ptr rpcController(new TinypbController); + rpcController->SetMsgReq(respond.msg_req); + rpcController->SetFullName(respond.service_full_name); + rpcController->SetMethodName(method_name); + TinypbClosure done(callback); - service->CallMethod(method, nullptr, requestMsg.get(), respondMsg.get(), nullptr /* callback */); + service->CallMethod(method, rpcController.get(), requestMsg.get(), respondMsg.get(), &done /* callback */); } @@ -89,10 +103,16 @@ namespace tinyrpc { serviceName = name.substr(0, pos); methodName = name.substr(pos + 1); - logger() << "serviceName=" << serviceName; - logger() << "methodName=" << methodName; + // logger() << "serviceName=" << serviceName; + // logger() << "methodName=" << methodName; return true; } + void TinypbDispatcher::registerService(std::shared_ptr& service) { + std::string service_name = service->GetDescriptor()->full_name(); + m_service_map[service_name] = service; + logger() << "success register service:" << "[" << service_name << "]"; + } + } diff --git a/test/servertest/clienttest.cc b/test/servertest/clienttest.cc new file mode 100644 index 0000000..b7d4199 --- /dev/null +++ b/test/servertest/clienttest.cc @@ -0,0 +1,22 @@ +#include +#include "reactor.hpp" +#include "tcp_server.hpp" +using namespace std; +using namespace tinyrpc; +void test() { + + + +} + + + +int main() { + TcpServer server; + + // server. + Reactor::getReactor()->addTask(test); + server.start(); + + return 0; +} \ No newline at end of file diff --git a/test/servertest/servertest.cc b/test/servertest/servertest.cc new file mode 100644 index 0000000..4583d56 --- /dev/null +++ b/test/servertest/servertest.cc @@ -0,0 +1,51 @@ +#include "logger.hpp" +#include "tcp_server.hpp" +#include "tinypb.pb.h" +#include +#include +using namespace std; +using namespace tinyrpc; + +class QueryServiceImpl : public QueryService { +public: + QueryServiceImpl() { } + ~QueryServiceImpl() { } + + void query_name(google::protobuf::RpcController* controller, + const ::queryNameReq* request, + ::queryNameRes* response, + ::google::protobuf::Closure* done) override + { + logger() << "QueryServiceImpl.query_name, req={" << request->ShortDebugString() << "}"; + response->set_ret_code(0); + response->set_res_info("OK"); + response->set_req_no(request->req_no()); + response->set_id(request->id()); + response->set_name("yyy"); + done->Run(); + } + + void query_age(google::protobuf::RpcController* controller, + const ::queryAgeReq* request, + ::queryAgeRes* response, + ::google::protobuf::Closure* done) override + { + logger() << "QueryServiceImpl.query_name, req={" << request->ShortDebugString() << "}"; + response->set_ret_code(0); + response->set_res_info("OK"); + response->set_req_no(request->req_no()); + response->set_id(request->id()); + response->set_age(20); + done->Run(); + } + +private: +}; + +int main() +{ + TcpServer server("0.0.0.0", 9001); + server.registerService(std::make_shared()); + server.start(); + return 0; +} diff --git a/test/servertest/tinypb.pb.cc b/test/servertest/tinypb.pb.cc new file mode 100644 index 0000000..b9b0c96 --- /dev/null +++ b/test/servertest/tinypb.pb.cc @@ -0,0 +1,1439 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: tinypb.proto + +#include "tinypb.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +class queryAgeReqDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _queryAgeReq_default_instance_; +class queryAgeResDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _queryAgeRes_default_instance_; +class queryNameReqDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _queryNameReq_default_instance_; +class queryNameResDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _queryNameRes_default_instance_; +static void InitDefaultsscc_info_queryAgeReq_tinypb_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::_queryAgeReq_default_instance_; + new (ptr) ::queryAgeReq(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::queryAgeReq::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_queryAgeReq_tinypb_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_queryAgeReq_tinypb_2eproto}, {}}; + +static void InitDefaultsscc_info_queryAgeRes_tinypb_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::_queryAgeRes_default_instance_; + new (ptr) ::queryAgeRes(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::queryAgeRes::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_queryAgeRes_tinypb_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_queryAgeRes_tinypb_2eproto}, {}}; + +static void InitDefaultsscc_info_queryNameReq_tinypb_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::_queryNameReq_default_instance_; + new (ptr) ::queryNameReq(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::queryNameReq::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_queryNameReq_tinypb_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_queryNameReq_tinypb_2eproto}, {}}; + +static void InitDefaultsscc_info_queryNameRes_tinypb_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::_queryNameRes_default_instance_; + new (ptr) ::queryNameRes(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::queryNameRes::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_queryNameRes_tinypb_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_queryNameRes_tinypb_2eproto}, {}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_tinypb_2eproto[4]; +static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_tinypb_2eproto = nullptr; +static const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor* file_level_service_descriptors_tinypb_2eproto[1]; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_tinypb_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::queryAgeReq, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::queryAgeReq, req_no_), + PROTOBUF_FIELD_OFFSET(::queryAgeReq, id_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::queryAgeRes, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::queryAgeRes, ret_code_), + PROTOBUF_FIELD_OFFSET(::queryAgeRes, res_info_), + PROTOBUF_FIELD_OFFSET(::queryAgeRes, req_no_), + PROTOBUF_FIELD_OFFSET(::queryAgeRes, id_), + PROTOBUF_FIELD_OFFSET(::queryAgeRes, age_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::queryNameReq, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::queryNameReq, req_no_), + PROTOBUF_FIELD_OFFSET(::queryNameReq, id_), + PROTOBUF_FIELD_OFFSET(::queryNameReq, type_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::queryNameRes, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::queryNameRes, ret_code_), + PROTOBUF_FIELD_OFFSET(::queryNameRes, res_info_), + PROTOBUF_FIELD_OFFSET(::queryNameRes, req_no_), + PROTOBUF_FIELD_OFFSET(::queryNameRes, id_), + PROTOBUF_FIELD_OFFSET(::queryNameRes, name_), +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, sizeof(::queryAgeReq)}, + { 7, -1, sizeof(::queryAgeRes)}, + { 17, -1, sizeof(::queryNameReq)}, + { 25, -1, sizeof(::queryNameRes)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::_queryAgeReq_default_instance_), + reinterpret_cast(&::_queryAgeRes_default_instance_), + reinterpret_cast(&::_queryNameReq_default_instance_), + reinterpret_cast(&::_queryNameRes_default_instance_), +}; + +const char descriptor_table_protodef_tinypb_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\014tinypb.proto\")\n\013queryAgeReq\022\016\n\006req_no\030" + "\001 \001(\005\022\n\n\002id\030\002 \001(\005\"Z\n\013queryAgeRes\022\020\n\010ret_" + "code\030\001 \001(\005\022\020\n\010res_info\030\002 \001(\t\022\016\n\006req_no\030\003" + " \001(\005\022\n\n\002id\030\004 \001(\005\022\013\n\003age\030\005 \001(\005\"8\n\014queryNa" + "meReq\022\016\n\006req_no\030\001 \001(\005\022\n\n\002id\030\002 \001(\005\022\014\n\004typ" + "e\030\003 \001(\005\"\\\n\014queryNameRes\022\020\n\010ret_code\030\001 \001(" + "\005\022\020\n\010res_info\030\002 \001(\t\022\016\n\006req_no\030\003 \001(\005\022\n\n\002i" + "d\030\004 \001(\005\022\014\n\004name\030\005 \001(\t2c\n\014QueryService\022*\n" + "\nquery_name\022\r.queryNameReq\032\r.queryNameRe" + "s\022\'\n\tquery_age\022\014.queryAgeReq\032\014.queryAgeR" + "esB\003\200\001\001b\006proto3" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_tinypb_2eproto_deps[1] = { +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_tinypb_2eproto_sccs[4] = { + &scc_info_queryAgeReq_tinypb_2eproto.base, + &scc_info_queryAgeRes_tinypb_2eproto.base, + &scc_info_queryNameReq_tinypb_2eproto.base, + &scc_info_queryNameRes_tinypb_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_tinypb_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_tinypb_2eproto = { + false, false, descriptor_table_protodef_tinypb_2eproto, "tinypb.proto", 415, + &descriptor_table_tinypb_2eproto_once, descriptor_table_tinypb_2eproto_sccs, descriptor_table_tinypb_2eproto_deps, 4, 0, + schemas, file_default_instances, TableStruct_tinypb_2eproto::offsets, + file_level_metadata_tinypb_2eproto, 4, file_level_enum_descriptors_tinypb_2eproto, file_level_service_descriptors_tinypb_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_tinypb_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_tinypb_2eproto)), true); + +// =================================================================== + +void queryAgeReq::InitAsDefaultInstance() { +} +class queryAgeReq::_Internal { + public: +}; + +queryAgeReq::queryAgeReq(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:queryAgeReq) +} +queryAgeReq::queryAgeReq(const queryAgeReq& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::memcpy(&req_no_, &from.req_no_, + static_cast(reinterpret_cast(&id_) - + reinterpret_cast(&req_no_)) + sizeof(id_)); + // @@protoc_insertion_point(copy_constructor:queryAgeReq) +} + +void queryAgeReq::SharedCtor() { + ::memset(&req_no_, 0, static_cast( + reinterpret_cast(&id_) - + reinterpret_cast(&req_no_)) + sizeof(id_)); +} + +queryAgeReq::~queryAgeReq() { + // @@protoc_insertion_point(destructor:queryAgeReq) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void queryAgeReq::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void queryAgeReq::ArenaDtor(void* object) { + queryAgeReq* _this = reinterpret_cast< queryAgeReq* >(object); + (void)_this; +} +void queryAgeReq::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void queryAgeReq::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const queryAgeReq& queryAgeReq::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_queryAgeReq_tinypb_2eproto.base); + return *internal_default_instance(); +} + + +void queryAgeReq::Clear() { +// @@protoc_insertion_point(message_clear_start:queryAgeReq) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + ::memset(&req_no_, 0, static_cast( + reinterpret_cast(&id_) - + reinterpret_cast(&req_no_)) + sizeof(id_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* queryAgeReq::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // int32 req_no = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + req_no_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* queryAgeReq::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:queryAgeReq) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // int32 req_no = 1; + if (this->req_no() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_req_no(), target); + } + + // int32 id = 2; + if (this->id() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_id(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::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:queryAgeReq) + return target; +} + +size_t queryAgeReq::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:queryAgeReq) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // int32 req_no = 1; + if (this->req_no() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_req_no()); + } + + // int32 id = 2; + if (this->id() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_id()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void queryAgeReq::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:queryAgeReq) + GOOGLE_DCHECK_NE(&from, this); + const queryAgeReq* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:queryAgeReq) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:queryAgeReq) + MergeFrom(*source); + } +} + +void queryAgeReq::MergeFrom(const queryAgeReq& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:queryAgeReq) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from.req_no() != 0) { + _internal_set_req_no(from._internal_req_no()); + } + if (from.id() != 0) { + _internal_set_id(from._internal_id()); + } +} + +void queryAgeReq::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:queryAgeReq) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void queryAgeReq::CopyFrom(const queryAgeReq& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:queryAgeReq) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool queryAgeReq::IsInitialized() const { + return true; +} + +void queryAgeReq::InternalSwap(queryAgeReq* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(queryAgeReq, id_) + + sizeof(queryAgeReq::id_) + - PROTOBUF_FIELD_OFFSET(queryAgeReq, req_no_)>( + reinterpret_cast(&req_no_), + reinterpret_cast(&other->req_no_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata queryAgeReq::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void queryAgeRes::InitAsDefaultInstance() { +} +class queryAgeRes::_Internal { + public: +}; + +queryAgeRes::queryAgeRes(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:queryAgeRes) +} +queryAgeRes::queryAgeRes(const queryAgeRes& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + res_info_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (!from._internal_res_info().empty()) { + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_res_info(), + GetArena()); + } + ::memcpy(&ret_code_, &from.ret_code_, + static_cast(reinterpret_cast(&age_) - + reinterpret_cast(&ret_code_)) + sizeof(age_)); + // @@protoc_insertion_point(copy_constructor:queryAgeRes) +} + +void queryAgeRes::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_queryAgeRes_tinypb_2eproto.base); + res_info_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(&ret_code_, 0, static_cast( + reinterpret_cast(&age_) - + reinterpret_cast(&ret_code_)) + sizeof(age_)); +} + +queryAgeRes::~queryAgeRes() { + // @@protoc_insertion_point(destructor:queryAgeRes) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void queryAgeRes::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + res_info_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void queryAgeRes::ArenaDtor(void* object) { + queryAgeRes* _this = reinterpret_cast< queryAgeRes* >(object); + (void)_this; +} +void queryAgeRes::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void queryAgeRes::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const queryAgeRes& queryAgeRes::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_queryAgeRes_tinypb_2eproto.base); + return *internal_default_instance(); +} + + +void queryAgeRes::Clear() { +// @@protoc_insertion_point(message_clear_start:queryAgeRes) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + res_info_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::memset(&ret_code_, 0, static_cast( + reinterpret_cast(&age_) - + reinterpret_cast(&ret_code_)) + sizeof(age_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* queryAgeRes::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // int32 ret_code = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + ret_code_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // string res_info = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_res_info(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "queryAgeRes.res_info")); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 req_no = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + req_no_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 id = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 age = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { + age_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* queryAgeRes::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:queryAgeRes) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // int32 ret_code = 1; + if (this->ret_code() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_ret_code(), target); + } + + // string res_info = 2; + if (this->res_info().size() > 0) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_res_info().data(), static_cast(this->_internal_res_info().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "queryAgeRes.res_info"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_res_info(), target); + } + + // int32 req_no = 3; + if (this->req_no() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_req_no(), target); + } + + // int32 id = 4; + if (this->id() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_id(), target); + } + + // int32 age = 5; + if (this->age() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_age(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::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:queryAgeRes) + return target; +} + +size_t queryAgeRes::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:queryAgeRes) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string res_info = 2; + if (this->res_info().size() > 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_res_info()); + } + + // int32 ret_code = 1; + if (this->ret_code() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_ret_code()); + } + + // int32 req_no = 3; + if (this->req_no() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_req_no()); + } + + // int32 id = 4; + if (this->id() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_id()); + } + + // int32 age = 5; + if (this->age() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_age()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void queryAgeRes::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:queryAgeRes) + GOOGLE_DCHECK_NE(&from, this); + const queryAgeRes* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:queryAgeRes) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:queryAgeRes) + MergeFrom(*source); + } +} + +void queryAgeRes::MergeFrom(const queryAgeRes& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:queryAgeRes) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from.res_info().size() > 0) { + _internal_set_res_info(from._internal_res_info()); + } + if (from.ret_code() != 0) { + _internal_set_ret_code(from._internal_ret_code()); + } + if (from.req_no() != 0) { + _internal_set_req_no(from._internal_req_no()); + } + if (from.id() != 0) { + _internal_set_id(from._internal_id()); + } + if (from.age() != 0) { + _internal_set_age(from._internal_age()); + } +} + +void queryAgeRes::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:queryAgeRes) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void queryAgeRes::CopyFrom(const queryAgeRes& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:queryAgeRes) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool queryAgeRes::IsInitialized() const { + return true; +} + +void queryAgeRes::InternalSwap(queryAgeRes* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + res_info_.Swap(&other->res_info_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(queryAgeRes, age_) + + sizeof(queryAgeRes::age_) + - PROTOBUF_FIELD_OFFSET(queryAgeRes, ret_code_)>( + reinterpret_cast(&ret_code_), + reinterpret_cast(&other->ret_code_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata queryAgeRes::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void queryNameReq::InitAsDefaultInstance() { +} +class queryNameReq::_Internal { + public: +}; + +queryNameReq::queryNameReq(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:queryNameReq) +} +queryNameReq::queryNameReq(const queryNameReq& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::memcpy(&req_no_, &from.req_no_, + static_cast(reinterpret_cast(&type_) - + reinterpret_cast(&req_no_)) + sizeof(type_)); + // @@protoc_insertion_point(copy_constructor:queryNameReq) +} + +void queryNameReq::SharedCtor() { + ::memset(&req_no_, 0, static_cast( + reinterpret_cast(&type_) - + reinterpret_cast(&req_no_)) + sizeof(type_)); +} + +queryNameReq::~queryNameReq() { + // @@protoc_insertion_point(destructor:queryNameReq) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void queryNameReq::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void queryNameReq::ArenaDtor(void* object) { + queryNameReq* _this = reinterpret_cast< queryNameReq* >(object); + (void)_this; +} +void queryNameReq::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void queryNameReq::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const queryNameReq& queryNameReq::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_queryNameReq_tinypb_2eproto.base); + return *internal_default_instance(); +} + + +void queryNameReq::Clear() { +// @@protoc_insertion_point(message_clear_start:queryNameReq) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + ::memset(&req_no_, 0, static_cast( + reinterpret_cast(&type_) - + reinterpret_cast(&req_no_)) + sizeof(type_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* queryNameReq::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // int32 req_no = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + req_no_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 type = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* queryNameReq::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:queryNameReq) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // int32 req_no = 1; + if (this->req_no() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_req_no(), target); + } + + // int32 id = 2; + if (this->id() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_id(), target); + } + + // int32 type = 3; + if (this->type() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_type(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::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:queryNameReq) + return target; +} + +size_t queryNameReq::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:queryNameReq) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // int32 req_no = 1; + if (this->req_no() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_req_no()); + } + + // int32 id = 2; + if (this->id() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_id()); + } + + // int32 type = 3; + if (this->type() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_type()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void queryNameReq::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:queryNameReq) + GOOGLE_DCHECK_NE(&from, this); + const queryNameReq* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:queryNameReq) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:queryNameReq) + MergeFrom(*source); + } +} + +void queryNameReq::MergeFrom(const queryNameReq& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:queryNameReq) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from.req_no() != 0) { + _internal_set_req_no(from._internal_req_no()); + } + if (from.id() != 0) { + _internal_set_id(from._internal_id()); + } + if (from.type() != 0) { + _internal_set_type(from._internal_type()); + } +} + +void queryNameReq::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:queryNameReq) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void queryNameReq::CopyFrom(const queryNameReq& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:queryNameReq) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool queryNameReq::IsInitialized() const { + return true; +} + +void queryNameReq::InternalSwap(queryNameReq* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(queryNameReq, type_) + + sizeof(queryNameReq::type_) + - PROTOBUF_FIELD_OFFSET(queryNameReq, req_no_)>( + reinterpret_cast(&req_no_), + reinterpret_cast(&other->req_no_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata queryNameReq::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +void queryNameRes::InitAsDefaultInstance() { +} +class queryNameRes::_Internal { + public: +}; + +queryNameRes::queryNameRes(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:queryNameRes) +} +queryNameRes::queryNameRes(const queryNameRes& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + res_info_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (!from._internal_res_info().empty()) { + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_res_info(), + GetArena()); + } + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (!from._internal_name().empty()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), + GetArena()); + } + ::memcpy(&ret_code_, &from.ret_code_, + static_cast(reinterpret_cast(&id_) - + reinterpret_cast(&ret_code_)) + sizeof(id_)); + // @@protoc_insertion_point(copy_constructor:queryNameRes) +} + +void queryNameRes::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_queryNameRes_tinypb_2eproto.base); + res_info_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(&ret_code_, 0, static_cast( + reinterpret_cast(&id_) - + reinterpret_cast(&ret_code_)) + sizeof(id_)); +} + +queryNameRes::~queryNameRes() { + // @@protoc_insertion_point(destructor:queryNameRes) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void queryNameRes::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + res_info_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void queryNameRes::ArenaDtor(void* object) { + queryNameRes* _this = reinterpret_cast< queryNameRes* >(object); + (void)_this; +} +void queryNameRes::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void queryNameRes::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const queryNameRes& queryNameRes::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_queryNameRes_tinypb_2eproto.base); + return *internal_default_instance(); +} + + +void queryNameRes::Clear() { +// @@protoc_insertion_point(message_clear_start:queryNameRes) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + res_info_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::memset(&ret_code_, 0, static_cast( + reinterpret_cast(&id_) - + reinterpret_cast(&ret_code_)) + sizeof(id_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* queryNameRes::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // int32 ret_code = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + ret_code_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // string res_info = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_res_info(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "queryNameRes.res_info")); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 req_no = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + req_no_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 id = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // string name = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + auto str = _internal_mutable_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "queryNameRes.name")); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* queryNameRes::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:queryNameRes) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // int32 ret_code = 1; + if (this->ret_code() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_ret_code(), target); + } + + // string res_info = 2; + if (this->res_info().size() > 0) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_res_info().data(), static_cast(this->_internal_res_info().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "queryNameRes.res_info"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_res_info(), target); + } + + // int32 req_no = 3; + if (this->req_no() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_req_no(), target); + } + + // int32 id = 4; + if (this->id() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_id(), target); + } + + // string name = 5; + if (this->name().size() > 0) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "queryNameRes.name"); + target = stream->WriteStringMaybeAliased( + 5, this->_internal_name(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::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:queryNameRes) + return target; +} + +size_t queryNameRes::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:queryNameRes) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string res_info = 2; + if (this->res_info().size() > 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_res_info()); + } + + // string name = 5; + if (this->name().size() > 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } + + // int32 ret_code = 1; + if (this->ret_code() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_ret_code()); + } + + // int32 req_no = 3; + if (this->req_no() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_req_no()); + } + + // int32 id = 4; + if (this->id() != 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_id()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void queryNameRes::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:queryNameRes) + GOOGLE_DCHECK_NE(&from, this); + const queryNameRes* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:queryNameRes) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:queryNameRes) + MergeFrom(*source); + } +} + +void queryNameRes::MergeFrom(const queryNameRes& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:queryNameRes) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from.res_info().size() > 0) { + _internal_set_res_info(from._internal_res_info()); + } + if (from.name().size() > 0) { + _internal_set_name(from._internal_name()); + } + if (from.ret_code() != 0) { + _internal_set_ret_code(from._internal_ret_code()); + } + if (from.req_no() != 0) { + _internal_set_req_no(from._internal_req_no()); + } + if (from.id() != 0) { + _internal_set_id(from._internal_id()); + } +} + +void queryNameRes::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:queryNameRes) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void queryNameRes::CopyFrom(const queryNameRes& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:queryNameRes) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool queryNameRes::IsInitialized() const { + return true; +} + +void queryNameRes::InternalSwap(queryNameRes* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + res_info_.Swap(&other->res_info_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(queryNameRes, id_) + + sizeof(queryNameRes::id_) + - PROTOBUF_FIELD_OFFSET(queryNameRes, ret_code_)>( + reinterpret_cast(&ret_code_), + reinterpret_cast(&other->ret_code_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata queryNameRes::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +QueryService::~QueryService() {} + +const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor* QueryService::descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_tinypb_2eproto); + return file_level_service_descriptors_tinypb_2eproto[0]; +} + +const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor* QueryService::GetDescriptor() { + return descriptor(); +} + +void QueryService::query_name(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryNameReq*, + ::queryNameRes*, + ::google::protobuf::Closure* done) { + controller->SetFailed("Method query_name() not implemented."); + done->Run(); +} + +void QueryService::query_age(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryAgeReq*, + ::queryAgeRes*, + ::google::protobuf::Closure* done) { + controller->SetFailed("Method query_age() not implemented."); + done->Run(); +} + +void QueryService::CallMethod(const ::PROTOBUF_NAMESPACE_ID::MethodDescriptor* method, + ::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::PROTOBUF_NAMESPACE_ID::Message* request, + ::PROTOBUF_NAMESPACE_ID::Message* response, + ::google::protobuf::Closure* done) { + GOOGLE_DCHECK_EQ(method->service(), file_level_service_descriptors_tinypb_2eproto[0]); + switch(method->index()) { + case 0: + query_name(controller, + ::PROTOBUF_NAMESPACE_ID::internal::DownCast( + request), + ::PROTOBUF_NAMESPACE_ID::internal::DownCast<::queryNameRes*>( + response), + done); + break; + case 1: + query_age(controller, + ::PROTOBUF_NAMESPACE_ID::internal::DownCast( + request), + ::PROTOBUF_NAMESPACE_ID::internal::DownCast<::queryAgeRes*>( + response), + done); + break; + default: + GOOGLE_LOG(FATAL) << "Bad method index; this should never happen."; + break; + } +} + +const ::PROTOBUF_NAMESPACE_ID::Message& QueryService::GetRequestPrototype( + const ::PROTOBUF_NAMESPACE_ID::MethodDescriptor* method) const { + GOOGLE_DCHECK_EQ(method->service(), descriptor()); + switch(method->index()) { + case 0: + return ::queryNameReq::default_instance(); + case 1: + return ::queryAgeReq::default_instance(); + default: + GOOGLE_LOG(FATAL) << "Bad method index; this should never happen."; + return *::PROTOBUF_NAMESPACE_ID::MessageFactory::generated_factory() + ->GetPrototype(method->input_type()); + } +} + +const ::PROTOBUF_NAMESPACE_ID::Message& QueryService::GetResponsePrototype( + const ::PROTOBUF_NAMESPACE_ID::MethodDescriptor* method) const { + GOOGLE_DCHECK_EQ(method->service(), descriptor()); + switch(method->index()) { + case 0: + return ::queryNameRes::default_instance(); + case 1: + return ::queryAgeRes::default_instance(); + default: + GOOGLE_LOG(FATAL) << "Bad method index; this should never happen."; + return *::PROTOBUF_NAMESPACE_ID::MessageFactory::generated_factory() + ->GetPrototype(method->output_type()); + } +} + +QueryService_Stub::QueryService_Stub(::PROTOBUF_NAMESPACE_ID::RpcChannel* channel) + : channel_(channel), owns_channel_(false) {} +QueryService_Stub::QueryService_Stub( + ::PROTOBUF_NAMESPACE_ID::RpcChannel* channel, + ::PROTOBUF_NAMESPACE_ID::Service::ChannelOwnership ownership) + : channel_(channel), + owns_channel_(ownership == ::PROTOBUF_NAMESPACE_ID::Service::STUB_OWNS_CHANNEL) {} +QueryService_Stub::~QueryService_Stub() { + if (owns_channel_) delete channel_; +} + +void QueryService_Stub::query_name(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryNameReq* request, + ::queryNameRes* response, + ::google::protobuf::Closure* done) { + channel_->CallMethod(descriptor()->method(0), + controller, request, response, done); +} +void QueryService_Stub::query_age(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryAgeReq* request, + ::queryAgeRes* response, + ::google::protobuf::Closure* done) { + channel_->CallMethod(descriptor()->method(1), + controller, request, response, done); +} + +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::queryAgeReq* Arena::CreateMaybeMessage< ::queryAgeReq >(Arena* arena) { + return Arena::CreateMessageInternal< ::queryAgeReq >(arena); +} +template<> PROTOBUF_NOINLINE ::queryAgeRes* Arena::CreateMaybeMessage< ::queryAgeRes >(Arena* arena) { + return Arena::CreateMessageInternal< ::queryAgeRes >(arena); +} +template<> PROTOBUF_NOINLINE ::queryNameReq* Arena::CreateMaybeMessage< ::queryNameReq >(Arena* arena) { + return Arena::CreateMessageInternal< ::queryNameReq >(arena); +} +template<> PROTOBUF_NOINLINE ::queryNameRes* Arena::CreateMaybeMessage< ::queryNameRes >(Arena* arena) { + return Arena::CreateMessageInternal< ::queryNameRes >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/test/servertest/tinypb.pb.h b/test/servertest/tinypb.pb.h new file mode 100644 index 0000000..78cf49a --- /dev/null +++ b/test/servertest/tinypb.pb.h @@ -0,0 +1,1383 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: tinypb.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_tinypb_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_tinypb_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3012000 +#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 3012004 < 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_tinypb_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_tinypb_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[4] + 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_tinypb_2eproto; +class queryAgeReq; +class queryAgeReqDefaultTypeInternal; +extern queryAgeReqDefaultTypeInternal _queryAgeReq_default_instance_; +class queryAgeRes; +class queryAgeResDefaultTypeInternal; +extern queryAgeResDefaultTypeInternal _queryAgeRes_default_instance_; +class queryNameReq; +class queryNameReqDefaultTypeInternal; +extern queryNameReqDefaultTypeInternal _queryNameReq_default_instance_; +class queryNameRes; +class queryNameResDefaultTypeInternal; +extern queryNameResDefaultTypeInternal _queryNameRes_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template<> ::queryAgeReq* Arena::CreateMaybeMessage<::queryAgeReq>(Arena*); +template<> ::queryAgeRes* Arena::CreateMaybeMessage<::queryAgeRes>(Arena*); +template<> ::queryNameReq* Arena::CreateMaybeMessage<::queryNameReq>(Arena*); +template<> ::queryNameRes* Arena::CreateMaybeMessage<::queryNameRes>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +// =================================================================== + +class queryAgeReq PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:queryAgeReq) */ { + public: + inline queryAgeReq() : queryAgeReq(nullptr) {}; + virtual ~queryAgeReq(); + + queryAgeReq(const queryAgeReq& from); + queryAgeReq(queryAgeReq&& from) noexcept + : queryAgeReq() { + *this = ::std::move(from); + } + + inline queryAgeReq& operator=(const queryAgeReq& from) { + CopyFrom(from); + return *this; + } + inline queryAgeReq& operator=(queryAgeReq&& from) noexcept { + if (GetArena() == from.GetArena()) { + 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 queryAgeReq& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const queryAgeReq* internal_default_instance() { + return reinterpret_cast( + &_queryAgeReq_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(queryAgeReq& a, queryAgeReq& b) { + a.Swap(&b); + } + inline void Swap(queryAgeReq* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(queryAgeReq* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline queryAgeReq* New() const final { + return CreateMaybeMessage(nullptr); + } + + queryAgeReq* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const queryAgeReq& from); + void MergeFrom(const queryAgeReq& from); + 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; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) 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(queryAgeReq* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "queryAgeReq"; + } + protected: + explicit queryAgeReq(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_tinypb_2eproto); + return ::descriptor_table_tinypb_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kReqNoFieldNumber = 1, + kIdFieldNumber = 2, + }; + // int32 req_no = 1; + void clear_req_no(); + ::PROTOBUF_NAMESPACE_ID::int32 req_no() const; + void set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_req_no() const; + void _internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 id = 2; + void clear_id(); + ::PROTOBUF_NAMESPACE_ID::int32 id() const; + void set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_id() const; + void _internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:queryAgeReq) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::int32 req_no_; + ::PROTOBUF_NAMESPACE_ID::int32 id_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_tinypb_2eproto; +}; +// ------------------------------------------------------------------- + +class queryAgeRes PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:queryAgeRes) */ { + public: + inline queryAgeRes() : queryAgeRes(nullptr) {}; + virtual ~queryAgeRes(); + + queryAgeRes(const queryAgeRes& from); + queryAgeRes(queryAgeRes&& from) noexcept + : queryAgeRes() { + *this = ::std::move(from); + } + + inline queryAgeRes& operator=(const queryAgeRes& from) { + CopyFrom(from); + return *this; + } + inline queryAgeRes& operator=(queryAgeRes&& from) noexcept { + if (GetArena() == from.GetArena()) { + 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 queryAgeRes& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const queryAgeRes* internal_default_instance() { + return reinterpret_cast( + &_queryAgeRes_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(queryAgeRes& a, queryAgeRes& b) { + a.Swap(&b); + } + inline void Swap(queryAgeRes* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(queryAgeRes* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline queryAgeRes* New() const final { + return CreateMaybeMessage(nullptr); + } + + queryAgeRes* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const queryAgeRes& from); + void MergeFrom(const queryAgeRes& from); + 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; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) 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(queryAgeRes* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "queryAgeRes"; + } + protected: + explicit queryAgeRes(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_tinypb_2eproto); + return ::descriptor_table_tinypb_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kResInfoFieldNumber = 2, + kRetCodeFieldNumber = 1, + kReqNoFieldNumber = 3, + kIdFieldNumber = 4, + kAgeFieldNumber = 5, + }; + // string res_info = 2; + void clear_res_info(); + const std::string& res_info() const; + void set_res_info(const std::string& value); + void set_res_info(std::string&& value); + void set_res_info(const char* value); + void set_res_info(const char* value, size_t size); + std::string* mutable_res_info(); + std::string* release_res_info(); + void set_allocated_res_info(std::string* res_info); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_res_info(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_res_info( + std::string* res_info); + private: + const std::string& _internal_res_info() const; + void _internal_set_res_info(const std::string& value); + std::string* _internal_mutable_res_info(); + public: + + // int32 ret_code = 1; + void clear_ret_code(); + ::PROTOBUF_NAMESPACE_ID::int32 ret_code() const; + void set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_ret_code() const; + void _internal_set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 req_no = 3; + void clear_req_no(); + ::PROTOBUF_NAMESPACE_ID::int32 req_no() const; + void set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_req_no() const; + void _internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 id = 4; + void clear_id(); + ::PROTOBUF_NAMESPACE_ID::int32 id() const; + void set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_id() const; + void _internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 age = 5; + void clear_age(); + ::PROTOBUF_NAMESPACE_ID::int32 age() const; + void set_age(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_age() const; + void _internal_set_age(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:queryAgeRes) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr res_info_; + ::PROTOBUF_NAMESPACE_ID::int32 ret_code_; + ::PROTOBUF_NAMESPACE_ID::int32 req_no_; + ::PROTOBUF_NAMESPACE_ID::int32 id_; + ::PROTOBUF_NAMESPACE_ID::int32 age_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_tinypb_2eproto; +}; +// ------------------------------------------------------------------- + +class queryNameReq PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:queryNameReq) */ { + public: + inline queryNameReq() : queryNameReq(nullptr) {}; + virtual ~queryNameReq(); + + queryNameReq(const queryNameReq& from); + queryNameReq(queryNameReq&& from) noexcept + : queryNameReq() { + *this = ::std::move(from); + } + + inline queryNameReq& operator=(const queryNameReq& from) { + CopyFrom(from); + return *this; + } + inline queryNameReq& operator=(queryNameReq&& from) noexcept { + if (GetArena() == from.GetArena()) { + 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 queryNameReq& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const queryNameReq* internal_default_instance() { + return reinterpret_cast( + &_queryNameReq_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(queryNameReq& a, queryNameReq& b) { + a.Swap(&b); + } + inline void Swap(queryNameReq* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(queryNameReq* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline queryNameReq* New() const final { + return CreateMaybeMessage(nullptr); + } + + queryNameReq* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const queryNameReq& from); + void MergeFrom(const queryNameReq& from); + 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; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) 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(queryNameReq* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "queryNameReq"; + } + protected: + explicit queryNameReq(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_tinypb_2eproto); + return ::descriptor_table_tinypb_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kReqNoFieldNumber = 1, + kIdFieldNumber = 2, + kTypeFieldNumber = 3, + }; + // int32 req_no = 1; + void clear_req_no(); + ::PROTOBUF_NAMESPACE_ID::int32 req_no() const; + void set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_req_no() const; + void _internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 id = 2; + void clear_id(); + ::PROTOBUF_NAMESPACE_ID::int32 id() const; + void set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_id() const; + void _internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 type = 3; + void clear_type(); + ::PROTOBUF_NAMESPACE_ID::int32 type() const; + void set_type(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_type() const; + void _internal_set_type(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:queryNameReq) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::int32 req_no_; + ::PROTOBUF_NAMESPACE_ID::int32 id_; + ::PROTOBUF_NAMESPACE_ID::int32 type_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_tinypb_2eproto; +}; +// ------------------------------------------------------------------- + +class queryNameRes PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:queryNameRes) */ { + public: + inline queryNameRes() : queryNameRes(nullptr) {}; + virtual ~queryNameRes(); + + queryNameRes(const queryNameRes& from); + queryNameRes(queryNameRes&& from) noexcept + : queryNameRes() { + *this = ::std::move(from); + } + + inline queryNameRes& operator=(const queryNameRes& from) { + CopyFrom(from); + return *this; + } + inline queryNameRes& operator=(queryNameRes&& from) noexcept { + if (GetArena() == from.GetArena()) { + 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 queryNameRes& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const queryNameRes* internal_default_instance() { + return reinterpret_cast( + &_queryNameRes_default_instance_); + } + static constexpr int kIndexInFileMessages = + 3; + + friend void swap(queryNameRes& a, queryNameRes& b) { + a.Swap(&b); + } + inline void Swap(queryNameRes* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(queryNameRes* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline queryNameRes* New() const final { + return CreateMaybeMessage(nullptr); + } + + queryNameRes* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const queryNameRes& from); + void MergeFrom(const queryNameRes& from); + 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; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) 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(queryNameRes* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "queryNameRes"; + } + protected: + explicit queryNameRes(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_tinypb_2eproto); + return ::descriptor_table_tinypb_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kResInfoFieldNumber = 2, + kNameFieldNumber = 5, + kRetCodeFieldNumber = 1, + kReqNoFieldNumber = 3, + kIdFieldNumber = 4, + }; + // string res_info = 2; + void clear_res_info(); + const std::string& res_info() const; + void set_res_info(const std::string& value); + void set_res_info(std::string&& value); + void set_res_info(const char* value); + void set_res_info(const char* value, size_t size); + std::string* mutable_res_info(); + std::string* release_res_info(); + void set_allocated_res_info(std::string* res_info); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_res_info(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_res_info( + std::string* res_info); + private: + const std::string& _internal_res_info() const; + void _internal_set_res_info(const std::string& value); + std::string* _internal_mutable_res_info(); + public: + + // string name = 5; + 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); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_name(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_name( + std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: + + // int32 ret_code = 1; + void clear_ret_code(); + ::PROTOBUF_NAMESPACE_ID::int32 ret_code() const; + void set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_ret_code() const; + void _internal_set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 req_no = 3; + void clear_req_no(); + ::PROTOBUF_NAMESPACE_ID::int32 req_no() const; + void set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_req_no() const; + void _internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 id = 4; + void clear_id(); + ::PROTOBUF_NAMESPACE_ID::int32 id() const; + void set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_id() const; + void _internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:queryNameRes) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr res_info_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::int32 ret_code_; + ::PROTOBUF_NAMESPACE_ID::int32 req_no_; + ::PROTOBUF_NAMESPACE_ID::int32 id_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_tinypb_2eproto; +}; +// =================================================================== + +class QueryService_Stub; + +class QueryService : public ::PROTOBUF_NAMESPACE_ID::Service { + protected: + // This class should be treated as an abstract interface. + inline QueryService() {}; + public: + virtual ~QueryService(); + + typedef QueryService_Stub Stub; + + static const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor* descriptor(); + + virtual void query_name(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryNameReq* request, + ::queryNameRes* response, + ::google::protobuf::Closure* done); + virtual void query_age(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryAgeReq* request, + ::queryAgeRes* response, + ::google::protobuf::Closure* done); + + // implements Service ---------------------------------------------- + + const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor* GetDescriptor(); + void CallMethod(const ::PROTOBUF_NAMESPACE_ID::MethodDescriptor* method, + ::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::PROTOBUF_NAMESPACE_ID::Message* request, + ::PROTOBUF_NAMESPACE_ID::Message* response, + ::google::protobuf::Closure* done); + const ::PROTOBUF_NAMESPACE_ID::Message& GetRequestPrototype( + const ::PROTOBUF_NAMESPACE_ID::MethodDescriptor* method) const; + const ::PROTOBUF_NAMESPACE_ID::Message& GetResponsePrototype( + const ::PROTOBUF_NAMESPACE_ID::MethodDescriptor* method) const; + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(QueryService); +}; + +class QueryService_Stub : public QueryService { + public: + QueryService_Stub(::PROTOBUF_NAMESPACE_ID::RpcChannel* channel); + QueryService_Stub(::PROTOBUF_NAMESPACE_ID::RpcChannel* channel, + ::PROTOBUF_NAMESPACE_ID::Service::ChannelOwnership ownership); + ~QueryService_Stub(); + + inline ::PROTOBUF_NAMESPACE_ID::RpcChannel* channel() { return channel_; } + + // implements QueryService ------------------------------------------ + + void query_name(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryNameReq* request, + ::queryNameRes* response, + ::google::protobuf::Closure* done); + void query_age(::PROTOBUF_NAMESPACE_ID::RpcController* controller, + const ::queryAgeReq* request, + ::queryAgeRes* response, + ::google::protobuf::Closure* done); + private: + ::PROTOBUF_NAMESPACE_ID::RpcChannel* channel_; + bool owns_channel_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(QueryService_Stub); +}; + + +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// queryAgeReq + +// int32 req_no = 1; +inline void queryAgeReq::clear_req_no() { + req_no_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeReq::_internal_req_no() const { + return req_no_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeReq::req_no() const { + // @@protoc_insertion_point(field_get:queryAgeReq.req_no) + return _internal_req_no(); +} +inline void queryAgeReq::_internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + + req_no_ = value; +} +inline void queryAgeReq::set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_req_no(value); + // @@protoc_insertion_point(field_set:queryAgeReq.req_no) +} + +// int32 id = 2; +inline void queryAgeReq::clear_id() { + id_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeReq::_internal_id() const { + return id_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeReq::id() const { + // @@protoc_insertion_point(field_get:queryAgeReq.id) + return _internal_id(); +} +inline void queryAgeReq::_internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + + id_ = value; +} +inline void queryAgeReq::set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:queryAgeReq.id) +} + +// ------------------------------------------------------------------- + +// queryAgeRes + +// int32 ret_code = 1; +inline void queryAgeRes::clear_ret_code() { + ret_code_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::_internal_ret_code() const { + return ret_code_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::ret_code() const { + // @@protoc_insertion_point(field_get:queryAgeRes.ret_code) + return _internal_ret_code(); +} +inline void queryAgeRes::_internal_set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value) { + + ret_code_ = value; +} +inline void queryAgeRes::set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_ret_code(value); + // @@protoc_insertion_point(field_set:queryAgeRes.ret_code) +} + +// string res_info = 2; +inline void queryAgeRes::clear_res_info() { + res_info_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline const std::string& queryAgeRes::res_info() const { + // @@protoc_insertion_point(field_get:queryAgeRes.res_info) + return _internal_res_info(); +} +inline void queryAgeRes::set_res_info(const std::string& value) { + _internal_set_res_info(value); + // @@protoc_insertion_point(field_set:queryAgeRes.res_info) +} +inline std::string* queryAgeRes::mutable_res_info() { + // @@protoc_insertion_point(field_mutable:queryAgeRes.res_info) + return _internal_mutable_res_info(); +} +inline const std::string& queryAgeRes::_internal_res_info() const { + return res_info_.Get(); +} +inline void queryAgeRes::_internal_set_res_info(const std::string& value) { + + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void queryAgeRes::set_res_info(std::string&& value) { + + res_info_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:queryAgeRes.res_info) +} +inline void queryAgeRes::set_res_info(const char* value) { + GOOGLE_DCHECK(value != nullptr); + + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:queryAgeRes.res_info) +} +inline void queryAgeRes::set_res_info(const char* value, + size_t size) { + + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:queryAgeRes.res_info) +} +inline std::string* queryAgeRes::_internal_mutable_res_info() { + + return res_info_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* queryAgeRes::release_res_info() { + // @@protoc_insertion_point(field_release:queryAgeRes.res_info) + return res_info_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void queryAgeRes::set_allocated_res_info(std::string* res_info) { + if (res_info != nullptr) { + + } else { + + } + res_info_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), res_info, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:queryAgeRes.res_info) +} +inline std::string* queryAgeRes::unsafe_arena_release_res_info() { + // @@protoc_insertion_point(field_unsafe_arena_release:queryAgeRes.res_info) + GOOGLE_DCHECK(GetArena() != nullptr); + + return res_info_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void queryAgeRes::unsafe_arena_set_allocated_res_info( + std::string* res_info) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (res_info != nullptr) { + + } else { + + } + res_info_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + res_info, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:queryAgeRes.res_info) +} + +// int32 req_no = 3; +inline void queryAgeRes::clear_req_no() { + req_no_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::_internal_req_no() const { + return req_no_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::req_no() const { + // @@protoc_insertion_point(field_get:queryAgeRes.req_no) + return _internal_req_no(); +} +inline void queryAgeRes::_internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + + req_no_ = value; +} +inline void queryAgeRes::set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_req_no(value); + // @@protoc_insertion_point(field_set:queryAgeRes.req_no) +} + +// int32 id = 4; +inline void queryAgeRes::clear_id() { + id_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::_internal_id() const { + return id_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::id() const { + // @@protoc_insertion_point(field_get:queryAgeRes.id) + return _internal_id(); +} +inline void queryAgeRes::_internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + + id_ = value; +} +inline void queryAgeRes::set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:queryAgeRes.id) +} + +// int32 age = 5; +inline void queryAgeRes::clear_age() { + age_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::_internal_age() const { + return age_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryAgeRes::age() const { + // @@protoc_insertion_point(field_get:queryAgeRes.age) + return _internal_age(); +} +inline void queryAgeRes::_internal_set_age(::PROTOBUF_NAMESPACE_ID::int32 value) { + + age_ = value; +} +inline void queryAgeRes::set_age(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_age(value); + // @@protoc_insertion_point(field_set:queryAgeRes.age) +} + +// ------------------------------------------------------------------- + +// queryNameReq + +// int32 req_no = 1; +inline void queryNameReq::clear_req_no() { + req_no_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameReq::_internal_req_no() const { + return req_no_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameReq::req_no() const { + // @@protoc_insertion_point(field_get:queryNameReq.req_no) + return _internal_req_no(); +} +inline void queryNameReq::_internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + + req_no_ = value; +} +inline void queryNameReq::set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_req_no(value); + // @@protoc_insertion_point(field_set:queryNameReq.req_no) +} + +// int32 id = 2; +inline void queryNameReq::clear_id() { + id_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameReq::_internal_id() const { + return id_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameReq::id() const { + // @@protoc_insertion_point(field_get:queryNameReq.id) + return _internal_id(); +} +inline void queryNameReq::_internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + + id_ = value; +} +inline void queryNameReq::set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:queryNameReq.id) +} + +// int32 type = 3; +inline void queryNameReq::clear_type() { + type_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameReq::_internal_type() const { + return type_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameReq::type() const { + // @@protoc_insertion_point(field_get:queryNameReq.type) + return _internal_type(); +} +inline void queryNameReq::_internal_set_type(::PROTOBUF_NAMESPACE_ID::int32 value) { + + type_ = value; +} +inline void queryNameReq::set_type(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:queryNameReq.type) +} + +// ------------------------------------------------------------------- + +// queryNameRes + +// int32 ret_code = 1; +inline void queryNameRes::clear_ret_code() { + ret_code_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameRes::_internal_ret_code() const { + return ret_code_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameRes::ret_code() const { + // @@protoc_insertion_point(field_get:queryNameRes.ret_code) + return _internal_ret_code(); +} +inline void queryNameRes::_internal_set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value) { + + ret_code_ = value; +} +inline void queryNameRes::set_ret_code(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_ret_code(value); + // @@protoc_insertion_point(field_set:queryNameRes.ret_code) +} + +// string res_info = 2; +inline void queryNameRes::clear_res_info() { + res_info_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline const std::string& queryNameRes::res_info() const { + // @@protoc_insertion_point(field_get:queryNameRes.res_info) + return _internal_res_info(); +} +inline void queryNameRes::set_res_info(const std::string& value) { + _internal_set_res_info(value); + // @@protoc_insertion_point(field_set:queryNameRes.res_info) +} +inline std::string* queryNameRes::mutable_res_info() { + // @@protoc_insertion_point(field_mutable:queryNameRes.res_info) + return _internal_mutable_res_info(); +} +inline const std::string& queryNameRes::_internal_res_info() const { + return res_info_.Get(); +} +inline void queryNameRes::_internal_set_res_info(const std::string& value) { + + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void queryNameRes::set_res_info(std::string&& value) { + + res_info_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:queryNameRes.res_info) +} +inline void queryNameRes::set_res_info(const char* value) { + GOOGLE_DCHECK(value != nullptr); + + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:queryNameRes.res_info) +} +inline void queryNameRes::set_res_info(const char* value, + size_t size) { + + res_info_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:queryNameRes.res_info) +} +inline std::string* queryNameRes::_internal_mutable_res_info() { + + return res_info_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* queryNameRes::release_res_info() { + // @@protoc_insertion_point(field_release:queryNameRes.res_info) + return res_info_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void queryNameRes::set_allocated_res_info(std::string* res_info) { + if (res_info != nullptr) { + + } else { + + } + res_info_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), res_info, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:queryNameRes.res_info) +} +inline std::string* queryNameRes::unsafe_arena_release_res_info() { + // @@protoc_insertion_point(field_unsafe_arena_release:queryNameRes.res_info) + GOOGLE_DCHECK(GetArena() != nullptr); + + return res_info_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void queryNameRes::unsafe_arena_set_allocated_res_info( + std::string* res_info) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (res_info != nullptr) { + + } else { + + } + res_info_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + res_info, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:queryNameRes.res_info) +} + +// int32 req_no = 3; +inline void queryNameRes::clear_req_no() { + req_no_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameRes::_internal_req_no() const { + return req_no_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameRes::req_no() const { + // @@protoc_insertion_point(field_get:queryNameRes.req_no) + return _internal_req_no(); +} +inline void queryNameRes::_internal_set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + + req_no_ = value; +} +inline void queryNameRes::set_req_no(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_req_no(value); + // @@protoc_insertion_point(field_set:queryNameRes.req_no) +} + +// int32 id = 4; +inline void queryNameRes::clear_id() { + id_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameRes::_internal_id() const { + return id_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 queryNameRes::id() const { + // @@protoc_insertion_point(field_get:queryNameRes.id) + return _internal_id(); +} +inline void queryNameRes::_internal_set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + + id_ = value; +} +inline void queryNameRes::set_id(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_id(value); + // @@protoc_insertion_point(field_set:queryNameRes.id) +} + +// string name = 5; +inline void queryNameRes::clear_name() { + name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline const std::string& queryNameRes::name() const { + // @@protoc_insertion_point(field_get:queryNameRes.name) + return _internal_name(); +} +inline void queryNameRes::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:queryNameRes.name) +} +inline std::string* queryNameRes::mutable_name() { + // @@protoc_insertion_point(field_mutable:queryNameRes.name) + return _internal_mutable_name(); +} +inline const std::string& queryNameRes::_internal_name() const { + return name_.Get(); +} +inline void queryNameRes::_internal_set_name(const std::string& value) { + + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void queryNameRes::set_name(std::string&& value) { + + name_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:queryNameRes.name) +} +inline void queryNameRes::set_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:queryNameRes.name) +} +inline void queryNameRes::set_name(const char* value, + size_t size) { + + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:queryNameRes.name) +} +inline std::string* queryNameRes::_internal_mutable_name() { + + return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* queryNameRes::release_name() { + // @@protoc_insertion_point(field_release:queryNameRes.name) + return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void queryNameRes::set_allocated_name(std::string* name) { + if (name != nullptr) { + + } else { + + } + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:queryNameRes.name) +} +inline std::string* queryNameRes::unsafe_arena_release_name() { + // @@protoc_insertion_point(field_unsafe_arena_release:queryNameRes.name) + GOOGLE_DCHECK(GetArena() != nullptr); + + return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void queryNameRes::unsafe_arena_set_allocated_name( + std::string* name) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (name != nullptr) { + + } else { + + } + name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + name, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:queryNameRes.name) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_tinypb_2eproto diff --git a/test/servertest/tinypb.proto b/test/servertest/tinypb.proto new file mode 100644 index 0000000..90597dd --- /dev/null +++ b/test/servertest/tinypb.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +option cc_generic_services = true; + +message queryAgeReq { + int32 req_no = 1; + int32 id = 2; +} + +message queryAgeRes { + int32 ret_code = 1; + string res_info = 2; + int32 req_no = 3; + int32 id = 4; + int32 age = 5; +} + +message queryNameReq { + int32 req_no = 1; + int32 id = 2; + int32 type = 3; +} + +message queryNameRes { + int32 ret_code = 1; + string res_info = 2; + int32 req_no = 3; + int32 id = 4; + string name = 5; +} + + +service QueryService { + // rpc method name + rpc query_name(queryNameReq) returns (queryNameRes); + + // rpc method name + rpc query_age(queryAgeReq) returns (queryAgeRes); +} \ No newline at end of file diff --git a/test/tcp_connection.cc b/test/tcp_connection.cc new file mode 100644 index 0000000..1d495e2 --- /dev/null +++ b/test/tcp_connection.cc @@ -0,0 +1,173 @@ +// #include "tcp_connection.hpp" +// #include "abstract_coder.hpp" +// #include "coroutine_hook.hpp" +// #include "fd_event.hpp" +// #include "logger.hpp" +// #include "reactor.hpp" +// #include "tcp_client.hpp" +// #include "tcp_server.hpp" +// #include "tinypb_data.hpp" +// #include +// #include +// #include +// #include +// #include + + +// namespace tinyrpc { +// TcpConnection::TcpConnection(int fd, Reactor& reactor, TcpServer& ser, Type type) : +// m_fdEvent(FdEventPool::getInstance()->getFdEvent(fd)), +// m_mainCoroutine(std::bind(&TcpConnection::mainLoopFun, this)), +// m_reactor(reactor), +// m_server(ser), +// m_connectType(type) +// { +// Reactor::Task task = [this] { +// logger() << "conn coroutine is resume"; +// m_mainCoroutine.resume(); +// }; + +// reactor.addTask(task, true); + +// } + + + +// void TcpConnection::mainLoopFun() { +// while(m_state == State::Connected) { +// input(); +// process(); +// output(); +// } +// logger() << "this conn loop has already break"; +// } + +// void TcpConnection::clearClient() { +// logger() << "clearClient"; +// m_state = State::Disconnected; +// m_reactor.delFdEvent(m_fdEvent); +// m_fdEvent->reset(); +// close(m_fdEvent->getFd()); +// } + + +// void TcpConnection::input() { // 调用 read_hook 读数据到应用层缓冲区 +// logger() << "input"; +// if(m_state == State::Disconnected) { +// logger() << "input: this conn has already break"; +// return; +// } + + +// while(true) { +// if(m_readBuffer.getWriteable() == 0) { +// m_readBuffer.dilatation(); +// } + +// int ret = read_hook(m_fdEvent->getFd(), m_readBuffer.getWriteAddress(), m_readBuffer.getWriteable()); +// if(ret == -1) { +// logger() << "read_hook ret -1 err:" << strerror(errno); +// // if(errno == EAGAIN) exit(-1); +// break; + +// } else if(ret == 0) { // 对端关闭了连接 +// clearClient(); +// break; +// } else { +// int writeable = m_readBuffer.getWriteable(); +// m_readBuffer.writeOffset(ret); +// logger() << "input_hook ret: " << ret; + +// if(ret < writeable) { // 读完了结束循环 +// break; +// } + +// } + +// } + + +// } +// void TcpConnection::output() { +// logger() << "output"; +// if(m_state == State::Disconnected) { +// return; +// } + +// while(true) { +// if(m_writeBuffer.getReadable() == 0) { +// logger() << "no data need send"; +// break; +// } + +// int ret = write_hook(m_fdEvent->getFd(), m_writeBuffer.getReadAddress(), m_writeBuffer.getReadable()); +// if(ret == -1) { +// logger() << "read_hook ret -1 err:" << strerror(errno); +// break; + +// } else if(ret == 0) { +// logger() << "write_hook ret 0"; +// break; +// } else { +// m_writeBuffer.readOffset(ret); +// } +// logger() << "write_hook ret: " << ret; +// } + + +// } + +// void TcpConnection::process() { +// logger() << "process"; + +// // if(m_state == State::Disconnected) { +// // return; +// // } +// // if(m_writeBuffer.getWriteable() < m_readBuffer.getReadable()) { +// // m_writeBuffer.resize(m_readBuffer.getReadable() * 2); +// // } +// // std::memcpy(m_writeBuffer.getWriteAddress(), m_readBuffer.getReadAddress(), m_readBuffer.getReadable()); +// // m_writeBuffer.writeOffset(m_readBuffer.getReadable()); +// // m_readBuffer.readOffset(m_readBuffer.getReadable()); + +// // logger() << "write data " << m_writeBuffer.getReadable() << " byte"; + +// while(m_readBuffer.getReadable() > 0) { +// std::shared_ptr data(new TinypbData); + +// bool ret = m_server.getCoder().decoder(m_readBuffer, *data); +// if(ret == false) { +// logger() << "decode error"; +// break; +// } +// if(m_connectType == Type::Server) { +// std::unique_ptr resp(new TinypbData); +// m_server.getDispatcher().dispatcher(*this, *data, *resp); +// m_server.getCoder().encoder(m_writeBuffer, *resp); +// } else { +// std::shared_ptr tmp = std::dynamic_pointer_cast(data); +// m_respond_datas[tmp->msg_req] = data; +// } + + +// } + +// } + +// bool TcpConnection::getResPackageData(const std::string& msg_req, std::shared_ptr& pb_struct) { +// auto it = m_respond_datas.find(msg_req); +// if(it == m_respond_datas.end()) return false; +// pb_struct = it->second; +// m_respond_datas.erase(it); +// return true; +// } + +// TcpConnection::~TcpConnection() { +// if(m_state == State::Connected) { +// clearClient(); +// } + +// logger() << "TcpConnection fd " << m_fdEvent->getFd() << " destructor"; +// } + +// } \ No newline at end of file diff --git a/test/tcp_connection.hpp b/test/tcp_connection.hpp new file mode 100644 index 0000000..2b04051 --- /dev/null +++ b/test/tcp_connection.hpp @@ -0,0 +1,52 @@ +// #pragma once +// #include "abstract_coder.hpp" +// #include "coroutine.hpp" +// #include "fd_event.hpp" +// #include "reactor.hpp" +// #include "tcp_buffer.hpp" +// #include "tcp_client.hpp" +// #include "tinypb_data.hpp" +// #include +// #include + +// namespace tinyrpc { +// class TcpServer; +// class TcpConnection { +// public: +// enum class State{ +// Disconnected, +// Connected +// }; +// enum class Type{ +// Server, +// Client +// }; + +// public: +// TcpConnection(int fd, Reactor& reactor, TcpServer& ser, Type type = Type::Server); +// TcpConnection(int fd, Reactor& reactor, TcpClient& cli, Type type = Type::Client); +// void clearClient(); +// void mainLoopFun(); +// State getState() {return m_state;} +// bool getResPackageData(const std::string& msg_req, std::shared_ptr& pb_struct); +// ~TcpConnection(); + +// private: +// void input(); +// void output(); +// void process(); + +// private: +// FdEvent *m_fdEvent; +// Coroutine m_mainCoroutine; +// State m_state{State::Connected}; +// TcpBuffer m_writeBuffer{}; +// TcpBuffer m_readBuffer{}; +// Reactor& m_reactor; +// TcpServer& m_server; +// // TcpClient& m_server; +// Type m_connectType{}; +// std::unordered_map> m_respond_datas; +// }; + +// } \ No newline at end of file