Wellknown types(知名类型)

本文说明 wellknown types 的各种特性。

Datetime(日期时间)

Datetime(日期时间)

参考 Basics: Datetime →

HelloWorld.xlsx 中的 worksheet ItemConf

BeginDatetimeEndDatetimeDatetime
datetimedatetime[]datetime
Begin datetimeEnd datetimeDatetime
2020-01-01 10:25:002022-10-10 05:10:002020-01-01 10:25:00,2022-10-10 05:10:00

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  google.protobuf.Timestamp begin_datetime = 1 [(tableau.field) = {name:"BeginDatetime"}];
  google.protobuf.Timestamp end_datetime = 2 [(tableau.field) = {name:"EndDatetime"}];
  repeated google.protobuf.Timestamp datetime_list = 3 [(tableau.field) = {name:"Datetime" layout:LAYOUT_INCELL}];
}
ItemConf.json
{
    "beginDatetime": "2020-01-01T02:25:00Z",
    "endDatetime": "2022-10-09T21:10:00Z",
    "datetimeList": [
        "2020-01-01T02:25:00Z",
        "2022-10-09T21:10:00Z"
    ]
}

Date(日期)

参考 Basics: Datetime →

HelloWorld.xlsx 中的 worksheet ItemConf

BeginDateEndDateDate
datedate[]date
Begin dateEnd dateDate
2020-01-01202210102020-01-01,20221010

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  google.protobuf.Timestamp begin_date = 1 [(tableau.field) = {name:"BeginDate"}];
  google.protobuf.Timestamp end_date = 2 [(tableau.field) = {name:"EndDate"}];
  repeated google.protobuf.Timestamp date_list = 3 [(tableau.field) = {name:"Date" layout:LAYOUT_INCELL}];
}
ItemConf.json
{
    "beginDate": "2019-12-31T16:00:00Z",
    "endDate": "2022-10-09T16:00:00Z",
    "dateList": [
        "2019-12-31T16:00:00Z",
        "2022-10-09T16:00:00Z"
    ]
}

Time(时间)

参考 Basics: Datetime →

HelloWorld.xlsx 中的 worksheet ItemConf

BeginTimeEndTimeTime
timetime[]time
Begin timeEnd timeTime
10:25:00112510:25:00,1125

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  google.protobuf.Duration begin_time = 1 [(tableau.field) = {name:"BeginTime"}];
  google.protobuf.Duration end_time = 2 [(tableau.field) = {name:"EndTime"}];
  repeated google.protobuf.Duration time_list = 3 [(tableau.field) = {name:"Time" layout:LAYOUT_INCELL}];
}
ItemConf.json
{
    "beginTime": "37500s",
    "endTime": "41100s",
    "timeList": [
        "37500s",
        "41100s"
    ]
}

Duration(时长)

参考 Basics: Duration →

HelloWorld.xlsx 中的 worksheet ItemConf

Duration1Duration2Duration
durationduration[]duration
Duration 1Duration 2Duration
1h2m3s4ms5us6ns1h2m3s,4ms5us6ns

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  google.protobuf.Duration duration_1 = 1 [(tableau.field) = {name:"Duration1"}];
  google.protobuf.Duration duration_2 = 2 [(tableau.field) = {name:"Duration2"}];
  repeated google.protobuf.Duration duration_list = 3 [(tableau.field) = {name:"Duration" layout:LAYOUT_INCELL}];
}
ItemConf.json
{
    "duration1": "3723s",
    "duration2": "0.004005006s",
    "durationList": [
        "3723s",
        "0.004005006s"
    ]
}

Fraction(分数)

参考 Basics: Fraction →

HelloWorld.xlsx 中的 worksheet ItemConf

