Import std.data.protobuf
ProtoText
class
Public Class ProtoText
Writes a message as protobuf's text format, on one line, as a message's ToString gives it:
name: "Ada" id: 7 phone { number: "555" }. Each field goes in with its name, a message's
between BeginMessage and EndMessage.
Examples
Local text = ProtoText()
text.WriteString("name", "Ada")
text.Write("id", "7")
text.BeginMessage("phone")
text.WriteString("number", "555")
text.EndMessage()
Expect(text.Finish() == "name: \"Ada\" id: 7 phone {{ number: \"555\" }}")std/data/protobuf.fb, line 630
-
A new ProtoText, with nothing written.
-
name: value, for a value that's text already, like a number or an enum'sname. -
name: trueorname: false. -
A float as text format has it: its shortest form, or inf, -inf, or nan.
-
A double as text format has it: its shortest form, or inf, -inf, or nan.
-
A string in quotes, with C's escapes for quotes, backslashes, and control characters; the rest of its UTF-8 stays as it is.
-
Bytes in quotes, with C's escapes, and each byte that isn't printable ASCII in octal.
-
Starts a message's fields:
name {. -
Ends the message BeginMessage started:
}. -
The fields a message didn't know, by their numbers, as text format shows them: a varint as its number, a 4-byte or 8-byte value in hex, a length-delimited one as bytes in quotes, and a group between braces. Panics when
unknownisn't fields, as a reader's Skip keeps them. -
What was written, after which it starts again, empty.
Report an issue with this page or with FutureBlitz on GitHub.