프로토콜 버퍼
보이기
	
	
| 개발자 | 구글 | 
|---|---|
| 발표일 | 2001년 초 (내부)[1] 2008년 7월 7일 (공개) | 
| 안정화 버전 | 33.0   / 2025년 10월 15일[2] | 
| 저장소 | |
| 운영 체제 | 전체 | 
| 플랫폼 | 크로스 플랫폼 | 
| 종류 | 직렬화 포맷 및 라이브러리, IDL 컴파일러 | 
| 라이선스 | BSD | 
| 상태 | 지원 중 | 
| 웹사이트 | developers | 
프로토콜 버퍼(Protocol Buffers, Protobuf)는 구조화된 데이터를 직렬화하는 방식이다. 유선이나 데이터 저장을 목적으로 서로 통신할 프로그램을 개발할 때 유용하다.
예
[편집]//polyline.proto
syntax = "proto2";
message Point {
  required int32 x = 1;
  required int32 y = 2;
  optional string label = 3;
}
message Line {
  required Point start = 1;
  required Point end = 2;
  optional string label = 3;
}
message Polyline {
  repeated Point point = 1;
  optional string label = 2;
}
위에서 C++ 버전의 프로토콜 버퍼 스키마를 만든 다음 C++ 소스 코드 파일 polyline.cpp은 아래와 같은 메시지 오브젝트를 사용할 수 있다:
// polyline.cpp
#include "polyline.pb.h"  // generated by calling "protoc polyline.proto"
Line* createNewLine(const std::string& name) {
  // create a line from (10, 20) to (30, 40)
  Line* line = new Line;
  line->mutable_start()->set_x(10);
  line->mutable_start()->set_y(20);
  line->mutable_end()->set_x(30);
  line->mutable_end()->set_y(40);
  line->set_label(name);
  return line;
}
Polyline* createNewPolyline() {
  // create a polyline with points at (10,10) and (20,20)
  Polyline* polyline = new Polyline;
  Point* point1 = polyline->add_point();
  point1->set_x(10);
  point1->set_y(10);
  Point* point2 = polyline->add_point();
  point2->set_x(20);
  point2->set_y(20);
  return polyline;
}
언어 지원
[편집]proto2는 C++, 자바, 파이썬을 위한 코드 생성기를 제공한다.[3]
타사 구현체는 자바스크립트를 지원한다.[4]
proto3는 C++, 자바(자바나노 포함), 파이썬, Go, 루비, 오브젝티브-C, C#를 위한 코드 생성기를 제공한다[5]. 3.0.0 베타 2부터 자바스크립트를 지원한다.[6]
타사 구현체는 펄, PHP, 스칼라, 줄리아를 지원한다.[7]
같이 보기
[편집]각주
[편집]- ↑ “Frequently Asked Questions | Protocol Buffers”. 《Google Developers》. 2016년 10월 2일에 확인함.
- ↑ “Releases - google/protobuf” – GitHub 경유.
- ↑ “Protocol Buffers Language Guide”. 《Google Developers》. 2016년 4월 21일에 확인함.
- ↑ “Protocol Buffers for JavaScript.”. github.com. 2016년 5월 14일에 확인함.
- ↑ “Protocol Buffers Language Guide (proto3)”. 《Google Developers》. 2016년 4월 21일에 확인함.
- ↑ “Protocol Buffers v3.0.0-beta-2”. 《Google Developers》. 2016년 5월 14일에 확인함.
- ↑ “ThirdPartyAddOns - protobuf - Links to third-party add-ons. - Protocol Buffers - Google's data interchange format - Google Project Hosting”. Code.google.com. 2012년 11월 7일에 확인함.
외부 링크
[편집]- (영어) Official documentation at developers.google.com
- (영어) Official project page at Github project hosting
|   | 이 글은 소프트웨어에 관한 토막글입니다. 여러분의 지식으로 알차게 문서를 완성해 갑시다. | 
