aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Base/BaseDataReader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/Base/BaseDataReader.cs')
-rw-r--r--OpenSim/Data/Base/BaseDataReader.cs205
1 files changed, 0 insertions, 205 deletions
diff --git a/OpenSim/Data/Base/BaseDataReader.cs b/OpenSim/Data/Base/BaseDataReader.cs
deleted file mode 100644
index 23f03e5..0000000
--- a/OpenSim/Data/Base/BaseDataReader.cs
+++ /dev/null
@@ -1,205 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Data;
30using System.IO;
31
32namespace OpenSim.Data.Base
33{
34 /// <summary>
35 ///
36 /// </summary>
37 public abstract class BaseDataReader
38 {
39 private readonly IDataReader m_source;
40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <param name="source"></param>
45 public BaseDataReader(IDataReader source)
46 {
47 m_source = source;
48 }
49
50 /// <summary>
51 ///
52 /// </summary>
53 /// <param name="name"></param>
54 /// <returns></returns>
55 public object Get(string name)
56 {
57 return m_source[name];
58 }
59
60 /// <summary>
61 ///
62 /// </summary>
63 /// <param name="name"></param>
64 /// <returns></returns>
65 public ushort GetUShort(string name)
66 {
67 return (ushort)m_source.GetInt32(m_source.GetOrdinal(name));
68 }
69
70 /// <summary>
71 ///
72 /// </summary>
73 /// <param name="name"></param>
74 /// <returns></returns>
75 public byte GetByte(string name)
76 {
77 int ordinal = m_source.GetOrdinal(name);
78 byte value = (byte)m_source.GetInt16(ordinal);
79 return value;
80 }
81
82 /// <summary>
83 ///
84 /// </summary>
85 /// <param name="name"></param>
86 /// <returns></returns>
87 public sbyte GetSByte(string name)
88 {
89 return (sbyte)m_source.GetInt16(m_source.GetOrdinal(name));
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="name"></param>
96 /// <returns></returns>
97 public float GetFloat(string name)
98 {
99 return m_source.GetFloat(m_source.GetOrdinal(name));
100 }
101
102 /// <summary>
103 ///
104 /// </summary>
105 /// <param name="name"></param>
106 /// <returns></returns>
107 public byte[] GetBytes(string name)
108 {
109 int ordinal = m_source.GetOrdinal(name);
110
111 if (m_source.GetValue(ordinal) == DBNull.Value)
112 {
113 return null;
114 }
115
116 byte[] buffer = new byte[16384];
117
118 MemoryStream memStream = new MemoryStream();
119
120 long totalRead = 0;
121
122 int bytesRead;
123 do
124 {
125 bytesRead = (int)m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length);
126 totalRead += bytesRead;
127
128 memStream.Write(buffer, 0, bytesRead);
129 } while (bytesRead == buffer.Length);
130
131 return memStream.ToArray();
132 }
133
134 /// <summary>
135 ///
136 /// </summary>
137 /// <param name="name"></param>
138 /// <returns></returns>
139 public string GetString(string name)
140 {
141 int ordinal = m_source.GetOrdinal(name);
142 object value = m_source.GetValue(ordinal);
143
144 if (value is DBNull)
145 {
146 return null;
147 }
148
149 return (string)value;
150 }
151
152 /// <summary>
153 ///
154 /// </summary>
155 /// <returns></returns>
156 public bool Read()
157 {
158 return m_source.Read();
159 }
160
161 /// <summary>
162 ///
163 /// </summary>
164 /// <param name="name"></param>
165 /// <returns></returns>
166 public virtual Guid GetGuid(string name)
167 {
168 return m_source.GetGuid(m_source.GetOrdinal(name));
169 }
170
171 /// <summary>
172 ///
173 /// </summary>
174 /// <param name="name"></param>
175 /// <returns></returns>
176 public UInt32 GetUInt32(string name)
177 {
178 return (UInt32)GetInt32(name);
179 }
180
181 /// <summary>
182 ///
183 /// </summary>
184 /// <param name="name"></param>
185 /// <returns></returns>
186 private Int32 GetInt32(string name)
187 {
188 int ordinal = m_source.GetOrdinal(name);
189 int int32 = m_source.GetInt32(ordinal);
190 return int32;
191 }
192
193 /// <summary>
194 ///
195 /// </summary>
196 /// <param name="name"></param>
197 /// <returns></returns>
198 public Int64 GetInt64(string name)
199 {
200 int ordinal = m_source.GetOrdinal(name);
201 long int64 = m_source.GetInt64(ordinal);
202 return int64;
203 }
204 }
205}