1 /** 2 Date: 2015-2017, Joakim Brännström 3 License: MPL-2, Mozilla Public License 2.0 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 */ 6 module dextool.type; 7 8 static import my.path; 9 10 public import dextool.compilation_db : FilterClangFlag; 11 12 @safe: 13 14 enum ExitStatusType { 15 Ok, 16 Errors 17 } 18 19 struct DextoolVersion { 20 string payload; 21 alias payload this; 22 } 23 24 alias Path = my.path.Path; 25 alias AbsolutePath = my.path.AbsolutePath; 26 27 /** During construction checks that the file exists on the filesystem. 28 * 29 * If it doesn't exist it will throw an Exception. 30 */ 31 struct Exists(T) { 32 AbsolutePath payload; 33 alias payload this; 34 35 this(AbsolutePath p) { 36 import std.file : exists, FileException; 37 38 if (!exists(p)) { 39 throw new FileException("File do not exist: " ~ cast(string) p); 40 } 41 42 payload = p; 43 } 44 45 this(Exists!T p) { 46 payload = p.payload; 47 } 48 49 void opAssign(Exists!T p) pure nothrow @nogc { 50 payload = p; 51 } 52 } 53 54 auto makeExists(T)(T p) { 55 return Exists!T(p); 56 } 57 58 @("shall be an instantiation of Exists") 59 nothrow unittest { 60 // the file is not expected to exist. 61 62 try { 63 auto p = makeExists(AbsolutePath(Path("foo"))); 64 } catch (Exception e) { 65 } 66 }