2 // Mono.Data.SybaseTypes.SybaseInt64
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright Tim Coleman, 2002
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using Mono
.Data
.SybaseClient
;
33 using System
.Data
.SqlTypes
;
34 using System
.Globalization
;
36 namespace Mono
.Data
.SybaseTypes
{
37 public struct SybaseInt64
: INullable
, IComparable
45 public static readonly SybaseInt64 MaxValue
= new SybaseInt64 (9223372036854775807);
46 public static readonly SybaseInt64 MinValue
= new SybaseInt64 (-9223372036854775808);
48 public static readonly SybaseInt64 Null
;
49 public static readonly SybaseInt64 Zero
= new SybaseInt64 (0);
55 public SybaseInt64 (long value)
66 get { return !notNull; }
72 throw new SybaseNullValueException ();
82 public static SybaseInt64
Add (SybaseInt64 x
, SybaseInt64 y
)
87 public static SybaseInt64
BitwiseAnd (SybaseInt64 x
, SybaseInt64 y
)
92 public static SybaseInt64
BitwiseOr (SybaseInt64 x
, SybaseInt64 y
)
97 public int CompareTo (object value)
101 else if (!(value is SybaseInt64
))
102 throw new ArgumentException (Locale
.GetText ("Value is not a System.Data.SybaseTypes.SybaseInt64"));
103 else if (((SybaseInt64
)value).IsNull
)
106 return this.value.CompareTo (((SybaseInt64
)value).Value
);
109 public static SybaseInt64
Divide (SybaseInt64 x
, SybaseInt64 y
)
114 public override bool Equals (object value)
116 if (!(value is SybaseInt64
))
119 return (bool) (this == (SybaseInt64
)value);
122 public static SybaseBoolean
Equals (SybaseInt64 x
, SybaseInt64 y
)
127 public override int GetHashCode ()
129 return (int)(value & 0xffffffff) ^
(int)(value >> 32);
132 public static SybaseBoolean
GreaterThan (SybaseInt64 x
, SybaseInt64 y
)
137 public static SybaseBoolean
GreaterThanOrEqual (SybaseInt64 x
, SybaseInt64 y
)
142 public static SybaseBoolean
LessThan (SybaseInt64 x
, SybaseInt64 y
)
147 public static SybaseBoolean
LessThanOrEqual (SybaseInt64 x
, SybaseInt64 y
)
152 public static SybaseInt64
Mod (SybaseInt64 x
, SybaseInt64 y
)
157 public static SybaseInt64
Multiply (SybaseInt64 x
, SybaseInt64 y
)
162 public static SybaseBoolean
NotEquals (SybaseInt64 x
, SybaseInt64 y
)
167 public static SybaseInt64
OnesComplement (SybaseInt64 x
)
173 public static SybaseInt64
Parse (string s
)
175 return new SybaseInt64 (Int64
.Parse (s
));
178 public static SybaseInt64
Subtract (SybaseInt64 x
, SybaseInt64 y
)
183 public SybaseBoolean
ToSybaseBoolean ()
185 return ((SybaseBoolean
)this);
188 public SybaseByte
ToSybaseByte ()
190 return ((SybaseByte
)this);
193 public SybaseDecimal
ToSybaseDecimal ()
195 return ((SybaseDecimal
)this);
198 public SybaseDouble
ToSybaseDouble ()
200 return ((SybaseDouble
)this);
203 public SybaseInt16
ToSybaseInt16 ()
205 return ((SybaseInt16
)this);
208 public SybaseInt32
ToSybaseInt32 ()
210 return ((SybaseInt32
)this);
213 public SybaseMoney
ToSybaseMoney ()
215 return ((SybaseMoney
)this);
218 public SybaseSingle
ToSybaseSingle ()
220 return ((SybaseSingle
)this);
223 public SybaseString
ToSybaseString ()
225 return ((SybaseString
)this);
228 public override string ToString ()
233 return value.ToString ();
236 public static SybaseInt64
Xor (SybaseInt64 x
, SybaseInt64 y
)
241 public static SybaseInt64
operator + (SybaseInt64 x
, SybaseInt64 y
)
243 return new SybaseInt64 (x
.Value
+ y
.Value
);
246 public static SybaseInt64
operator & (SybaseInt64 x
, SybaseInt64 y
)
248 return new SybaseInt64 (x
.value & y
.Value
);
251 public static SybaseInt64
operator | (SybaseInt64 x
, SybaseInt64 y
)
253 return new SybaseInt64 (x
.value | y
.Value
);
256 public static SybaseInt64
operator / (SybaseInt64 x
, SybaseInt64 y
)
258 return new SybaseInt64 (x
.Value
/ y
.Value
);
261 public static SybaseBoolean
operator == (SybaseInt64 x
, SybaseInt64 y
)
263 if (x
.IsNull
|| y
.IsNull
)
264 return SybaseBoolean
.Null
;
266 return new SybaseBoolean (x
.Value
== y
.Value
);
269 public static SybaseInt64
operator ^
(SybaseInt64 x
, SybaseInt64 y
)
271 return new SybaseInt64 (x
.Value ^ y
.Value
);
274 public static SybaseBoolean
operator > (SybaseInt64 x
, SybaseInt64 y
)
276 if (x
.IsNull
|| y
.IsNull
)
277 return SybaseBoolean
.Null
;
279 return new SybaseBoolean (x
.Value
> y
.Value
);
282 public static SybaseBoolean
operator >= (SybaseInt64 x
, SybaseInt64 y
)
284 if (x
.IsNull
|| y
.IsNull
)
285 return SybaseBoolean
.Null
;
287 return new SybaseBoolean (x
.Value
>= y
.Value
);
290 public static SybaseBoolean
operator != (SybaseInt64 x
, SybaseInt64 y
)
292 if (x
.IsNull
|| y
.IsNull
)
293 return SybaseBoolean
.Null
;
295 return new SybaseBoolean (!(x
.Value
== y
.Value
));
298 public static SybaseBoolean
operator < (SybaseInt64 x
, SybaseInt64 y
)
300 if (x
.IsNull
|| y
.IsNull
)
301 return SybaseBoolean
.Null
;
303 return new SybaseBoolean (x
.Value
< y
.Value
);
306 public static SybaseBoolean
operator <= (SybaseInt64 x
, SybaseInt64 y
)
308 if (x
.IsNull
|| y
.IsNull
)
309 return SybaseBoolean
.Null
;
311 return new SybaseBoolean (x
.Value
<= y
.Value
);
314 public static SybaseInt64
operator % (SybaseInt64 x
, SybaseInt64 y
)
316 return new SybaseInt64(x
.Value
% y
.Value
);
319 public static SybaseInt64
operator * (SybaseInt64 x
, SybaseInt64 y
)
321 return new SybaseInt64 (x
.Value
* y
.Value
);
324 public static SybaseInt64
operator ~
(SybaseInt64 x
)
326 return new SybaseInt64 (~
(x
.Value
));
329 public static SybaseInt64
operator - (SybaseInt64 x
, SybaseInt64 y
)
331 return new SybaseInt64 (x
.Value
- y
.Value
);
334 public static SybaseInt64
operator - (SybaseInt64 n
)
336 return new SybaseInt64 (-(n
.Value
));
339 public static explicit operator SybaseInt64 (SybaseBoolean x
)
342 return SybaseInt64
.Null
;
344 return new SybaseInt64 ((long)x
.ByteValue
);
347 public static explicit operator SybaseInt64 (SybaseDecimal x
)
350 return SybaseInt64
.Null
;
352 return new SybaseInt64 ((long)x
.Value
);
355 public static explicit operator SybaseInt64 (SybaseDouble x
)
358 return SybaseInt64
.Null
;
360 return new SybaseInt64 ((long)x
.Value
);
363 public static explicit operator long (SybaseInt64 x
)
368 public static explicit operator SybaseInt64 (SybaseMoney x
)
371 return SybaseInt64
.Null
;
373 return new SybaseInt64 ((long)x
.Value
);
376 public static explicit operator SybaseInt64 (SybaseSingle x
)
379 return SybaseInt64
.Null
;
381 return new SybaseInt64 ((long)x
.Value
);
384 public static explicit operator SybaseInt64 (SybaseString x
)
386 return SybaseInt64
.Parse (x
.Value
);
389 public static implicit operator SybaseInt64 (long x
)
391 return new SybaseInt64 (x
);
394 public static implicit operator SybaseInt64 (SybaseByte x
)
397 return SybaseInt64
.Null
;
399 return new SybaseInt64 ((long)x
.Value
);
402 public static implicit operator SybaseInt64 (SybaseInt16 x
)
405 return SybaseInt64
.Null
;
407 return new SybaseInt64 ((long)x
.Value
);
410 public static implicit operator SybaseInt64 (SybaseInt32 x
)
413 return SybaseInt64
.Null
;
415 return new SybaseInt64 ((long)x
.Value
);