Commit fc4b5568 by songxinkai

~

parent 19579d97
#include <fstream>
#include <iostream>
#include <string>
#define max_step 2000
#define fea_len 1377
#define pi_len 82
using namespace std;
int main(){
// int out_games = 1;
// int out_steps = 2;
// int out_winner = 1;
// unsigned char* out_feas = new unsigned char [fea_len*out_steps];
// float* out_pis = new float [pi_len * out_steps];
// for (int i = 0; i < out_steps; ++i){
// for (int j = 0; j < fea_len; ++j){
// out_feas[i*fea_len+j] = j % (i+2) == 0 ? 1 : 0;
// }
// }
// string fea_path = "fake.features";
// ofstream output(fea_path, ios::out | ios::binary);
// output.write((char*)&out_games, sizeof(int));
// for (int game_id = 0; game_id < out_games; game_id ++){
// output.write((char*)&out_steps, sizeof(int));
// output.write((char*)&out_winner, sizeof(int));
// output.write((char*)out_feas, sizeof(unsigned char) * fea_len * out_steps);
// output.write((char*)out_pis, sizeof(float) * pi_len*out_steps);
// }
// output.close();
int mv_games = -1;
int mv_steps = -1;
int mv_winner = -1;
uint16_t* moves = new uint16_t [max_step];
uint16_t* visit_counts = new uint16_t [(9*9+1)*max_step];
string moves_path = "/share/selfplay_data_go9/agz9_selfplay_zhuque_25071.moves";
// string moves_path = "/root/agz9_selfplay_zhuque_24773.moves";
ifstream mv_input(moves_path, ios::in | ios::binary);
mv_input.read((char*)&mv_games, sizeof(int));
cout << "mv_games: " << mv_games << endl;
for (int game_id = 0; game_id < mv_games; game_id ++){
mv_input.read((char*)&mv_steps, sizeof(int));
mv_input.read((char*)&mv_winner, sizeof(int));
mv_input.read((char*)moves, sizeof(uint16_t) * mv_steps);
mv_input.read((char*)visit_counts, sizeof(uint16_t) * (9*9+1)*mv_steps);
cout << "game " << game_id << ", mv_steps: " << mv_steps << ", mv_winner: " << mv_winner << endl;
}
mv_input.close();
cout << "================================== " << endl;
int fea_games = -1;
int fea_steps = -1;
int fea_winner = -1;
unsigned char* feas = new unsigned char[fea_len*max_step];
float* pis = new float[pi_len*max_step];
//string fea_path = "/share/data/go_9/train/using/agz9_selfplay_zhuque_23122.moves.features";
string fea_path = "/share/data/go_9/train/using/agz9_selfplay_zhuque_24773.moves.features";
ifstream fea_input(fea_path, ios::in | ios::binary);
fea_input.read((char*)&fea_games, sizeof(int));
cout << "fea_games: " << fea_games << endl;
for (int game_id = 0; game_id < fea_games; game_id ++){
fea_input.read((char*)&fea_steps, sizeof(int));
fea_input.read((char*)&fea_winner, sizeof(int));
if (fea_steps == 0){
cout << "steps: " << fea_steps << endl;
}
fea_input.read((char*)feas, sizeof(unsigned char) * fea_len*fea_steps);
fea_input.read((char*)pis, sizeof(float) * pi_len*fea_steps);
cout << "game " << game_id << ", fea_steps: " << fea_steps << ", fea_winner: " << fea_winner << endl;
// for (int step_id = 0; step_id < fea_steps; ++ step_id){
// cout << " step: " << ", feas: " << int(feas[0]);
// for (int i = 1; i < fea_len && i < 10; ++i){
// cout << ", " << int(feas[step_id * fea_len + i]);
// }
// cout << endl;
// }
}
fea_input.close();
return 0;
}
syntax = "proto3"; syntax = "proto2";
package eden; package eden;
message pigs{ message pigs{
int32 count = 1; int32 count = 1;
......
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: family.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "family.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
namespace {
const ::google::protobuf::Descriptor* Person_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
Person_reflection_ = NULL;
const ::google::protobuf::Descriptor* Family_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
Family_reflection_ = NULL;
} // namespace
void protobuf_AssignDesc_family_2eproto() {
protobuf_AddDesc_family_2eproto();
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"family.proto");
GOOGLE_CHECK(file != NULL);
Person_descriptor_ = file->message_type(0);
static const int Person_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, age_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, name_),
};
Person_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
Person_descriptor_,
Person::default_instance_,
Person_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(Person));
Family_descriptor_ = file->message_type(1);
static const int Family_offsets_[1] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Family, person_),
};
Family_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
Family_descriptor_,
Family::default_instance_,
Family_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Family, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Family, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(Family));
}
namespace {
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
inline void protobuf_AssignDescriptorsOnce() {
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
&protobuf_AssignDesc_family_2eproto);
}
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
Person_descriptor_, &Person::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
Family_descriptor_, &Family::default_instance());
}
} // namespace
void protobuf_ShutdownFile_family_2eproto() {
delete Person::default_instance_;
delete Person_reflection_;
delete Family::default_instance_;
delete Family_reflection_;
}
void protobuf_AddDesc_family_2eproto() {
static bool already_here = false;
if (already_here) return;
already_here = true;
GOOGLE_PROTOBUF_VERIFY_VERSION;
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\014family.proto\"#\n\006Person\022\013\n\003age\030\001 \002(\005\022\014\n"
"\004name\030\002 \002(\t\"!\n\006Family\022\027\n\006person\030\001 \003(\0132\007."
"Person", 86);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"family.proto", &protobuf_RegisterTypes);
Person::default_instance_ = new Person();
Family::default_instance_ = new Family();
Person::default_instance_->InitAsDefaultInstance();
Family::default_instance_->InitAsDefaultInstance();
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_family_2eproto);
}
// Force AddDescriptors() to be called at static initialization time.
struct StaticDescriptorInitializer_family_2eproto {
StaticDescriptorInitializer_family_2eproto() {
protobuf_AddDesc_family_2eproto();
}
} static_descriptor_initializer_family_2eproto_;
// ===================================================================
#ifndef _MSC_VER
const int Person::kAgeFieldNumber;
const int Person::kNameFieldNumber;
#endif // !_MSC_VER
Person::Person()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:Person)
}
void Person::InitAsDefaultInstance() {
}
Person::Person(const Person& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:Person)
}
void Person::SharedCtor() {
::google::protobuf::internal::GetEmptyString();
_cached_size_ = 0;
age_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
Person::~Person() {
// @@protoc_insertion_point(destructor:Person)
SharedDtor();
}
void Person::SharedDtor() {
if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete name_;
}
if (this != default_instance_) {
}
}
void Person::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Person::descriptor() {
protobuf_AssignDescriptorsOnce();
return Person_descriptor_;
}
const Person& Person::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_family_2eproto();
return *default_instance_;
}
Person* Person::default_instance_ = NULL;
Person* Person::New() const {
return new Person;
}
void Person::Clear() {
if (_has_bits_[0 / 32] & 3) {
age_ = 0;
if (has_name()) {
if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
name_->clear();
}
}
}
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool Person::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:Person)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required int32 age = 1;
case 1: {
if (tag == 8) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &age_)));
set_has_age();
} else {
goto handle_unusual;
}
if (input->ExpectTag(18)) goto parse_name;
break;
}
// required string name = 2;
case 2: {
if (tag == 18) {
parse_name:
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::PARSE,
"name");
} else {
goto handle_unusual;
}
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:Person)
return true;
failure:
// @@protoc_insertion_point(parse_failure:Person)
return false;
#undef DO_
}
void Person::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:Person)
// required int32 age = 1;
if (has_age()) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->age(), output);
}
// required string name = 2;
if (has_name()) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
2, this->name(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:Person)
}
::google::protobuf::uint8* Person::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:Person)
// required int32 age = 1;
if (has_age()) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->age(), target);
}
// required string name = 2;
if (has_name()) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
"name");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this->name(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:Person)
return target;
}
int Person::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// required int32 age = 1;
if (has_age()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->age());
}
// required string name = 2;
if (has_name()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void Person::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const Person* source =
::google::protobuf::internal::dynamic_cast_if_available<const Person*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void Person::MergeFrom(const Person& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_age()) {
set_age(from.age());
}
if (from.has_name()) {
set_name(from.name());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void Person::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Person::CopyFrom(const Person& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Person::IsInitialized() const {
if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
return true;
}
void Person::Swap(Person* other) {
if (other != this) {
std::swap(age_, other->age_);
std::swap(name_, other->name_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata Person::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = Person_descriptor_;
metadata.reflection = Person_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
const int Family::kPersonFieldNumber;
#endif // !_MSC_VER
Family::Family()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:Family)
}
void Family::InitAsDefaultInstance() {
}
Family::Family(const Family& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:Family)
}
void Family::SharedCtor() {
_cached_size_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
Family::~Family() {
// @@protoc_insertion_point(destructor:Family)
SharedDtor();
}
void Family::SharedDtor() {
if (this != default_instance_) {
}
}
void Family::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Family::descriptor() {
protobuf_AssignDescriptorsOnce();
return Family_descriptor_;
}
const Family& Family::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_family_2eproto();
return *default_instance_;
}
Family* Family::default_instance_ = NULL;
Family* Family::New() const {
return new Family;
}
void Family::Clear() {
person_.Clear();
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool Family::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:Family)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .Person person = 1;
case 1: {
if (tag == 10) {
parse_person:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_person()));
} else {
goto handle_unusual;
}
if (input->ExpectTag(10)) goto parse_person;
if (input->ExpectAtEnd()) goto success;
break;
}
default: {
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:Family)
return true;
failure:
// @@protoc_insertion_point(parse_failure:Family)
return false;
#undef DO_
}
void Family::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:Family)
// repeated .Person person = 1;
for (int i = 0; i < this->person_size(); i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->person(i), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:Family)
}
::google::protobuf::uint8* Family::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:Family)
// repeated .Person person = 1;
for (int i = 0; i < this->person_size(); i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
1, this->person(i), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:Family)
return target;
}
int Family::ByteSize() const {
int total_size = 0;
// repeated .Person person = 1;
total_size += 1 * this->person_size();
for (int i = 0; i < this->person_size(); i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->person(i));
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void Family::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const Family* source =
::google::protobuf::internal::dynamic_cast_if_available<const Family*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void Family::MergeFrom(const Family& from) {
GOOGLE_CHECK_NE(&from, this);
person_.MergeFrom(from.person_);
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void Family::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Family::CopyFrom(const Family& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Family::IsInitialized() const {
if (!::google::protobuf::internal::AllAreInitialized(this->person())) return false;
return true;
}
void Family::Swap(Family* other) {
if (other != this) {
person_.Swap(&other->person_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata Family::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = Family_descriptor_;
metadata.reflection = Family_reflection_;
return metadata;
}
// @@protoc_insertion_point(namespace_scope)
// @@protoc_insertion_point(global_scope)
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: family.proto
#ifndef PROTOBUF_family_2eproto__INCLUDED
#define PROTOBUF_family_2eproto__INCLUDED
#include <string>
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION < 2006000
#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 2006001 < 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.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
// Internal implementation detail -- do not call these.
void protobuf_AddDesc_family_2eproto();
void protobuf_AssignDesc_family_2eproto();
void protobuf_ShutdownFile_family_2eproto();
class Person;
class Family;
// ===================================================================
class Person : public ::google::protobuf::Message {
public:
Person();
virtual ~Person();
Person(const Person& from);
inline Person& operator=(const Person& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const Person& default_instance();
void Swap(Person* other);
// implements Message ----------------------------------------------
Person* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const Person& from);
void MergeFrom(const Person& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// required int32 age = 1;
inline bool has_age() const;
inline void clear_age();
static const int kAgeFieldNumber = 1;
inline ::google::protobuf::int32 age() const;
inline void set_age(::google::protobuf::int32 value);
// required string name = 2;
inline bool has_name() const;
inline void clear_name();
static const int kNameFieldNumber = 2;
inline const ::std::string& name() const;
inline void set_name(const ::std::string& value);
inline void set_name(const char* value);
inline void set_name(const char* value, size_t size);
inline ::std::string* mutable_name();
inline ::std::string* release_name();
inline void set_allocated_name(::std::string* name);
// @@protoc_insertion_point(class_scope:Person)
private:
inline void set_has_age();
inline void clear_has_age();
inline void set_has_name();
inline void clear_has_name();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::std::string* name_;
::google::protobuf::int32 age_;
friend void protobuf_AddDesc_family_2eproto();
friend void protobuf_AssignDesc_family_2eproto();
friend void protobuf_ShutdownFile_family_2eproto();
void InitAsDefaultInstance();
static Person* default_instance_;
};
// -------------------------------------------------------------------
class Family : public ::google::protobuf::Message {
public:
Family();
virtual ~Family();
Family(const Family& from);
inline Family& operator=(const Family& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const Family& default_instance();
void Swap(Family* other);
// implements Message ----------------------------------------------
Family* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const Family& from);
void MergeFrom(const Family& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// repeated .Person person = 1;
inline int person_size() const;
inline void clear_person();
static const int kPersonFieldNumber = 1;
inline const ::Person& person(int index) const;
inline ::Person* mutable_person(int index);
inline ::Person* add_person();
inline const ::google::protobuf::RepeatedPtrField< ::Person >&
person() const;
inline ::google::protobuf::RepeatedPtrField< ::Person >*
mutable_person();
// @@protoc_insertion_point(class_scope:Family)
private:
::google::protobuf::UnknownFieldSet _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::Person > person_;
friend void protobuf_AddDesc_family_2eproto();
friend void protobuf_AssignDesc_family_2eproto();
friend void protobuf_ShutdownFile_family_2eproto();
void InitAsDefaultInstance();
static Family* default_instance_;
};
// ===================================================================
// ===================================================================
// Person
// required int32 age = 1;
inline bool Person::has_age() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void Person::set_has_age() {
_has_bits_[0] |= 0x00000001u;
}
inline void Person::clear_has_age() {
_has_bits_[0] &= ~0x00000001u;
}
inline void Person::clear_age() {
age_ = 0;
clear_has_age();
}
inline ::google::protobuf::int32 Person::age() const {
// @@protoc_insertion_point(field_get:Person.age)
return age_;
}
inline void Person::set_age(::google::protobuf::int32 value) {
set_has_age();
age_ = value;
// @@protoc_insertion_point(field_set:Person.age)
}
// required string name = 2;
inline bool Person::has_name() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void Person::set_has_name() {
_has_bits_[0] |= 0x00000002u;
}
inline void Person::clear_has_name() {
_has_bits_[0] &= ~0x00000002u;
}
inline void Person::clear_name() {
if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
name_->clear();
}
clear_has_name();
}
inline const ::std::string& Person::name() const {
// @@protoc_insertion_point(field_get:Person.name)
return *name_;
}
inline void Person::set_name(const ::std::string& value) {
set_has_name();
if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
name_ = new ::std::string;
}
name_->assign(value);
// @@protoc_insertion_point(field_set:Person.name)
}
inline void Person::set_name(const char* value) {
set_has_name();
if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
name_ = new ::std::string;
}
name_->assign(value);
// @@protoc_insertion_point(field_set_char:Person.name)
}
inline void Person::set_name(const char* value, size_t size) {
set_has_name();
if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
name_ = new ::std::string;
}
name_->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:Person.name)
}
inline ::std::string* Person::mutable_name() {
set_has_name();
if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
name_ = new ::std::string;
}
// @@protoc_insertion_point(field_mutable:Person.name)
return name_;
}
inline ::std::string* Person::release_name() {
clear_has_name();
if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
return NULL;
} else {
::std::string* temp = name_;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
return temp;
}
}
inline void Person::set_allocated_name(::std::string* name) {
if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete name_;
}
if (name) {
set_has_name();
name_ = name;
} else {
clear_has_name();
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
// @@protoc_insertion_point(field_set_allocated:Person.name)
}
// -------------------------------------------------------------------
// Family
// repeated .Person person = 1;
inline int Family::person_size() const {
return person_.size();
}
inline void Family::clear_person() {
person_.Clear();
}
inline const ::Person& Family::person(int index) const {
// @@protoc_insertion_point(field_get:Family.person)
return person_.Get(index);
}
inline ::Person* Family::mutable_person(int index) {
// @@protoc_insertion_point(field_mutable:Family.person)
return person_.Mutable(index);
}
inline ::Person* Family::add_person() {
// @@protoc_insertion_point(field_add:Family.person)
return person_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::Person >&
Family::person() const {
// @@protoc_insertion_point(field_list:Family.person)
return person_;
}
inline ::google::protobuf::RepeatedPtrField< ::Person >*
Family::mutable_person() {
// @@protoc_insertion_point(field_mutable_list:Family.person)
return &person_;
}
// @@protoc_insertion_point(namespace_scope)
#ifndef SWIG
namespace google {
namespace protobuf {
} // namespace google
} // namespace protobuf
#endif // SWIG
// @@protoc_insertion_point(global_scope)
#endif // PROTOBUF_family_2eproto__INCLUDED
syntax = "proto2";
message Person {
required int32 age = 1;
required string name = 2;
}
message Family {
repeated Person person = 1;
}
...@@ -7,9 +7,9 @@ using namespace std; ...@@ -7,9 +7,9 @@ using namespace std;
int main(){ int main(){
string a("1.bin.finish"); string a("1.bin.finish");
string b(".fisnish"); string b(".finish");
cout << (string::npos == a.find(b)) << endl; cout << (string::npos == a.find(b)) << endl;
cout << (string::npos == a.find(".")) << endl; cout << (string::npos == a.find("uyuyuyuyu")) << endl;
// string c("1.bin"); // string c("1.bin");
// vector<string> v; // vector<string> v;
// v.push_back(a); // v.push_back(a);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment