資源簡介
protobuf visual studio 編譯版本.
下載后,解壓到一個目錄中,用vs打開vsprojects目錄中的protobuf.sln

代碼片段和文件信息
import?com.google.protobuf.conformance.Conformance;
import?com.google.protobuf.util.JsonFormat;
import?com.google.protobuf.util.JsonFormat.TypeRegistry;
import?com.google.protobuf.InvalidProtocolBufferException;
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?Conformance.ConformanceResponse?doTest(Conformance.ConformanceRequest?request)?{
????Conformance.TestAllTypes?testMessage;
????switch?(request.getPayloadCase())?{
??????case?PROTOBUF_PAYLOAD:?{
????????try?{
??????????testMessage?=?Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());
????????}?catch?(InvalidProtocolBufferException?e)?{
??????????return?Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
????????}
????????break;
??????}
??????case?JSON_PAYLOAD:?{
????????try?{
??????????Conformance.TestAllTypes.Builder?builder?=?Conformance.TestAllTypes.newBuilder();
??????????JsonFormat.parser().usingTypeRegistry(typeRegistry)
??????????????.merge(request.getJsonPayload()?builder);
??????????testMessage?=?builder.build();
????????}?catch?(InvalidProtocolBufferException?e)?{
??????????return?Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
????????}
????????break;
??????}
??????case?PAYLOAD_NOT_SET:?{
????????throw?new?RuntimeException(“Request?didn‘t?have?payload.“);
??????}
??????default:?{
????????throw?new?RuntimeException(“Unexpected?payload?case.“);
??????}
????}
????switch?(request.getRequestedOutputFormat())?{
??????case?UNSPECIFIED:
????????throw?new?RuntimeException(“Unspecified?output?format.“);
??????case?PROTOBUF:
????????return?Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build();
??????case?JSON:
????????try?{
??????????return?Conformance.ConformanceResponse.newBuilder().setJsonPayload(
??????????????JsonFormat.printer().usingTypeRegistry(typeRegistry).print(testMessage)).build();
????????}?catch?(InvalidProtocolBufferException?|
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-01-27?10:15??protobuf-3.0.0\
?????文件???????45860??2016-07-28?12:25??protobuf-3.0.0\aclocal.m4
?????文件????????5826??2016-04-29?05:36??protobuf-3.0.0\ar-lib
?????文件????????1153??2016-04-29?05:34??protobuf-3.0.0\autogen.sh
?????目錄???????????0??2016-07-28?12:26??protobuf-3.0.0\benchmarks\
?????文件????????4556??2016-05-06?07:03??protobuf-3.0.0\benchmarks\generate_datasets.cc
?????文件????????3009??2016-05-11?05:05??protobuf-3.0.0\benchmarks\Makefile.am
?????文件???????34644??2016-07-28?12:25??protobuf-3.0.0\benchmarks\Makefile.in
?????文件???????28601??2016-07-28?12:24??protobuf-3.0.0\BUILD
?????文件???????61341??2016-07-28?12:24??protobuf-3.0.0\CHANGES.txt
?????目錄???????????0??2016-07-28?12:26??protobuf-3.0.0\cmake\
?????文件????????6030??2016-07-28?12:24??protobuf-3.0.0\cmake\CMakeLists.txt
?????文件????????2112??2016-07-28?12:24??protobuf-3.0.0\cmake\examples.cmake
?????文件???????14335??2016-07-28?12:24??protobuf-3.0.0\cmake\extract_includes.bat.in
?????文件????????4635??2016-07-28?12:24??protobuf-3.0.0\cmake\install.cmake
?????文件????????2067??2016-05-11?05:05??protobuf-3.0.0\cmake\libprotobuf-lite.cmake
?????文件????????4113??2016-05-11?05:05??protobuf-3.0.0\cmake\libprotobuf.cmake
?????文件????????7838??2016-05-11?05:05??protobuf-3.0.0\cmake\libprotoc.cmake
?????文件????????2805??2016-07-28?12:24??protobuf-3.0.0\cmake\protobuf-config-version.cmake.in
?????文件?????????300??2016-07-28?12:24??protobuf-3.0.0\cmake\protobuf-config.cmake.in
?????文件????????7322??2016-07-28?12:24??protobuf-3.0.0\cmake\protobuf-module.cmake.in
?????文件?????????281??2016-07-28?12:24??protobuf-3.0.0\cmake\protobuf-options.cmake
?????文件?????????173??2016-04-29?05:34??protobuf-3.0.0\cmake\protoc.cmake
?????文件???????12518??2016-04-29?05:34??protobuf-3.0.0\cmake\README.md
?????文件???????10840??2016-07-28?12:24??protobuf-3.0.0\cmake\tests.cmake
?????文件????????7333??2016-04-29?05:36??protobuf-3.0.0\compile
?????文件???????45297??2016-04-29?05:36??protobuf-3.0.0\config.guess
?????文件????????3709??2016-07-28?12:25??protobuf-3.0.0\config.h.in
?????文件???????35564??2016-04-29?05:36??protobuf-3.0.0\config.sub
?????文件??????629582??2016-07-28?12:25??protobuf-3.0.0\configure
?????文件????????6240??2016-07-28?12:24??protobuf-3.0.0\configure.ac
............此處省略1016個文件信息
評論
共有 條評論