2 // System.Data.SqlTypes.SqlString
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Daniel Morgan (danmorg@sc.rr.com)
7 // Tim Coleman (tim@timcoleman.com)
9 // (C) Ximian, Inc. 2002
10 // (C) Copyright 2002 Tim Coleman
14 using System.Globalization;
16 namespace System.Data.SqlTypes
19 /// A variable-length stream of characters
20 /// to be stored in or retrieved from the database
22 public struct SqlString : INullable, IComparable
29 public static readonly int BinarySort;
30 public static readonly int IgnoreCase;
31 public static readonly int IgnoreKanaType;
32 public static readonly int IgnoreNonSpace;
33 public static readonly int IgnoreWidth;
34 public static readonly SqlString Null;
40 // init with a string data
41 public SqlString (string data)
46 // init with a string data and locale id values.
48 public SqlString (string data, int lcid)
50 throw new NotImplementedException ();
53 // init with locale id, compare options,
54 // and an array of bytes data
56 public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data)
58 throw new NotImplementedException ();
61 // init with string data, locale id, and compare options
63 public SqlString (string data, int lcid, SqlCompareOptions compareOptions)
65 throw new NotImplementedException ();
68 // init with locale id, compare options, array of bytes data,
69 // and whether unicode is encoded or not
71 public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, bool fUnicode)
73 throw new NotImplementedException ();
76 // init with locale id, compare options, array of bytes data,
77 // starting index in the byte array,
78 // and number of bytes to copy
80 public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count)
82 throw new NotImplementedException ();
85 // init with locale id, compare options, array of bytes data,
86 // starting index in the byte array, number of byte to copy,
87 // and whether unicode is encoded or not
89 public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count, bool fUnicode)
91 throw new NotImplementedException ();
94 #endregion // Constructors
97 #region Public Properties
99 public CompareInfo CompareInfo {
101 get { throw new NotImplementedException ();
105 public CultureInfo CultureInfo {
107 get { throw new NotImplementedException ();
112 get { return (bool) (this == SqlString.Null); }
115 // geographics location and language (locale id)
118 get { throw new NotImplementedException ();
122 public SqlCompareOptions SqlCompareOptions {
124 get { throw new NotImplementedException ();
128 public string Value {
131 throw new SqlNullValueException ("The property contains Null.");
137 #endregion // Public Properties
139 #region Public Methods
142 public SqlString Clone()
144 throw new NotImplementedException ();
148 public static CompareOptions CompareOptionsFromSqlCompareOptions (SqlCompareOptions compareOptions)
150 throw new NotImplementedException ();
153 // **********************************
154 // Comparison Methods
155 // **********************************
157 public int CompareTo(object value)
161 else if (!(value is SqlString))
162 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.SqlTypes.SqlString"));
163 else if (((SqlString)value).IsNull)
166 return this.value.CompareTo (((SqlString)value).Value);
169 public static SqlString Concat(SqlString x, SqlString y)
174 public override bool Equals(object value)
176 if (!(value is SqlString))
179 return (bool) (this == (SqlString)value);
182 public static SqlBoolean Equals(SqlString x, SqlString y)
188 public override int GetHashCode()
190 throw new NotImplementedException ();
194 public byte[] GetNonUnicodeBytes()
196 throw new NotImplementedException ();
200 public byte[] GetUnicodeBytes()
202 throw new NotImplementedException ();
205 public static SqlBoolean GreaterThan(SqlString x, SqlString y)
210 public static SqlBoolean GreaterThanOrEqual(SqlString x, SqlString y)
215 public static SqlBoolean LessThan(SqlString x, SqlString y)
220 public static SqlBoolean LessThanOrEqual(SqlString x, SqlString y)
225 public static SqlBoolean NotEquals(SqlString x, SqlString y)
230 // ****************************************
231 // Type Conversions From SqlString To ...
232 // ****************************************
234 public SqlBoolean ToSqlBoolean()
236 return ((SqlBoolean)this);
239 public SqlByte ToSqlByte()
241 return ((SqlByte)this);
244 public SqlDateTime ToSqlDateTime()
246 return ((SqlDateTime)this);
249 public SqlDecimal ToSqlDecimal()
251 return ((SqlDecimal)this);
254 public SqlDouble ToSqlDouble()
256 return ((SqlDouble)this);
259 public SqlGuid ToSqlGuid()
261 return ((SqlGuid)this);
264 public SqlInt16 ToSqlInt16()
266 return ((SqlInt16)this);
269 public SqlInt32 ToSqlInt32()
271 return ((SqlInt32)this);
274 public SqlInt64 ToSqlInt64()
276 return ((SqlInt64)this);
279 public SqlMoney ToSqlMoney()
281 return ((SqlMoney)this);
284 public SqlSingle ToSqlSingle()
286 return ((SqlSingle)this);
289 public override string ToString()
291 return ((string)this);
294 // ***********************************
296 // ***********************************
299 public static SqlString operator + (SqlString x, SqlString y)
301 return new SqlString (x.Value + y.Value);
305 public static SqlBoolean operator == (SqlString x, SqlString y)
307 if (x.IsNull || y.IsNull)
308 return SqlBoolean.Null;
310 return new SqlBoolean (x.Value == y.Value);
314 public static SqlBoolean operator > (SqlString x, SqlString y)
316 if (x.IsNull || y.IsNull)
317 return SqlBoolean.Null;
319 throw new NotImplementedException ();
322 // Greater Than Or Equal
323 public static SqlBoolean operator >= (SqlString x, SqlString y)
325 if (x.IsNull || y.IsNull)
326 return SqlBoolean.Null;
328 throw new NotImplementedException ();
331 public static SqlBoolean operator != (SqlString x, SqlString y)
333 if (x.IsNull || y.IsNull)
334 return SqlBoolean.Null;
336 return new SqlBoolean (x.Value != y.Value);
340 public static SqlBoolean operator < (SqlString x, SqlString y)
342 if (x.IsNull || y.IsNull)
343 return SqlBoolean.Null;
345 throw new NotImplementedException ();
348 // Less Than Or Equal
349 public static SqlBoolean operator <= (SqlString x, SqlString y)
351 if (x.IsNull || y.IsNull)
352 return SqlBoolean.Null;
354 throw new NotImplementedException ();
357 // **************************************
359 // **************************************
361 public static explicit operator SqlString (SqlBoolean x)
366 return new SqlString (x.ByteValue.ToString ());
369 public static explicit operator SqlString (SqlByte x)
374 return new SqlString (x.Value.ToString ());
377 public static explicit operator SqlString (SqlDateTime x)
382 return new SqlString (x.Value.ToString ());
385 public static explicit operator SqlString (SqlDecimal x)
390 return new SqlString (x.Value.ToString ());
393 public static explicit operator SqlString (SqlDouble x)
398 return new SqlString (x.Value.ToString ());
401 public static explicit operator SqlString (SqlGuid x)
406 return new SqlString (x.Value.ToString ());
409 public static explicit operator SqlString (SqlInt16 x)
414 return new SqlString (x.Value.ToString ());
417 public static explicit operator SqlString (SqlInt32 x)
422 return new SqlString (x.Value.ToString ());
425 public static explicit operator SqlString (SqlInt64 x)
430 return new SqlString (x.Value.ToString ());
433 public static explicit operator SqlString (SqlMoney x)
438 return new SqlString (x.Value.ToString ());
441 public static explicit operator SqlString (SqlSingle x)
446 return new SqlString (x.Value.ToString ());
449 public static explicit operator string (SqlString x)
454 public static implicit operator SqlString (string x)
456 return new SqlString (x);
459 #endregion // Public Methods