[Library Release] dproto

Matt Soucy msoucy at csh.rit.edu
Sat Oct 5 13:56:21 PDT 2013


Hello, all-

I'd like to present a library that I've been working on on-and-off for
the last couple of months.

Protocol Buffers are a format produced by Google that acts as an
Interface Description Language for serializable data. Basically, given a
file containing lines like:

message Point {
	optional int32 x = 1 [default=166];
	required int32 y = 2;
	optional string label = 3;
	message Coord {
		required int32 a = 1;
		required int32 b = 2;
	}
}

You can get a structure that behaves as:

struct Point {
	int x=166;
	int y;
	string label;
	struct Coord {
		int a,b;
	}
}

What's the benefit? This structure also has some useful methods for
serialization and deserialization to a well-documented format - in
dproto's case, the resulting data can be stored in any ubyte[].

What makes this library special? Unlike the C++/Java/Python compilers
for .proto files, this library does the conversion at compile time using
mixins and string manipulation. All that's needed is to add the file
directories to the string imports, and then:

	mixin ProtocolBuffer!"point.proto";

Where can you get it?
It's available as a Dub package ("dproto"), or on Github at
http://github.com/msoucy/dproto

dproto is licensed under the BSD 3-clause license, and I'm definitely
open to suggestions for improvement - currently, a lot of the code was
translated from Java and so there are some things that are quite
unidiomatic.

-Matt Soucy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20131005/7cc6ff6e/attachment.pgp>


More information about the Digitalmars-d-announce mailing list