天天看點

Google Protocol Buffer(2)—API

引言

google protocol buffer提供了三個API packeges, 其命名和功能概要分别如下:

  • google::protobuf   
    • protobuf核心運作庫              
  • google::protobuf::io 
    • 用于I/O的輔助類;
  • google::protobuf::compiler   
    • protocol buffer  compiler的實作庫;

1. google::protobuf   

  •  protocol buffer 系統的核心庫;
  • note:線程安全:隻讀對象(const 修飾)可以被多個線程同時通路,但允許寫的對象隻能同時被一個線程通路;

2.google::protobuf::io

  • 可以encoding 和decoding 原始的位元組;
  • 開發者實作自己的I/O系統:例如,允許protobuf無需緩存從不同的輸入流裡讀取資料;

3.google::protocol::compiler

  • 動态編譯.proto檔案時應用,需包含import.h;
  • 開發其他語言的.proto檔案的編譯器;

繼續閱讀