1 2 //////////////////////////////////////////////////////////////////////////////////////////// 3 // Copyright (c) 2012 Christopher Nicholson-Sauls // 4 // // 5 // Permission is hereby granted, free of charge, to any person obtaining a copy of this // 6 // software and associated documentation files (the "Software"), to deal in the // 7 // Software without restriction, including without limitation the rights to use, copy, // 8 // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, // 9 // and to permit persons to whom the Software is furnished to do so, subject to the // 10 // following conditions: // 11 // // 12 // The above copyright notice and this permission notice shall be included in all // 13 // copies or substantial portions of the Software. // 14 // // 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // 16 // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // 17 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // 18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // 19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE // 20 // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // 21 //////////////////////////////////////////////////////////////////////////////////////////// 22 23 module zeal.config; 24 25 import std.metastrings; 26 import std.string; 27 28 import Custom = config; 29 30 struct Defaults { static: 31 enum string address = "127.0.0.1"; 32 enum string assets = "./assets/"; 33 enum string[] inflections = []; 34 enum ushort port = 8080; 35 enum string[] resources = []; 36 enum string[] styles = [ "application" ]; 37 } 38 39 template ZealConfig ( string _ID ) { 40 mixin(Format!( 41 q{ 42 static if ( is( typeof( Custom.%s ) ) ) { 43 alias Custom.%s ZealConfig; 44 } 45 else static if ( is( typeof( Defaults.%s ) ) ) { 46 alias Defaults.%s ZealConfig; 47 } 48 else { 49 static assert( false, "ZealConfig found no value for id '%s'." ); 50 } 51 }, 52 _ID, 53 _ID, 54 _ID, 55 _ID, 56 _ID 57 )); 58 } 59 60 template ZealConfig ( string _ID, alias _Default ) { 61 mixin(Format!( 62 q{ 63 static if ( is( typeof( Custom.%s ) ) ) { 64 alias Custom.%s ZealConfig; 65 } 66 else { 67 alias _Default ZealConfig; 68 } 69 }, 70 _ID, 71 _ID 72 )); 73 }