資源簡介
Protocol Buffers v3.2.0
C# 版本

代碼片段和文件信息
import?com.google.protobuf.ByteString;
import?com.google.protobuf.CodedInputStream;
import?com.google.protobuf.conformance.Conformance;
import?com.google.protobuf.InvalidProtocolBufferException;
import?com.google.protobuf_test_messages.proto3.TestMessagesProto3;
import?com.google.protobuf.util.JsonFormat;
import?com.google.protobuf.util.JsonFormat.TypeRegistry;
import?java.io.IOException;
import?java.nio.ByteBuffer;
class?ConformanceJava?{
??private?int?testCount?=?0;
??private?TypeRegistry?typeRegistry;
??private?boolean?readFromStdin(byte[]?buf?int?len)?throws?Exception?{
????int?ofs?=?0;
????while?(len?>?0)?{
??????int?read?=?System.in.read(buf?ofs?len);
??????if?(read?==?-1)?{
????????return?false;??//?EOF
??????}
??????ofs?+=?read;
??????len?-=?read;
????}
????return?true;
??}
??private?void?writeToStdout(byte[]?buf)?throws?Exception?{
????System.out.write(buf);
??}
??//?Returns?-1?on?EOF?(the?actual?values?will?always?be?positive).
??private?int?readLittleEndianIntFromStdin()?throws?Exception?{
????byte[]?buf?=?new?byte[4];
????if?(!readFromStdin(buf?4))?{
??????return?-1;
????}
????return?(buf[0]?&?0xff)
????????|?((buf[1]?&?0xff)?<8)
????????|?((buf[2]?&?0xff)?<16)
????????|?((buf[3]?&?0xff)?<24);
??}
??private?void?writeLittleEndianIntToStdout(int?val)?throws?Exception?{
????byte[]?buf?=?new?byte[4];
????buf[0]?=?(byte)val;
????buf[1]?=?(byte)(val?>>?8);
????buf[2]?=?(byte)(val?>>?16);
????buf[3]?=?(byte)(val?>>?24);
????writeToStdout(buf);
??}
??private?enum?BinaryDecoder?{
????BYTE_STRING_DECODER()?{
??????@Override
??????public?TestMessagesProto3.TestAllTypes?parse(ByteString?bytes)
??????????throws?InvalidProtocolBufferException?{
????????return?TestMessagesProto3.TestAllTypes.parseFrom(bytes);
??????}
????}
????BYTE_ARRAY_DECODER()?{
??????@Override
??????public?TestMessagesProto3.TestAllTypes?parse(ByteString?bytes)
??????????throws?InvalidProtocolBufferException?{
????????return?TestMessagesProto3.TestAllTypes.parseFrom(bytes.toByteArray());
??????}
????}
????ARRAY_BYTE_BUFFER_DECODER()?{
??????@Override
??????public?TestMessagesProto3.TestAllTypes?parse(ByteString?bytes)
??????????throws?InvalidProtocolBufferException?{
????????ByteBuffer?buffer?=?ByteBuffer.allocate(bytes.size());
????????bytes.copyTo(buffer);
????????buffer.flip();
????????try?{
??????????return?TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer));
????????}?catch?(InvalidProtocolBufferException?e)?{
??????????throw?e;
????????}?catch?(IOException?e)?{
??????????throw?new?RuntimeException(
??????????????“ByteString?based?ByteBuffer?should?not?throw?IOException.“?e);
????????}
??????}
????}
????READONLY_ARRAY_BYTE_BUFFER_DECODER()?{
??????@Override
??????public?TestMessagesProto3.TestAllTypes?parse(ByteString?bytes)
??????????throws?InvalidProtocolBufferException?{
????????try?{
??????????return?TestMessagesProto3.TestAllTypes.parseFrom(
??????????????CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer()));
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-01-28?02:25??protobuf-3.2.0\
?????文件????????1361??2017-01-27?23:49??protobuf-3.2.0\autogen.sh
?????文件????????5826??2017-01-28?02:20??protobuf-3.2.0\ar-lib
?????文件????????2133??2017-01-27?23:49??protobuf-3.2.0\LICENSE
?????文件?????????319??2017-01-27?23:49??protobuf-3.2.0\protobuf.pc.in
?????目錄???????????0??2017-01-28?02:25??protobuf-3.2.0\src\
?????目錄???????????0??2017-01-28?02:25??protobuf-3.2.0\src\google\
?????目錄???????????0??2017-01-28?02:25??protobuf-3.2.0\src\google\protobuf\
?????文件???????51100??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\arena_unittest.cc
?????文件????????2049??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\unittest_preserve_unknown_enum2.proto
?????文件???????61619??2017-01-28?02:20??protobuf-3.2.0\src\google\protobuf\map.h
?????文件????????3515??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\map_lite_test_util.h
?????文件????????2059??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\unittest_no_generic_services.proto
?????文件????????2792??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\generated_message_util.cc
?????文件????????2353??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\arenastring.cc
?????文件???????22997??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\unknown_field_set_unittest.cc
?????文件????????6421??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\generated_message_util.h
?????文件???????88231??2017-01-28?02:20??protobuf-3.2.0\src\google\protobuf\repeated_field.h
?????文件???????12345??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\dynamic_message_unittest.cc
?????文件????????8128??2017-01-28?02:20??protobuf-3.2.0\src\google\protobuf\field_mask.pb.h
?????文件???????73725??2017-01-28?02:20??protobuf-3.2.0\src\google\protobuf\api.pb.cc
?????文件???????91511??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\test_util_lite.cc
?????文件????????3345??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\map_proto2_unittest.proto
?????文件????????3536??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\reflection_ops.h
?????文件????????2365??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\unittest_em
?????文件????????3493??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\any_test.cc
?????文件???????30717??2017-01-28?02:20??protobuf-3.2.0\src\google\protobuf\dynamic_message.cc
?????文件???????17404??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\desc
?????文件????????5011??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\unittest_well_known_types.proto
?????文件???????17927??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\map_field_inl.h
?????文件????????2125??2017-01-27?23:49??protobuf-3.2.0\src\google\protobuf\generated_enum_util.h
............此處省略1155個文件信息
評論
共有 條評論