(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Npgsql / Npgsql / NpgsqlParse.cs
blob129a266a0683c5d491ae30bfa03f98c39b793b73
1 // created on 22/6/2003 at 18:33
3 // Npgsql.NpgsqlParse.cs
4 //
5 // Author:
6 // Francisco Jr. (fxjrlists@yahoo.com.br)
7 //
8 // Copyright (C) 2002 The Npgsql Development Team
9 // npgsql-general@gborg.postgresql.org
10 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 using System;
27 using System.Collections;
28 using System.IO;
29 using System.Text;
30 using System.Net;
31 using NpgsqlTypes;
34 namespace Npgsql
37 /// <summary>
38 /// This class represents the Parse message sent to PostgreSQL
39 /// server.
40 /// </summary>
41 ///
42 internal sealed class NpgsqlParse
44 // Logging related values
45 private static readonly String CLASSNAME = "NpgsqlParse";
47 private String _prepareName;
48 private String _queryString;
49 private Int32[] _parameterIDs;
52 public NpgsqlParse(String prepareName, String queryString, Int32[] parameterIDs)
54 _prepareName = prepareName;
55 _queryString = queryString;
56 _parameterIDs = parameterIDs;
60 public void WriteToStream(Stream outputStream, Encoding encoding)
62 outputStream.WriteByte((Byte)'P');
64 // message length =
65 // Int32 self
66 // name of prepared statement + 1 null string terminator +
67 // query string + 1 null string terminator
68 // + Int16
69 // + Int32 * number of parameters.
70 Int32 messageLength = 4 + encoding.GetByteCount(_prepareName) + 1 + encoding.GetByteCount(_queryString) + 1 + 2 + (_parameterIDs.Length * 4);
71 //Int32 messageLength = 4 + _prepareName.Length + 1 + _queryString.Length + 1 + 2 + (_parameterIDs.Length * 4);
73 PGUtil.WriteInt32(outputStream, messageLength);
74 PGUtil.WriteString(_prepareName, outputStream, encoding);
75 PGUtil.WriteString(_queryString, outputStream, encoding);
76 PGUtil.WriteInt16(outputStream, (Int16)_parameterIDs.Length);
79 for(Int32 i = 0; i < _parameterIDs.Length; i++)
80 PGUtil.WriteInt32(outputStream, _parameterIDs[i]);