|Did you know ...||Search Documentation:|
|The SWI-Prolog Implementation|
In SWI-Prolog, the wire stream interpreter is embodied in the form of a Definite Clause Grammar (DCG). It has a small underlying C-support library that loads when the Prolog module loads. This implementation does not depend on any code that is provided by Google and thus, is not bound by its license terms.
On the Prolog side, you define your message template as a list of
predefined Prolog terms that correspond to production rules in the DCG.
The process is not unlike specifiying the format of a regular
expression. To encode a message,
X, to wire-stream,
you pass a grounded template,
X, and a variable,
to protobuf_message/2. To
decode a wire-stream,
Y, to template,
pass an ungrounded template,
X, along with a grounded
interpreter will unify the unbound variables in the template with values
decoded from the wire-stream.