C++ protobuf can';不能连载

C++ protobuf can';不能连载,c++,serialization,protocol-buffers,C++,Serialization,Protocol Buffers,你好,eyeryone 我的protobuf版本是2.5.0,生成的头文件只包含一个SerializeWithCachedSizes方法,我想将protobuf对象序列化为char数组,并通过套接字发布数组。在很多教程中提到了一个方法SerializeToArray方法,我只需要这个方法,但是为什么我的头文件不包含这个方法呢? 第一次使用protobuf,不熟悉。如果有人能解决这个问题,请给我详细的代码 原始文件为: package ddz.proto; option optimize_for

你好,eyeryone

我的protobuf版本是2.5.0,生成的头文件只包含一个
SerializeWithCachedSizes
方法,我想将protobuf对象序列化为char数组,并通过套接字发布数组。在很多教程中提到了一个方法
SerializeToArray
方法,我只需要这个方法,但是为什么我的头文件不包含这个方法呢?
第一次使用protobuf,不熟悉。如果有人能解决这个问题,请给我详细的代码

原始文件为:

package ddz.proto;

option optimize_for = LITE_RUNTIME;
option java_package = "ddz.proto";
option java_outer_classname = "Login";

message LoginMessage {
    optional string userAccount = 1;
}
并且生成的头文件为:

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: hello.proto

#ifndef PROTOBUF_hello_2eproto__INCLUDED
#define PROTOBUF_hello_2eproto__INCLUDED

#include <string>

#include <google/protobuf/stubs/common.h>

#if GOOGLE_PROTOBUF_VERSION < 2005000
#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 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
#endif

#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
// @@protoc_insertion_point(includes)

namespace ddz {
namespace proto {

// Internal implementation detail -- do not call these.
void  protobuf_AddDesc_hello_2eproto();
void protobuf_AssignDesc_hello_2eproto();
void protobuf_ShutdownFile_hello_2eproto();

class LoginMessage;

// ===================================================================

class LoginMessage : public ::google::protobuf::MessageLite {
 public:
  LoginMessage();
  virtual ~LoginMessage();

  LoginMessage(const LoginMessage& from);

  inline LoginMessage& operator=(const LoginMessage& from) {
    CopyFrom(from);
    return *this;
  }

  static const LoginMessage& default_instance();

  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
  // Returns the internal default instance pointer. This function can
  // return NULL thus should not be used by the user. This is intended
  // for Protobuf internal code. Please use default_instance() declared
  // above instead.
  static inline const LoginMessage* internal_default_instance() {
    return default_instance_;
  }
  #endif

  void Swap(LoginMessage* other);

  // implements Message ----------------------------------------------

  LoginMessage* New() const;
  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
  void CopyFrom(const LoginMessage& from);
  void MergeFrom(const LoginMessage& from);
  void Clear();
  bool IsInitialized() const;

  int ByteSize() const;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input);
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const;
  int GetCachedSize() const { return _cached_size_; }
  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const;
  public:

  ::std::string GetTypeName() const;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional string userAccount = 1;
  inline bool has_useraccount() const;
  inline void clear_useraccount();
  static const int kUserAccountFieldNumber = 1;
  inline const ::std::string& useraccount() const;
  inline void set_useraccount(const ::std::string& value);
  inline void set_useraccount(const char* value);
  inline void set_useraccount(const char* value, size_t size);
  inline ::std::string* mutable_useraccount();
  inline ::std::string* release_useraccount();
  inline void set_allocated_useraccount(::std::string* useraccount);

  // @@protoc_insertion_point(class_scope:ddz.proto.LoginMessage)
 private:
  inline void set_has_useraccount();
  inline void clear_has_useraccount();

  ::std::string* useraccount_;

  mutable int _cached_size_;
  ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];

  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
  friend void  protobuf_AddDesc_hello_2eproto_impl();
  #else
  friend void  protobuf_AddDesc_hello_2eproto();
  #endif
  friend void protobuf_AssignDesc_hello_2eproto();
  friend void protobuf_ShutdownFile_hello_2eproto();

