(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Data.TdsClient / Mono.Data.TdsTypes / TdsInt16.cs
blobf7dc003e8698ac9020a039e46401dd530e6f74c1
1 //
2 // Mono.Data.TdsTypes.TdsInt16
3 //
4 // Author:
5 // Tim Coleman <tim@timcoleman.com>
6 //
7 // (C) Copyright Tim Coleman, 2002
8 //
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:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
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.TdsClient;
32 using System;
33 using System.Data.SqlTypes;
34 using System.Globalization;
36 namespace Mono.Data.TdsTypes {
37 public struct TdsInt16 : INullable, IComparable
39 #region Fields
41 short value;
42 private bool notNull;
44 public static readonly TdsInt16 MaxValue = new TdsInt16 (32767);
45 public static readonly TdsInt16 MinValue = new TdsInt16 (-32768);
46 public static readonly TdsInt16 Null;
47 public static readonly TdsInt16 Zero = new TdsInt16 (0);
49 #endregion
51 #region Constructors
53 public TdsInt16 (short value)
55 this.value = value;
56 notNull = true;;
59 #endregion
61 #region Properties
63 public bool IsNull {
64 get { return !notNull; }
67 public short Value {
68 get {
69 if (this.IsNull)
70 throw new TdsNullValueException ();
71 else
72 return value;
76 #endregion
78 #region Methods
80 public static TdsInt16 Add (TdsInt16 x, TdsInt16 y)
82 return (x + y);
85 public static TdsInt16 BitwiseAnd (TdsInt16 x, TdsInt16 y)
87 return (x & y);
90 public static TdsInt16 BitwiseOr (TdsInt16 x, TdsInt16 y)
92 return (x | y);
95 public int CompareTo (object value)
97 if (value == null)
98 return 1;
99 else if (!(value is TdsInt16))
100 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.TdsTypes.TdsInt16"));
101 else if (((TdsInt16)value).IsNull)
102 return 1;
103 else
104 return this.value.CompareTo (((TdsInt16)value).Value);
107 public static TdsInt16 Divide (TdsInt16 x, TdsInt16 y)
109 return (x / y);
112 public override bool Equals (object value)
114 if (!(value is TdsInt16))
115 return false;
116 else
117 return (bool) (this == (TdsInt16)value);
120 public static TdsBoolean Equals (TdsInt16 x, TdsInt16 y)
122 return (x == y);
125 public override int GetHashCode ()
127 return (int)value;
130 public static TdsBoolean GreaterThan (TdsInt16 x, TdsInt16 y)
132 return (x > y);
135 public static TdsBoolean GreaterThanOrEqual (TdsInt16 x, TdsInt16 y)
137 return (x >= y);
140 public static TdsBoolean LessThan (TdsInt16 x, TdsInt16 y)
142 return (x < y);
145 public static TdsBoolean LessThanOrEqual (TdsInt16 x, TdsInt16 y)
147 return (x <= y);
150 public static TdsInt16 Mod (TdsInt16 x, TdsInt16 y)
152 return (x % y);
155 public static TdsInt16 Multiply (TdsInt16 x, TdsInt16 y)
157 return (x * y);
160 public static TdsBoolean NotEquals (TdsInt16 x, TdsInt16 y)
162 return (x != y);
165 public static TdsInt16 OnesComplement (TdsInt16 x)
167 return ~x;
170 public static TdsInt16 Parse (string s)
172 return new TdsInt16 (Int16.Parse (s));
175 public static TdsInt16 Subtract (TdsInt16 x, TdsInt16 y)
177 return (x - y);
180 public TdsBoolean ToTdsBoolean ()
182 return ((TdsBoolean)this);
185 public TdsByte ToTdsByte ()
187 return ((TdsByte)this);
190 public TdsDecimal ToTdsDecimal ()
192 return ((TdsDecimal)this);
195 public TdsDouble ToTdsDouble ()
197 return ((TdsDouble)this);
200 public TdsInt32 ToTdsInt32 ()
202 return ((TdsInt32)this);
205 public TdsInt64 ToTdsInt64 ()
207 return ((TdsInt64)this);
210 public TdsMoney ToTdsMoney ()
212 return ((TdsMoney)this);
215 public TdsSingle ToTdsSingle ()
217 return ((TdsSingle)this);
220 public TdsString ToTdsString ()
222 return ((TdsString)this);
225 public override string ToString ()
227 if (this.IsNull)
228 return "Null";
229 else
230 return value.ToString ();
233 public static TdsInt16 Xor (TdsInt16 x, TdsInt16 y)
235 return (x ^ y);
238 public static TdsInt16 operator + (TdsInt16 x, TdsInt16 y)
240 return new TdsInt16 ((short) (x.Value + y.Value));
243 public static TdsInt16 operator & (TdsInt16 x, TdsInt16 y)
245 return new TdsInt16 ((short) (x.value & y.Value));
248 public static TdsInt16 operator | (TdsInt16 x, TdsInt16 y)
250 return new TdsInt16 ((short) ((byte) x.Value | (byte) y.Value));
253 public static TdsInt16 operator / (TdsInt16 x, TdsInt16 y)
255 return new TdsInt16 ((short) (x.Value / y.Value));
258 public static TdsBoolean operator == (TdsInt16 x, TdsInt16 y)
260 if (x.IsNull || y.IsNull)
261 return TdsBoolean.Null;
262 else
263 return new TdsBoolean (x.Value == y.Value);
266 public static TdsInt16 operator ^ (TdsInt16 x, TdsInt16 y)
268 return new TdsInt16 ((short) (x.Value ^ y.Value));
271 public static TdsBoolean operator > (TdsInt16 x, TdsInt16 y)
273 if (x.IsNull || y.IsNull)
274 return TdsBoolean.Null;
275 else
276 return new TdsBoolean (x.Value > y.Value);
279 public static TdsBoolean operator >= (TdsInt16 x, TdsInt16 y)
281 if (x.IsNull || y.IsNull)
282 return TdsBoolean.Null;
283 else
284 return new TdsBoolean (x.Value >= y.Value);
287 public static TdsBoolean operator != (TdsInt16 x, TdsInt16 y)
289 if (x.IsNull || y.IsNull)
290 return TdsBoolean.Null;
291 else
292 return new TdsBoolean (!(x.Value == y.Value));
295 public static TdsBoolean operator < (TdsInt16 x, TdsInt16 y)
297 if (x.IsNull || y.IsNull)
298 return TdsBoolean.Null;
299 else
300 return new TdsBoolean (x.Value < y.Value);
303 public static TdsBoolean operator <= (TdsInt16 x, TdsInt16 y)
305 if (x.IsNull || y.IsNull)
306 return TdsBoolean.Null;
307 else
308 return new TdsBoolean (x.Value <= y.Value);
311 public static TdsInt16 operator % (TdsInt16 x, TdsInt16 y)
313 return new TdsInt16 ((short) (x.Value % y.Value));
316 public static TdsInt16 operator * (TdsInt16 x, TdsInt16 y)
318 return new TdsInt16 ((short) (x.Value * y.Value));
321 public static TdsInt16 operator ~ (TdsInt16 x)
323 return new TdsInt16 ((short) (~x.Value));
326 public static TdsInt16 operator - (TdsInt16 x, TdsInt16 y)
328 return new TdsInt16 ((short) (x.Value - y.Value));
331 public static TdsInt16 operator - (TdsInt16 n)
333 return new TdsInt16 ((short) (-n.Value));
336 public static explicit operator TdsInt16 (TdsBoolean x)
338 if (x.IsNull)
339 return Null;
340 else
341 return new TdsInt16 ((short)x.ByteValue);
344 public static explicit operator TdsInt16 (TdsDecimal x)
346 if (x.IsNull)
347 return Null;
348 else
349 return new TdsInt16 ((short)x.Value);
352 public static explicit operator TdsInt16 (TdsDouble x)
354 if (x.IsNull)
355 return Null;
356 else
357 return new TdsInt16 ((short)x.Value);
360 public static explicit operator short (TdsInt16 x)
362 return x.Value;
365 public static explicit operator TdsInt16 (TdsInt32 x)
367 if (x.IsNull)
368 return Null;
369 else
370 return new TdsInt16 ((short)x.Value);
373 public static explicit operator TdsInt16 (TdsInt64 x)
375 if (x.IsNull)
376 return Null;
377 else
378 return new TdsInt16 ((short)x.Value);
381 public static explicit operator TdsInt16 (TdsMoney x)
383 if (x.IsNull)
384 return Null;
385 else
386 return new TdsInt16 ((short)x.Value);
389 public static explicit operator TdsInt16 (TdsSingle x)
391 if (x.IsNull)
392 return Null;
393 else
394 return new TdsInt16 ((short)x.Value);
397 public static explicit operator TdsInt16 (TdsString x)
399 return TdsInt16.Parse (x.Value);
402 public static implicit operator TdsInt16 (short x)
404 return new TdsInt16 (x);
407 public static implicit operator TdsInt16 (TdsByte x)
409 if (x.IsNull)
410 return Null;
411 else
412 return new TdsInt16 ((short)x.Value);
415 #endregion