(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Data.MySql / Mono.Data.MySql / Field.cs
blobd7487beca4b7851332b166d40872320267362d21
1 //
2 // Field.cs
3 //
4 // Provide definition for the Field class
5 // Part of the C# bindings to MySQL library libMySQL.dll
6 //
7 // Author:
8 // Brad Merrill <zbrad@cybercom.net>
9 // Daniel Morgan <danmorg@sc.rr.com>
11 // (C)Copyright 2002 Brad Merril
12 // (C)Copyright 2002 Daniel Morgan
14 // http://www.cybercom.net/~zbrad/DotNet/MySql/
16 // Mono has gotten permission from Brad Merrill to include in
17 // the Mono Class Library
18 // his C# bindings to MySQL under the X11 License
20 // Mono can be found at http://www.go-mono.com/
21 // The X11/MIT License can be found
22 // at http://www.opensource.org/licenses/mit-license.html
26 // Permission is hereby granted, free of charge, to any person obtaining
27 // a copy of this software and associated documentation files (the
28 // "Software"), to deal in the Software without restriction, including
29 // without limitation the rights to use, copy, modify, merge, publish,
30 // distribute, sublicense, and/or sell copies of the Software, and to
31 // permit persons to whom the Software is furnished to do so, subject to
32 // the following conditions:
33 //
34 // The above copyright notice and this permission notice shall be
35 // included in all copies or substantial portions of the Software.
36 //
37 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
43 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 namespace Mono.Data.MySql {
48 using System;
49 using System.Runtime.InteropServices;
51 [Flags]
52 internal enum MySqlFieldFlags : uint {
53 NOT_NULL_FLAG = 1,
54 PRI_KEY_FLAG = 2,
55 UNIQUE_KEY_FLAG = 4,
56 MULTIPLE_KEY_FLAG = 8,
57 BLOB_FLAG = 16,
58 UNSIGNED_FLAG = 32,
59 ZEROFILL_FLAG = 64,
60 BINARY_FLAG = 128,
61 ENUM_FLAG = 256,
62 AUTO_INCREMENT_FLAG = 512,
63 TIMESTAMP_FLAG = 1024,
64 SET_FLAG = 2048,
65 NUM_FLAG = 32768,
66 PART_KEY_FLAG = 16384,
67 GROUP_FLAG = 32768,
68 UNIQUE_FLAG = 65536
71 ///<remarks>
72 ///<para>
73 /// MySql P/Invoke implementation test program
74 /// Brad Merrill
75 /// 3-Mar-2002
76 ///</para>
77 ///<para>
78 /// This structure contains information about a field, such as the
79 /// field's name, type, and size. Its members are described in more
80 /// detail below. You may obtain the <see cref="Field"/> structures for
81 /// each field by calling
82 /// <see cref="MySql.FetchField"/>
83 /// repeatedly.
84 /// Field values are not part of this structure;
85 /// they are contained in a Row structure.
86 ///</para>
87 ///</remarks>
88 [StructLayout(LayoutKind.Sequential)]
89 public class MySqlMarshalledField {
91 ///<value>name of column</value>
92 [MarshalAs(UnmanagedType.LPStr)]
93 public string Name;
94 ///<value>table of column</value>
95 [MarshalAs(UnmanagedType.LPStr)]
96 public string Table;
97 ///<value>default value</value>
98 [MarshalAs(UnmanagedType.LPStr)]
99 public string Def;
100 ///<value>type of field</value>
101 public int FieldType;
102 ///<value>width of column</value>
103 public uint Length;
104 ///<value>max width of selected set</value>
105 public uint MaxLength;
106 ///<value>div flags</value>
107 public uint Flags;
108 ///<value>number of decimals in field</value>
109 public uint Decimals;
112 internal sealed class MySqlFieldHelper {
114 public static bool IsPrimaryKey(uint fieldFlags) {
115 // if ((SomeEnum)U & SomeEnum.EnumFlagValue) != 0) {...}
116 if(! (((MySqlFieldFlags) fieldFlags) & MySqlFieldFlags.PRI_KEY_FLAG).Equals(0))
117 return true;
118 else
119 return false;
122 public static bool IsNotNull(uint fieldFlags) {
124 if(! (((MySqlFieldFlags) fieldFlags) & MySqlFieldFlags.NOT_NULL_FLAG).Equals(0))
125 return true;
126 else
127 return false;
130 public static bool IsBlob(uint fieldFlags) {
132 if(! (((MySqlFieldFlags) fieldFlags) & MySqlFieldFlags.BLOB_FLAG).Equals(0))
133 return true;
134 else
135 return false;