Types.hx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (c) 2005-2011, The haXe Project Contributors
  3. * All rights reserved.
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * - Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * - Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  20. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  23. * DAMAGE.
  24. */
  25. package sys.db;
  26. // basic types
  27. /** int with auto increment **/
  28. typedef SId = Int
  29. /** int unsigned with auto increment **/
  30. typedef SUId = Int
  31. /** big int with auto increment **/
  32. typedef SBigId = Float
  33. typedef SInt = Int
  34. typedef SUInt = Int
  35. typedef SBigInt = Float
  36. /** single precision float **/
  37. typedef SSingle = Float
  38. /** double precision float **/
  39. typedef SFloat = Float
  40. /** use tinyint(1) to distinguish with int **/
  41. typedef SBool = Bool
  42. /** same as varchar(n) **/
  43. typedef SString<Const> = String
  44. /** date only, use SDateTime for date+time **/
  45. typedef SDate = Date
  46. /** mysql DateTime **/
  47. typedef SDateTime = Date
  48. /** mysql Timestamp **/
  49. typedef STimeStamp = Date
  50. /** TinyText (up to 255 bytes) **/
  51. typedef STinyText = String
  52. /** Text (up to 64KB) **/
  53. typedef SSmallText = String
  54. /** MediumText (up to 24MB) **/
  55. typedef SText = String
  56. /** Blob type (up to 64KB) **/
  57. typedef SSmallBinary = haxe.io.Bytes
  58. /** LongBlob type (up to 4GB) **/
  59. typedef SLongBinary = haxe.io.Bytes
  60. /** MediumBlob type (up to 24MB) **/
  61. typedef SBinary = haxe.io.Bytes
  62. /** same as binary(n) **/
  63. typedef SBytes<Const> = haxe.io.Bytes
  64. /** TinyInt [-128...127] **/
  65. typedef STinyInt = Int
  66. // extra
  67. /** specify that this field is nullable **/
  68. typedef SNull<T> = T
  69. /** specify that the integer use custom encoding **/
  70. typedef SEncoded = Int
  71. /** haxe Serialized string **/
  72. typedef SSerialized = String
  73. /** native neko serialized bytes **/
  74. typedef SNekoSerialized = haxe.io.Bytes
  75. @:native("Int")
  76. extern class SFlags<T> {
  77. public inline function init() : Void {
  78. untyped __this__ = 0;
  79. }
  80. public inline function get( v : T ) : Bool {
  81. return (cast this) & (1 << Type.enumIndex(v)) != 0;
  82. }
  83. public inline function set( v : T ) : Void {
  84. untyped __this__ |= 1 << Type.enumIndex(v);
  85. }
  86. public inline function unset( v : T ) : Void {
  87. untyped __this__ &= 0xFFFFFFF - (1 << Type.enumIndex(v));
  88. }
  89. public inline static function ofInt<T>( i : Int ) : SFlags<T> {
  90. return cast i;
  91. }
  92. public inline function toInt() : Int {
  93. return cast this;
  94. }
  95. }