2005-07-26 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / Npgsql / Npgsql / NpgsqlExecute.cs
1 // created on 1/7/2003 at 20:03
2 // Npgsql.NpgsqlExecute.cs
3 //
4 // Author:
5 //      Francisco Jr. (fxjrlists@yahoo.com.br)
6 //
7 //      Copyright (C) 2002 The Npgsql Development Team
8 //      npgsql-general@gborg.postgresql.org
9 //      http://gborg.postgresql.org/project/npgsql/projdisplay.php
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
25 using System;
26 using System.IO;
27 using System.Text;
28
29 namespace Npgsql
30 {
31
32     /// <summary>
33     /// This class represents the Parse message sent to PostgreSQL
34     /// server.
35     /// </summary>
36     ///
37     internal sealed class NpgsqlExecute
38     {
39         // Logging related values
40         private static readonly String CLASSNAME = "NpgsqlExecute";
41
42         private String _portalName;
43         private Int32 _maxRows;
44
45
46         public NpgsqlExecute(String portalName, Int32 maxRows)
47         {
48             _portalName = portalName;
49             _maxRows = maxRows;
50         }
51
52         public String PortalName
53         {
54             get
55             {
56                 return _portalName;
57             }
58         }
59
60         public void WriteToStream(Stream outputStream, Encoding encoding)
61         {
62             outputStream.WriteByte((Byte)'E');
63
64             PGUtil.WriteInt32(outputStream, 4 +
65                               encoding.GetByteCount(_portalName) + 1 +
66                               4);
67
68             PGUtil.WriteString(_portalName, outputStream, encoding);
69             PGUtil.WriteInt32(outputStream, _maxRows);
70
71         }
72
73     }
74 }
75