ProtoBuffer

[[grpc]]’s backstone.

Sample

1
2
3
4
5
message Person {
    optional string name = 1;
    optional int32 id = 2;
    optional string email = 3;
}
1
2
3
4
5
6
7
Person john = Person.newBuilder()
                .setId(1234)   
                .setName("John Doe")   
                .setEmail("[email protected]")   
                .build();
output = new FileOutputStream(args[0]);
john.writeTo(output);
1
2
3
4
5
6
Person john;
fstream input(argv[1],ios::in | ios::binary);
john.ParseFromIstream(&input);
id = john.id();
name = john.name();
email = john.email();

References

Licensed under CC BY-NC-SA 4.0
Get Things Done
Built with Hugo
Theme Stack designed by Jimmy