2 // Mono.Data.SybaseTypes.SybaseByte
5 // Tim Coleman <tim@timcoleman.com>
7 // Based on System.Data.SqlTypes.SqlByte
10 // (C) Ximian, Inc. 2002-2003
11 // (C) Copyright Tim Coleman, 2002
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using Mono.Data.SybaseClient;
37 using System.Data.SqlTypes;
38 using System.Globalization;
40 namespace Mono.Data.SybaseTypes {
41 public struct SybaseByte : INullable, IComparable
48 public static readonly SybaseByte MaxValue = new SybaseByte (0xff);
49 public static readonly SybaseByte MinValue = new SybaseByte (0);
50 public static readonly SybaseByte Null;
51 public static readonly SybaseByte Zero = new SybaseByte (0);
57 public SybaseByte (byte value)
68 get { return !notNull; }
74 throw new SybaseNullValueException ();
84 public static SybaseByte Add (SybaseByte x, SybaseByte y)
89 public static SybaseByte BitwiseAnd (SybaseByte x, SybaseByte y)
94 public static SybaseByte BitwiseOr (SybaseByte x, SybaseByte y)
99 public int CompareTo (object value)
103 else if (!(value is SybaseByte))
104 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.SybaseTypes.SybaseByte"));
105 else if (((SybaseByte)value).IsNull)
108 return this.value.CompareTo (((SybaseByte)value).Value);
111 public static SybaseByte Divide (SybaseByte x, SybaseByte y)
116 public override bool Equals (object value)
118 if (!(value is SybaseByte))
121 return (bool) (this == (SybaseByte)value);
124 public static SybaseBoolean Equals (SybaseByte x, SybaseByte y)
129 public override int GetHashCode ()
134 public static SybaseBoolean GreaterThan (SybaseByte x, SybaseByte y)
139 public static SybaseBoolean GreaterThanOrEqual (SybaseByte x, SybaseByte y)
144 public static SybaseBoolean LessThan (SybaseByte x, SybaseByte y)
149 public static SybaseBoolean LessThanOrEqual (SybaseByte x, SybaseByte y)
154 public static SybaseByte Mod (SybaseByte x, SybaseByte y)
159 public static SybaseByte Multiply (SybaseByte x, SybaseByte y)
164 public static SybaseBoolean NotEquals (SybaseByte x, SybaseByte y)
169 public static SybaseByte OnesComplement (SybaseByte x)
174 public static SybaseByte Parse (string s)
176 return new SybaseByte (Byte.Parse (s));
179 public static SybaseByte Subtract (SybaseByte x, SybaseByte y)
184 public SybaseBoolean ToSybaseBoolean ()
186 return ((SybaseBoolean)this);
189 public SybaseDecimal ToSybaseDecimal ()
191 return ((SybaseDecimal)this);
194 public SybaseDouble ToSybaseDouble ()
196 return ((SybaseDouble)this);
199 public SybaseInt16 ToSybaseInt16 ()
201 return ((SybaseInt16)this);
204 public SybaseInt32 ToSybaseInt32 ()
206 return ((SybaseInt32)this);
209 public SybaseInt64 ToSybaseInt64 ()
211 return ((SybaseInt64)this);
214 public SybaseMoney ToSybaseMoney ()
216 return ((SybaseMoney)this);
219 public SybaseSingle ToSybaseSingle ()
221 return ((SybaseSingle)this);
224 public SybaseString ToSybaseString ()
226 return ((SybaseString)this);
229 public override string ToString ()
234 return value.ToString ();
237 public static SybaseByte Xor (SybaseByte x, SybaseByte y)
242 public static SybaseByte operator + (SybaseByte x, SybaseByte y)
244 return new SybaseByte ((byte) (x.Value + y.Value));
247 public static SybaseByte operator & (SybaseByte x, SybaseByte y)
249 return new SybaseByte ((byte) (x.Value & y.Value));
252 public static SybaseByte operator | (SybaseByte x, SybaseByte y)
254 return new SybaseByte ((byte) (x.Value | y.Value));
257 public static SybaseByte operator / (SybaseByte x, SybaseByte y)
259 return new SybaseByte ((byte) (x.Value / y.Value));
262 public static SybaseBoolean operator == (SybaseByte x, SybaseByte y)
264 if (x.IsNull || y.IsNull)
265 return SybaseBoolean.Null;
267 return new SybaseBoolean (x.Value == y.Value);
270 public static SybaseByte operator ^ (SybaseByte x, SybaseByte y)
272 return new SybaseByte ((byte) (x.Value ^ y.Value));
275 public static SybaseBoolean operator > (SybaseByte x, SybaseByte y)
277 if (x.IsNull || y.IsNull)
278 return SybaseBoolean.Null;
280 return new SybaseBoolean (x.Value > y.Value);
283 public static SybaseBoolean operator >= (SybaseByte x, SybaseByte y)
285 if (x.IsNull || y.IsNull)
286 return SybaseBoolean.Null;
288 return new SybaseBoolean (x.Value >= y.Value);
291 public static SybaseBoolean operator != (SybaseByte x, SybaseByte y)
293 if (x.IsNull || y.IsNull)
294 return SybaseBoolean.Null;
296 return new SybaseBoolean (!(x.Value == y.Value));
299 public static SybaseBoolean operator < (SybaseByte x, SybaseByte y)
301 if (x.IsNull || y.IsNull)
302 return SybaseBoolean.Null;
304 return new SybaseBoolean (x.Value < y.Value);
307 public static SybaseBoolean operator <= (SybaseByte x, SybaseByte y)
309 if (x.IsNull || y.IsNull)
310 return SybaseBoolean.Null;
312 return new SybaseBoolean (x.Value <= y.Value);
315 public static SybaseByte operator % (SybaseByte x, SybaseByte y)
317 return new SybaseByte ((byte) (x.Value % y.Value));
320 public static SybaseByte operator * (SybaseByte x, SybaseByte y)
322 return new SybaseByte ((byte) (x.Value * y.Value));
325 public static SybaseByte operator ~ (SybaseByte x)
327 return new SybaseByte ((byte) ~x.Value);
330 public static SybaseByte operator - (SybaseByte x, SybaseByte y)
332 return new SybaseByte ((byte) (x.Value - y.Value));
335 public static explicit operator SybaseByte (SybaseBoolean x)
340 return new SybaseByte (x.ByteValue);
343 public static explicit operator byte (SybaseByte x)
348 public static explicit operator SybaseByte (SybaseDecimal x)
353 return new SybaseByte ((byte)x.Value);
356 public static explicit operator SybaseByte (SybaseDouble x)
361 return new SybaseByte ((byte)x.Value);
364 public static explicit operator SybaseByte (SybaseInt16 x)
369 return new SybaseByte ((byte)x.Value);
372 public static explicit operator SybaseByte (SybaseInt32 x)
377 return new SybaseByte ((byte)x.Value);
380 public static explicit operator SybaseByte (SybaseInt64 x)
385 return new SybaseByte ((byte)x.Value);
388 public static explicit operator SybaseByte (SybaseMoney x)
393 return new SybaseByte ((byte)x.Value);
396 public static explicit operator SybaseByte (SybaseSingle x)
401 return new SybaseByte ((byte)x.Value);
405 public static explicit operator SybaseByte (SybaseString x)
407 return SybaseByte.Parse (x.Value);
410 public static implicit operator SybaseByte (byte x)
412 return new SybaseByte (x);