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