2002-05-02 Rodrigo Moya <rodrigo@ximian.com>
[mono.git] / mcs / class / System.Data / System.Data.SqlTypes / SqlInt64.cs
1 //
2 // System.Data.SqlTypes.SqlInt64
3 //
4 // Author:
5 //   Tim Coleman <tim@timcoleman.com>
6 //
7 // (C) Copyright 2002 Tim Coleman
8 //
9
10 using System;
11
12 namespace System.Data.SqlTypes
13 {
14         public struct SqlInt64 : INullable, IComparable
15         {
16                 #region Fields
17                 private long value;
18
19                 public static readonly SqlInt64 MaxValue; // 2^63 - 1
20                 public static readonly SqlInt64 MinValue; // -2^63
21                 public static readonly SqlInt64 Null;
22                 public static readonly SqlInt64 Zero = new SqlInt64 (0);
23
24                 #endregion
25
26                 #region Constructors
27
28                 public SqlInt64 (long value) 
29                 {
30                         this.value = value;
31                 }
32
33                 #endregion
34
35                 #region Properties
36
37                 [MonoTODO]
38                 public bool IsNull { 
39                         get { throw new NotImplementedException (); }
40                 }
41
42                 public long Value { 
43                         get { return value; }
44                 }
45
46                 #endregion
47
48                 #region Methods
49
50                 public static SqlInt64 Add (SqlInt64 x, SqlInt64 y)
51                 {
52                         return (x + y);
53                 }
54
55                 public static SqlInt64 BitwiseAnd (SqlInt64 x, SqlInt64 y)
56                 {
57                         return (x & y);
58                 }
59
60                 public static SqlInt64 BitwiseOr (SqlInt64 x, SqlInt64 y)
61                 {
62                         return (x | y);
63                 }
64
65                 [MonoTODO]
66                 public int CompareTo (object value)
67                 {
68                         throw new NotImplementedException ();
69                 }
70
71                 public static SqlInt64 Divide (SqlInt64 x, SqlInt64 y)
72                 {
73                         return (x / y);
74                 }
75
76                 [MonoTODO]
77                 public override bool Equals (object value)
78                 {
79                         throw new NotImplementedException ();
80                 }
81
82                 public static SqlBoolean Equals (SqlInt64 x, SqlInt64 y)
83                 {
84                         return (x == y);
85                 }
86
87                 [MonoTODO]
88                 public override int GetHashCode ()
89                 {
90                         return (int)value;
91                 }
92
93                 public static SqlBoolean GreaterThan (SqlInt64 x, SqlInt64 y)
94                 {
95                         return (x > y);
96                 }
97
98                 public static SqlBoolean GreaterThanOrEqual (SqlInt64 x, SqlInt64 y)
99                 {
100                         return (x >= y);
101                 }
102
103                 public static SqlBoolean LessThan (SqlInt64 x, SqlInt64 y)
104                 {
105                         return (x < y);
106                 }
107
108                 public static SqlBoolean LessThanOrEqual (SqlInt64 x, SqlInt64 y)
109                 {
110                         return (x <= y);
111                 }
112
113                 public static SqlInt64 Multiply (SqlInt64 x, SqlInt64 y)
114                 {
115                         return (x * y);
116                 }
117
118                 public static SqlBoolean NotEquals (SqlInt64 x, SqlInt64 y)
119                 {
120                         return (x != y);
121                 }
122
123                 public static SqlInt64 OnesComplement (SqlInt64 x)
124                 {
125                         return ~x;
126                 }
127
128                 [MonoTODO]
129                 public static SqlInt64 Parse (string s)
130                 {
131                         throw new NotImplementedException ();
132                 }
133
134                 public static SqlInt64 Subtract (SqlInt64 x, SqlInt64 y)
135                 {
136                         return (x - y);
137                 }
138
139                 public static SqlBoolean ToSqlBoolean ()
140                 {
141                         if (value != 0) return SqlBoolean.True;
142                         if (value == 0) return SqlBoolean.False;
143
144                         return SqlBoolean.Null;
145                 }
146                 
147                 [MonoTODO]
148                 public static SqlByte ToSqlByte ()
149                 {
150                         throw new NotImplementedException ();
151                 }
152
153                 [MonoTODO]
154                 public static SqlDecimal ToSqlDecimal ()
155                 {
156                         throw new NotImplementedException ();
157                 }
158
159                 [MonoTODO]
160                 public static SqlDouble ToSqlDouble ()
161                 {
162                         throw new NotImplementedException ();
163                 }
164
165                 [MonoTODO]
166                 public static SqlInt16 ToSqlInt16 ()
167                 {
168                         throw new NotImplementedException ();
169                 }
170
171                 [MonoTODO]
172                 public static SqlInt32 ToSqlInt32 ()
173                 {
174                         throw new NotImplementedException ();
175                 }
176
177                 [MonoTODO]
178                 public static SqlMoney ToSqlMoney ()
179                 {
180                         throw new NotImplementedException ();
181                 }
182
183                 [MonoTODO]
184                 public static SqlSingle ToSqlSingle ()
185                 {
186                         throw new NotImplementedException ();
187                 }
188
189                 [MonoTODO]
190                 public static SqlString ToSqlString ()
191                 {
192                         throw new NotImplementedException ();
193                 }
194
195                 [MonoTODO]
196                 public override string ToString ()
197                 {
198                         throw new NotImplementedException ();
199                 }
200
201                 public static SqlInt64 Xor (SqlInt64 x, SqlInt64 y)
202                 {
203                         return (x ^ y);
204                 }
205
206                 public static SqlInt64 operator + (SqlInt64 x, SqlInt64 y)
207                 {
208                         return new SqlInt64 (x.Value + y.Value);
209                 }
210
211                 public static SqlInt64 operator & (SqlInt64 x, SqlInt64 y)
212                 {
213                         return new SqlInt64 (x.value & y.Value);
214                 }
215
216                 public static SqlInt64 operator | (SqlInt64 x, SqlInt64 y)
217                 {
218                         return new SqlInt64 (x.value | y.Value);
219                 }
220
221                 public static SqlInt64 operator / (SqlInt64 x, SqlInt64 y)
222                 {
223                         return new SqlInt64 (x.Value / y.Value);
224                 }
225
226                 public static SqlBoolean operator == (SqlInt64 x, SqlInt64 y)
227                 {
228                         if (x == null || y == null) return SqlBoolean.Null;
229                         return new SqlBoolean (x.Value == y.Value);
230                 }
231
232                 public static SqlInt64 operator ^ (SqlInt64 x, SqlInt64 y)
233                 {
234                         return new SqlInt64 (x.Value ^ y.Value);
235                 }
236
237                 public static SqlBoolean operator > (SqlInt64 x, SqlInt64 y)
238                 {
239                         if (x == null || y == null) return SqlBoolean.Null;
240                         return new SqlBoolean (x.Value > y.Value);
241                 }
242
243                 public static SqlBoolean operator >= (SqlInt64 x, SqlInt64 y)
244                 {
245                         if (x == null || y == null) return SqlBoolean.Null;
246                         return new SqlBoolean (x.Value >= y.Value);
247                 }
248
249                 public static SqlBoolean operator != (SqlInt64 x, SqlInt64 y)
250                 {
251                         if (x == null || y == null) return SqlBoolean.Null;
252                         return new SqlBoolean (!(x.Value == y.Value));
253                 }
254
255                 public static SqlBoolean operator < (SqlInt64 x, SqlInt64 y)
256                 {
257                         if (x == null || y == null) return SqlBoolean.Null;
258                         return new SqlBoolean (x.Value < y.Value);
259                 }
260
261                 public static SqlBoolean operator <= (SqlInt64 x, SqlInt64 y)
262                 {
263                         if (x == null || y == null) return SqlBoolean.Null;
264                         return new SqlBoolean (x.Value <= y.Value);
265                 }
266
267                 public static SqlInt64 operator % (SqlInt64 x, SqlInt64 y)
268                 {
269                         return new SqlInt64(x.Value % y.Value);
270                 }
271
272                 public static SqlInt64 operator * (SqlInt64 x, SqlInt64 y)
273                 {
274                         return new SqlInt64 (x.Value * y.Value);
275                 }
276
277                 public static SqlInt64 operator ~ (SqlInt64 x)
278                 {
279                         return new SqlInt64 (~(x.Value));
280                 }
281
282                 public static SqlInt64 operator - (SqlInt64 x, SqlInt64 y)
283                 {
284                         return new SqlInt64 (x.Value - y.Value);
285                 }
286
287                 public static SqlInt64 operator - (SqlInt64 n)
288                 {
289                         return new SqlInt64 (-(n.Value));
290                 }
291
292                 [MonoTODO]
293                 public static explicit operator SqlInt64 (SqlBoolean x)
294                 {
295                         return new NotImplementedException ();
296                 }
297
298                 [MonoTODO]
299                 public static explicit operator SqlInt64 (SqlDecimal x)
300                 {
301                         return new NotImplementedException ();
302                 }
303
304                 [MonoTODO]
305                 public static explicit operator SqlInt64 (SqlDouble x)
306                 {
307                         return new NotImplementedException ();
308                 }
309
310                 public static explicit operator long (SqlInt64 x)
311                 {
312                         return x.Value;
313                 }
314
315                 [MonoTODO]
316                 public static explicit operator SqlInt64 (SqlMoney x)
317                 {
318                         return new NotImplementedException ();
319                 }
320
321                 [MonoTODO]
322                 public static explicit operator SqlInt64 (SqlSingle x)
323                 {
324                         return new NotImplementedException ();
325                 }
326
327                 [MonoTODO]
328                 public static explicit operator SqlInt64 (SqlString x)
329                 {
330                         return new NotImplementedException ();
331                 }
332
333                 public static explicit operator SqlInt64 (long x)
334                 {
335                         return new SqlInt64 (x);
336                 }
337
338                 [MonoTODO]
339                 public static explicit operator SqlInt64 (SqlByte x)
340                 {
341                         return new NotImplementedException ();
342                 }
343
344                 [MonoTODO]
345                 public static explicit operator SqlInt64 (SqlInt16 x)
346                 {
347                         return new NotImplementedException ();
348                 }
349
350                 [MonoTODO]
351                 public static explicit operator SqlInt64 (SqlInt32 x)
352                 {
353                         return new NotImplementedException ();
354                 }
355
356                 #endregion
357         }
358 }
359