MinRatioRatio1Ratio2Ratio3Ratio4Ratio5
fraction[]fractionfractionfractionfractionfraction
min ratioratio1ratio 2ratio 3ratio 4ratio 5
1/410%10‰10‱100.01

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  tableau.Fraction min_ratio = 1 [(tableau.field) = {name:"MinRatio"}];
  repeated tableau.Fraction ratio_list = 2 [(tableau.field) = {name:"Ratio" layout:LAYOUT_HORIZONTAL}];
}
ItemConf.json
{
    "minRatio": {"num": 1, "den": 4},
    "ratioList": [
        {"num": 10, "den": 100},
        {"num": 10, "den": 1000},
        {"num": 10, "den": 10000},
        {"num": 10, "den": 1},
        {"num": 1, "den": 100}
    ]
}

Comparator(比较器)

参考 Basics: Comparator →

HelloWorld.xlsx 中的 worksheet ItemConf

MinRatioRatio1Ratio2Ratio3Ratio4Ratio5
comparator[]comparatorcomparatorcomparatorcomparatorcomparator
min ratioratio1ratio 2ratio 3ratio 4ratio 5
!=1/4<10%<=10‰>10‱>=10==3/5

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  tableau.Comparator min_ratio = 1 [(tableau.field) = {name:"MinRatio"}];
  repeated tableau.Comparator ratio_list = 2 [(tableau.field) = {name:"Ratio" layout:LAYOUT_HORIZONTAL}];
}
ItemConf.json
{
    "minRatio": {
        "sign": "SIGN_NOT_EQUAL",
        "value": {"num": 1, "den": 4}
    },
    "ratioList": [
        {"sign": "SIGN_LESS", "value": {"num": 10, "den": 100}},
        {"sign": "SIGN_LESS_OR_EQUAL", "value": {"num": 10, "den": 1000}},
        {"sign": "SIGN_GREATER", "value": {"num": 10, "den": 10000}},
        {"sign": "SIGN_GREATER_OR_EQUAL", "value": {"num": 10, "den": 1}},
        {"sign": "SIGN_EQUAL", "value": {"num": 3, "den": 5}}
    ]
}

Version(版本号)

参考 Basics: Version →

默认 pattern 为:255.255.255

HelloWorld.xlsx 中的 worksheet ItemConf

VersionCustomVersionIncellVersionHorizontalVersion1HorizontalVersion2HorizontalVersion3
versionversion|{pattern:“99.999.99.999.99.999”}[]version|{pattern:“999.999.999”}[]version|{pattern:“999.999.999”}versionversion
default versioncustom versionincell versionhorizontal version1horizontal version2horizontal version3
1.0.31.2.3.4.5.61.2.3,4.5.61.0.01.2.32.0.3

生成结果:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  tableau.Version version = 1 [(tableau.field) = {name:"Version"}]; // default version
  tableau.Version custom_version = 2 [(tableau.field) = {name:"CustomVersion" prop:{pattern:"99.999.99.999.99.999"}}]; // custom version
  repeated tableau.Version incell_version_list = 3 [(tableau.field) = {name:"IncellVersion" layout:LAYOUT_INCELL prop:{pattern:"999.999.999"}}]; // incell version
  repeated tableau.Version horizontal_version_list = 4 [(tableau.field) = {name:"HorizontalVersion" layout:LAYOUT_HORIZONTAL prop:{pattern:"999.999.999"}}]; // horizontal version
}
ItemConf.json
{
    "version": {
        "str": "1.0.3",
        "val": "65539",
        "major": 1,
        "minor": 0,
        "patch": 3,
        "others": []
    },
    "customVersion": {
        "str": "1.2.3.4.5.6",
        "val": "10020300405006",
        "major": 1,
        "minor": 2,
        "patch": 3,
        "others": [4, 5, 6]
    },
    "incellVersionList": [
        {"str": "1.2.3", "val": "1002003", "major": 1, "minor": 2, "patch": 3, "others": []},
        {"str": "4.5.6", "val": "4005006", "major": 4, "minor": 5, "patch": 6, "others": []}
    ],
    "horizontalVersionList": [
        {"str": "1.0.0", "val": "1000000", "major": 1, "minor": 0, "patch": 0, "others": []},
        {"str": "1.2.3", "val": "1002003", "major": 1, "minor": 2, "patch": 3, "others": []},
        {"str": "2.0.3", "val": "2000003", "major": 2, "minor": 0, "patch": 3, "others": []}
    ]
}