**** Merged from MCS ****
[mono-project.git] / mcs / class / Npgsql / NpgsqlTypes / NpgsqlTypes.cs
blobdb57d90ac1f6580f672576dbc6a2ee7ef466647e
1 // NpgsqlTypes.NpgsqlTypesHelper.cs
2 //
3 // Author:
4 // Glen Parker <glenebob@nwlink.com>
5 //
6 // Copyright (C) 2004 The Npgsql Development Team
7 // npgsql-general@gborg.postgresql.org
8 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 // This file provides implementations of PostgreSQL specific data types that cannot
25 // be mapped to standard .NET classes.
27 using System;
28 using System.Collections;
29 using System.Globalization;
30 using System.Data;
31 using System.Net;
32 using System.Text;
33 using System.IO;
34 using System.Resources;
35 using System.Drawing;
37 namespace NpgsqlTypes
40 /// <summary>
41 /// Represents a PostgreSQL Point type
42 /// </summary>
44 public struct NpgsqlPoint
46 private Single _X;
47 private Single _Y;
49 public NpgsqlPoint(Single X, Single Y)
51 _X = X;
52 _Y = Y;
55 public Single X
57 get
59 return _X;
62 set
64 _X = value;
69 public Single Y
71 get
73 return _Y;
76 set
78 _Y = value;
83 public struct NpgsqlBox
85 private NpgsqlPoint _UpperRight;
86 private NpgsqlPoint _LowerLeft;
88 public NpgsqlBox(NpgsqlPoint UpperRight, NpgsqlPoint LowerLeft)
90 _UpperRight = UpperRight;
91 _LowerLeft = LowerLeft;
95 public NpgsqlPoint UpperRight
97 get
99 return _UpperRight;
103 _UpperRight = value;
107 public NpgsqlPoint LowerLeft
111 return _LowerLeft;
115 _LowerLeft = value;
122 /// <summary>
123 /// Represents a PostgreSQL Line Segment type.
124 /// </summary>
125 public struct NpgsqlLSeg
127 public NpgsqlPoint Start;
128 public NpgsqlPoint End;
130 public NpgsqlLSeg(NpgsqlPoint Start, NpgsqlPoint End)
132 this.Start = Start;
133 this.End = End;
136 public override String ToString()
138 return String.Format("({0}, {1})", Start, End);
142 /// <summary>
143 /// Represents a PostgreSQL Path type.
144 /// </summary>
145 public struct NpgsqlPath
147 internal NpgsqlPoint[] Points;
149 internal Boolean IsOpen;
151 public NpgsqlPath(NpgsqlPoint[] Points)
153 this.Points = Points;
154 IsOpen = false;
157 public Int32 Count
158 { get { return Points.Length; } }
160 public NpgsqlPoint this [Int32 Index]
161 { get { return Points[Index]; } }
163 public Boolean Open
167 return IsOpen;
172 /// <summary>
173 /// Represents a PostgreSQL Polygon type.
174 /// </summary>
175 public struct NpgsqlPolygon
177 internal NpgsqlPoint[] Points;
179 public NpgsqlPolygon(NpgsqlPoint[] Points)
181 this.Points = Points;
184 public Int32 Count
185 { get { return Points.Length; } }
187 public NpgsqlPoint this [Int32 Index]
188 { get { return Points[Index]; } }
191 /// <summary>
192 /// Represents a PostgreSQL Circle type.
193 /// </summary>
194 public struct NpgsqlCircle
196 public NpgsqlPoint Center;
197 public Double Radius;
199 public NpgsqlCircle(NpgsqlPoint Center, Double Radius)
201 this.Center = Center;
202 this.Radius = Radius;
205 public override String ToString()
207 return string.Format("({0}), {1}", Center, Radius);