disable broken tests on net_4_0
[mcs.git] / class / Npgsql / NpgsqlTypes / FastPathArg.cs
blob51277265987b3fbb362702d8861f84c9341a0944
1 /*-------------------------------------------------------------------------
3 FastpathArg.cs
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 -------------------------------------------------------------------------
30 using System;
31 using System.IO;
32 using Npgsql;
34 namespace NpgsqlTypes
36 public class FastpathArg
39 * Type of argument, true=integer, false=byte[]
41 public Boolean type;
44 * Integer value if type=true
46 public Int32 value;
49 * Byte value if type=false;
51 public Byte[] bytes;
54 * Constructs an argument that consists of an integer value
55 * @param value int value to set
57 public FastpathArg(Int32 value)
59 type = true;
60 this.value = value;
64 * Constructs an argument that consists of an array of bytes
65 * @param bytes array to store
67 public FastpathArg(Byte[] bytes)
69 type = false;
70 this.bytes = 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)
81 type = false;
82 bytes = new Byte[len];
83 //TODO:
84 bytes = buf;
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
102 * client code.
104 * @param s output stream
105 * @exception IOException if something failed on the network stream
107 public void Send(Stream s)
109 if (type)
111 // argument is an integer
112 PGUtil.WriteInt32(s, 4);
113 PGUtil.WriteInt32(s, value); // integer value of argument
115 else
117 // argument is a byte array
118 PGUtil.WriteInt32(s, bytes.Length);
119 s.Write(bytes,0,bytes.Length);
123 public Int32 SendSize()
125 if (type)
127 return 8;
129 else
131 return 4+bytes.Length;