1 /*-------------------------------------------------------------------------
4 This class is a port of the class FastpathArg.java implemented by
5 PostgreSQL Global Development Group
7 Copyright (c) 2004, Emiliano Necciari
8 Original Code: Copyright (c) 2003, PostgreSQL Global Development Group
10 Note: (Francisco Figueiredo Jr.)
11 Changed case of method names to conform to .Net names standard.
12 Also changed type names to their true names. i.e. int -> Int32
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 2.1 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 -------------------------------------------------------------------------
36 public class FastpathArg
39 * Type of argument, true=integer, false=byte[]
44 * Integer value if type=true
49 * Byte value if type=false;
54 * Constructs an argument that consists of an integer value
55 * @param value int value to set
57 public FastpathArg(Int32
value)
64 * Constructs an argument that consists of an array of bytes
65 * @param bytes array to store
67 public FastpathArg(Byte
[] bytes
)
74 * Constructs an argument that consists of part of a byte array
75 * @param buf source array
76 * @param off offset within array
77 * @param len length of data to include
79 public FastpathArg(Byte
[] buf
, Int32 off
, Int32 len
)
82 bytes
= new Byte
[len
];
88 * Constructs an argument that consists of a String.
89 * @param s String to store
91 public FastpathArg(String s
)
93 //this(s.ToCharArray());
97 * This sends this argument down the network stream.
99 * <p>The stream sent consists of the length.int4 then the contents.
101 * <p><b>Note:</b> This is called from Fastpath, and cannot be called from
104 * @param s output stream
105 * @exception IOException if something failed on the network stream
107 public void Send(Stream s
)
111 // argument is an integer
112 PGUtil
.WriteInt32(s
, 4);
113 PGUtil
.WriteInt32(s
, value); // integer value of argument
117 // argument is a byte array
118 PGUtil
.WriteInt32(s
, bytes
.Length
);
119 s
.Write(bytes
,0,bytes
.Length
);
123 public Int32
SendSize()
131 return 4+bytes
.Length
;