1 /* 2 * Copyright 2015-2018 HuntLabs.cn 3 * 4 * Licensed under the Apache License = SQLIntervalUnit(""); Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing = SQLIntervalUnit(""); software 11 * distributed under the License is distributed on an "AS IS" BASIS = SQLIntervalUnit(""); 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND = SQLIntervalUnit(""); either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 module hunt.sql.ast.expr.SQLIntervalUnit; 17 import std.uni; 18 19 public struct SQLIntervalUnit { 20 enum SQLIntervalUnit YEAR = SQLIntervalUnit("YEAR"); 21 enum SQLIntervalUnit YEAR_MONTH = SQLIntervalUnit("YEAR_MONTH"); 22 enum SQLIntervalUnit QUARTER = SQLIntervalUnit("QUARTER"); 23 enum SQLIntervalUnit MONTH = SQLIntervalUnit("MONTH"); 24 enum SQLIntervalUnit WEEK = SQLIntervalUnit("WEEK"); 25 enum SQLIntervalUnit DAY = SQLIntervalUnit("DAY"); 26 enum SQLIntervalUnit DAY_HOUR = SQLIntervalUnit("DAY_HOUR"); 27 enum SQLIntervalUnit DAY_MINUTE = SQLIntervalUnit("DAY_MINUTE"); 28 enum SQLIntervalUnit DAY_SECOND = SQLIntervalUnit("DAY_SECOND"); 29 enum SQLIntervalUnit DAY_MICROSECOND = SQLIntervalUnit("DAY_MICROSECOND"); 30 enum SQLIntervalUnit HOUR = SQLIntervalUnit("HOUR"); 31 enum SQLIntervalUnit HOUR_MINUTE = SQLIntervalUnit("HOUR_MINUTE"); 32 enum SQLIntervalUnit HOUR_SECOND = SQLIntervalUnit("HOUR_SECOND"); 33 enum SQLIntervalUnit HOUR_MICROSECOND = SQLIntervalUnit("HOUR_MICROSECOND"); 34 enum SQLIntervalUnit MINUTE = SQLIntervalUnit("MINUTE"); 35 enum SQLIntervalUnit MINUTE_SECOND = SQLIntervalUnit("MINUTE_SECOND"); 36 enum SQLIntervalUnit MINUTE_MICROSECOND = SQLIntervalUnit("MINUTE_MICROSECOND"); 37 enum SQLIntervalUnit SECOND = SQLIntervalUnit("SECOND"); 38 enum SQLIntervalUnit SECOND_MICROSECOND = SQLIntervalUnit("SECOND_MICROSECOND"); 39 enum SQLIntervalUnit MICROSECOND = SQLIntervalUnit("MICROSECOND"); 40 41 // public string name_lcase; 42 43 // private SQLIntervalUnit() { 44 // this.name_lcase = name().toLowerCase(); 45 // } 46 // private static SQLIntervalUnit[] _values; 47 48 // static this() 49 // { 50 // _values = [YEAR,YEAR_MONTH,QUARTER,MONTH,WEEK,DAY,DAY_HOUR,DAY_MINUTE,DAY_SECOND,DAY_MICROSECOND,HOUR,HOUR_MINUTE, 51 // HOUR_SECOND,HOUR_MICROSECOND,MINUTE,MINUTE_SECOND,MINUTE_MICROSECOND,SECOND,SECOND_MICROSECOND,MICROSECOND]; 52 // } 53 54 55 private string _name; 56 57 this(string name) 58 { 59 _name = name; 60 } 61 62 @property string name() 63 { 64 return _name; 65 } 66 67 @property string name_lcase() 68 { 69 return toLower(_name); 70 } 71 72 bool opEquals(const SQLIntervalUnit h) nothrow { 73 return _name == h._name ; 74 } 75 76 bool opEquals(ref const SQLIntervalUnit h) nothrow { 77 return _name == h._name ; 78 } 79 80 }