  void InitAsDefaultInstance();
  static LoginMessage* default_instance_;
};
// ===================================================================


// ===================================================================

// LoginMessage

// optional string userAccount = 1;
inline bool LoginMessage::has_useraccount() const {
  return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void LoginMessage::set_has_useraccount() {
  _has_bits_[0] |= 0x00000001u;
}
inline void LoginMessage::clear_has_useraccount() {
  _has_bits_[0] &= ~0x00000001u;
}
inline void LoginMessage::clear_useraccount() {
  if (useraccount_ != &::google::protobuf::internal::kEmptyString) {
    useraccount_->clear();
  }
  clear_has_useraccount();
}
inline const ::std::string& LoginMessage::useraccount() const {
  return *useraccount_;
}
inline void LoginMessage::set_useraccount(const ::std::string& value) {
  set_has_useraccount();
  if (useraccount_ == &::google::protobuf::internal::kEmptyString) {
    useraccount_ = new ::std::string;
  }
  useraccount_->assign(value);
}
inline void LoginMessage::set_useraccount(const char* value) {
  set_has_useraccount();
  if (useraccount_ == &::google::protobuf::internal::kEmptyString) {
    useraccount_ = new ::std::string;
  }
  useraccount_->assign(value);
}
inline void LoginMessage::set_useraccount(const char* value, size_t size) {
  set_has_useraccount();
  if (useraccount_ == &::google::protobuf::internal::kEmptyString) {
    useraccount_ = new ::std::string;
  }
  useraccount_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* LoginMessage::mutable_useraccount() {
  set_has_useraccount();
  if (useraccount_ == &::google::protobuf::internal::kEmptyString) {
    useraccount_ = new ::std::string;
  }
  return useraccount_;
}
inline ::std::string* LoginMessage::release_useraccount() {
  clear_has_useraccount();
  if (useraccount_ == &::google::protobuf::internal::kEmptyString) {
    return NULL;
  } else {
    ::std::string* temp = useraccount_;
    useraccount_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
    return temp;
  }
}
inline void LoginMessage::set_allocated_useraccount(::std::string* useraccount) {
  if (useraccount_ != &::google::protobuf::internal::kEmptyString) {
    delete useraccount_;
  }
  if (useraccount) {
    set_has_useraccount();
    useraccount_ = useraccount;
  } else {
    clear_has_useraccount();
    useraccount_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
  }
}


// @@protoc_insertion_point(namespace_scope)

}  // namespace proto
}  // namespace ddz

// @@protoc_insertion_point(global_scope)

#endif  // PROTOBUF_hello_2eproto__INCLUDED
//由协议缓冲区编译器生成。不要编辑!
//来源:hello.proto
#如果不包括PROTOBUF\u hello\u 2 Protobu\u
#定义PROTOBUF_hello_2包括proto_
#包括
#包括
#如果GOOGLE_PROTOBUF_版本<2005000
#错误此文件是由更新版本的protoc生成的,它是
#与协议缓冲区标头不兼容的错误。请更新
#错误的标题。
#恩迪夫
#如果2005000清除();
}
clear_has_useraccount();
}
内联常量::std::string&LoginMessage::useraccount()常量{
return*useraccount\ux;
}
内联void LoginMessage::set_useraccount(const::std::string&value){
set_有_useraccount();
if(useraccount_==&::google::protobuf::internal::kEmptyString){
useraccount=新::标准::字符串;
}
用户帐户->分配(值);
}
内联void LoginMessage::set_useraccount(const char*value){
set_有_useraccount();
if(useraccount_==&::google::protobuf::internal::kEmptyString){
useraccount=新::标准::字符串;
}
用户帐户->分配(值);
}
内联void LoginMessage::set_useraccount(常量字符*值,大小){
set_有_useraccount();
if(useraccount_==&::google::protobuf::internal::kEmptyString){
useraccount=新::标准::字符串;
}
用户帐户->分配(重新解释类型(值)、大小);
}
内联::标准::字符串*登录消息::可变用户帐户(){
set_有_useraccount();
if(userac)