1 module ithox.qrcode.datatypesinterface; 2 3 alias StringString = string[string]; 4 5 /** 6 * Simple Laravel QrCode Generator 7 * @author donglei 8 * 9 */ 10 interface DataTypesInterface 11 { 12 13 public void create(StringString args); 14 public string toString(); 15 } 16 17 class PhoneNumber : DataTypesInterface 18 { 19 private 20 { 21 const string prefix = "tel:"; 22 string phoneNumber; 23 } 24 25 public void create(StringString args) 26 { 27 this.phoneNumber = args["phone"]; 28 } 29 30 public override string toString() 31 { 32 return prefix ~ phoneNumber; 33 } 34 35 } 36 37 //TODO 38 class Email : DataTypesInterface 39 { 40 private 41 { 42 const string prefix = "mailto:"; 43 } 44 public void create(StringString args) 45 { 46 } 47 48 public override string toString() 49 { 50 return prefix; 51 } 52 } 53 54 class Geo : DataTypesInterface 55 { 56 57 private 58 { 59 const string prefix = "geo:"; 60 const string separator = ","; 61 string latitude, longitude; 62 } 63 public void create(StringString args) 64 { 65 latitude = args.get("latitude", ""); 66 longitude = args.get("longitude", ""); 67 } 68 69 public override string toString() 70 { 71 return prefix ~ latitude ~ separator ~ longitude; 72 } 73 } 74 75 class SMS : DataTypesInterface 76 { 77 78 private 79 { 80 string phoneNumber, message; 81 } 82 public void create(StringString args) 83 { 84 phoneNumber = args.get("phone", ""); 85 message = args.get("message", ""); 86 } 87 88 public override string toString() 89 { 90 auto sms = "sms:" ~ phoneNumber; 91 if (message.length != 0) 92 { 93 sms ~= ":" ~ message; 94 } 95 return sms; 96 97 } 98 }