IDL
.deuk 파일 하나 = 스키마 하나
.proto, .thrift 도 같은 스키마로 읽음. .deuk 는 선택
예
namespace shop
enum Grade {
Bronze = 0
Silver = 1
Gold = 2
}
struct Point {
1> required int32 x
2> required int32 y
}
struct Item {
1> required string name
2> optional Point at
3> int32 count = 1
4> Grade grade = Grade.Silver
5> required list<string> tags
6> required map<string, Point> places
}
struct Node {
1> required string label
2> required list<Node> children
}
선언
| 문법 |
뜻 |
namespace a.b |
이름공간. 없으면 파일 이름 |
struct Name { ... } |
record. record 도 같음 |
struct Child extends Base { ... } |
Base 필드 + 자기 필드 |
enum Name { A = 0 ... } |
멤버마다 정수 값 |
include "other.deuk" |
다른 파일의 선언 사용 |
//, /* */, # |
주석 |
- 생성 단위 = namespace. 같은 namespace 의 IDL 여럿 → 생성물 한 벌
필드
- 꼴 =
<번호>> [required | optional] <타입> <이름> [= 기본값]
- 번호 = 와이어 식별자. record 안에서 하나뿐. 바꾸면 호환 깨짐
- 쉼표, 세미콜론은 있어도 없어도 됨
| 표기 |
뜻 |
required |
늘 있어야 함. 빠지면 오류 |
optional |
없음을 따로 표현 (언어의 optional 값) |
| 없음 |
선언 기본값이 곧 없음 |
- 컬렉션 = 존재 표시 없음. 빈 컬렉션 = 초기 상태
- 기본값 = 정수, 실수,
"문자열", true / false, Enum.Member
- 기본값 없는 enum 필드 = 첫 멤버
타입
| 분류 |
타입 |
| 불 |
bool |
| 부호 정수 |
sbyte int16 int32 int64 (int8 i16 i32 i64) |
| 부호 없는 정수 |
byte (uint8) uint16 uint32 uint64 |
| 실수 |
float double |
| 문자열, 바이트 |
string binary |
| 컬렉션 |
list<T> set<T> map<K, V> |
| 참조 |
다른 record, enum 이름 |
- 컬렉션 안 컬렉션 가능 (
list<list<int64>>)
- map 키 = 정수, 문자열, enum
- 자기 참조 = 컬렉션을 거쳐 가능 (
list<Node>)
.proto .thrift 에 없는 것
| 기능 |
.deuk |
proto3 |
Thrift |
상속 extends |
있음 |
없음 |
없음 |
required |
있음 |
없음 |
있음 |
| 필드 기본값 |
있음 |
없음 |
있음 |
| 8, 16비트 정수 |
있음 |
없음 |
일부 |
| 부호 없는 정수 |
있음 |
있음 |
없음 |
set<T> |
있음 |
없음 |
있음 |
| 컬렉션 안 컬렉션 |
있음 |
없음 |
있음 |
| enum 을 map 키로 |
있음 |
없음 |
있음 |
- 도입 = 지금 스키마 그대로 쓰다가 필요한 record 만
.deuk 로 옮김
- 포맷별 제약 = 포맷과 호환성
지원 밖
- 파서는 읽지만 생성 대상 아님:
service, typedef, const, union, exception, table, tablelink
datetime, timestamp, date, time, decimal, numeric = 문자열, 정수로 실림. 검증 대상 아님