1 /*******************************************************************************
2  * Main library import for dproto
3  *
4  * Provides accessors for D string and D structs from proto files/data
5  *
6  * Authors: Matthew Soucy, dproto@msoucy.me
7  */
8 module dproto.dproto;
9 
10 import std.exception : enforce;
11 import std.array;
12 import std.range;
13 
14 
15 /*******************************************************************************
16  * Create D structures from proto file
17  *
18  * Creates all required structs given a valid proto file
19  *
20  * Assumes that the file can be found in the string imports
21  */
22 template ProtocolBuffer(string s)
23 {
24 	import dproto.imports;
25 	mixin(ParseProtoSchema(s,import(s)).toD());
26 }
27 
28 /*******************************************************************************
29  * Create D structure strings from proto data
30  *
31  * Creates all required structs given a valid proto definition as a string
32  */
33 template ProtocolBufferFromString(string s)
34 {
35 	import dproto.imports;
36 	mixin(ParseProtoSchema("<none>",s).toD());
37 }
38 
39 template ProtocolBufferInterface(string s) {
40 	import dproto.imports;
41 	mixin("%3.1s".format(ParseProtoSchema("<none>",s)));
42 }
43 
44 template ProtocolBufferRpc(string s) {
45 	import dproto.imports;
46 	mixin("%3.2s".format(ParseProtoSchema("<none>",s)));
47 }
48 
49 template ProtocolBufferImpl(string s) {
50 	import dproto.imports;
51 	mixin("%3.3s".format(ParseProtoSchema("<none>",s)));
52 }
53 
54 template ProtocolBufferStruct(string s) {
55 	import dproto.imports;
56 	mixin("%-3.1s".format(ParseProtoSchema("<none>",s)));
57 }
58