blob: 861d3fece60ae20fe15c691201311e140c142478 [file] [log] [blame]
csharptestff628f62011-06-11 12:32:36 -05001#region Copyright notice and license
2
3// Protocol Buffers - Google's data interchange format
4// Copyright 2008 Google Inc. All rights reserved.
5// http://github.com/jskeet/dotnet-protobufs/
6// Original C++/Java/Python code:
7// http://code.google.com/p/protobuf/
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// * Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15// * Redistributions in binary form must reproduce the above
16// copyright notice, this list of conditions and the following disclaimer
17// in the documentation and/or other materials provided with the
18// distribution.
19// * Neither the name of Google Inc. nor the names of its
20// contributors may be used to endorse or promote products derived from
21// this software without specific prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35#endregion
36
csharptestcc8d2aa2011-06-03 12:15:42 -050037using System;
csharptest74c5e0c2011-07-14 13:06:22 -050038using System.Collections;
csharptestb00ea132011-06-10 01:09:57 -050039using System.Collections.Generic;
csharptestcc8d2aa2011-06-03 12:15:42 -050040using Google.ProtocolBuffers.Descriptors;
41
csharptestffafdaa2011-06-03 12:58:14 -050042//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
43#pragma warning disable 3010
44
csharptestcc8d2aa2011-06-03 12:15:42 -050045namespace Google.ProtocolBuffers
46{
csharptestd95293e2011-07-14 14:11:48 -050047 /// <summary>
48 /// Provides an interface that is used write a message. Most often proto buffers are written
49 /// in their binary form by creating a instance via the CodedOutputStream.CreateInstance
50 /// static factory.
51 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -050052 public interface ICodedOutputStream
53 {
csharptestd95293e2011-07-14 14:11:48 -050054 /// <summary>
55 /// Indicates that all temporary buffers be written to the final output.
56 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050057 void Flush();
csharptestd95293e2011-07-14 14:11:48 -050058 /// <summary>
59 /// Writes an unknown message as a group
60 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050061 [Obsolete]
csharptest2b868842011-06-10 14:41:47 -050062 void WriteUnknownGroup(int fieldNumber, IMessageLite value);
csharptestd95293e2011-07-14 14:11:48 -050063 /// <summary>
64 /// Writes an unknown field value of bytes
65 /// </summary>
csharptest2b868842011-06-10 14:41:47 -050066 void WriteUnknownBytes(int fieldNumber, ByteString value);
csharptestd95293e2011-07-14 14:11:48 -050067 /// <summary>
68 /// Writes an unknown field of a primitive type
69 /// </summary>
csharptest2b868842011-06-10 14:41:47 -050070 [CLSCompliant(false)]
71 void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value);
csharptestd95293e2011-07-14 14:11:48 -050072 /// <summary>
73 /// Writes an extension as a message-set group
74 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050075 void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
csharptestd95293e2011-07-14 14:11:48 -050076 /// <summary>
77 /// Writes an unknown extension as a message-set group
78 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050079 void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);
80
csharptestd95293e2011-07-14 14:11:48 -050081 /// <summary>
82 /// Writes a field value, including tag, to the stream.
83 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050084 void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value);
85
csharptestcc8d2aa2011-06-03 12:15:42 -050086 /// <summary>
87 /// Writes a double field value, including tag, to the stream.
88 /// </summary>
89 void WriteDouble(int fieldNumber, string fieldName, double value);
90
91 /// <summary>
92 /// Writes a float field value, including tag, to the stream.
93 /// </summary>
94 void WriteFloat(int fieldNumber, string fieldName, float value);
95
96 /// <summary>
97 /// Writes a uint64 field value, including tag, to the stream.
98 /// </summary>
99 [CLSCompliant(false)]
100 void WriteUInt64(int fieldNumber, string fieldName, ulong value);
101
102 /// <summary>
103 /// Writes an int64 field value, including tag, to the stream.
104 /// </summary>
105 void WriteInt64(int fieldNumber, string fieldName, long value);
106
107 /// <summary>
108 /// Writes an int32 field value, including tag, to the stream.
109 /// </summary>
110 void WriteInt32(int fieldNumber, string fieldName, int value);
111
112 /// <summary>
113 /// Writes a fixed64 field value, including tag, to the stream.
114 /// </summary>
115 [CLSCompliant(false)]
116 void WriteFixed64(int fieldNumber, string fieldName, ulong value);
117
118 /// <summary>
119 /// Writes a fixed32 field value, including tag, to the stream.
120 /// </summary>
121 [CLSCompliant(false)]
122 void WriteFixed32(int fieldNumber, string fieldName, uint value);
123
124 /// <summary>
125 /// Writes a bool field value, including tag, to the stream.
126 /// </summary>
127 void WriteBool(int fieldNumber, string fieldName, bool value);
128
129 /// <summary>
130 /// Writes a string field value, including tag, to the stream.
131 /// </summary>
132 void WriteString(int fieldNumber, string fieldName, string value);
133
134 /// <summary>
135 /// Writes a group field value, including tag, to the stream.
136 /// </summary>
137 void WriteGroup(int fieldNumber, string fieldName, IMessageLite value);
138
csharptestb00ea132011-06-10 01:09:57 -0500139 /// <summary>
140 /// Writes a message field value, including tag, to the stream.
141 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500142 void WriteMessage(int fieldNumber, string fieldName, IMessageLite value);
csharptest74c5e0c2011-07-14 13:06:22 -0500143
csharptestb00ea132011-06-10 01:09:57 -0500144 /// <summary>
145 /// Writes a byte array field value, including tag, to the stream.
146 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500147 void WriteBytes(int fieldNumber, string fieldName, ByteString value);
148
csharptestb00ea132011-06-10 01:09:57 -0500149 /// <summary>
150 /// Writes a UInt32 field value, including tag, to the stream.
151 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500152 [CLSCompliant(false)]
153 void WriteUInt32(int fieldNumber, string fieldName, uint value);
154
csharptestb00ea132011-06-10 01:09:57 -0500155 /// <summary>
156 /// Writes an enum field value, including tag, to the stream.
157 /// </summary>
csharptestced18e12011-06-09 19:47:56 -0500158 void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
csharptest74c5e0c2011-07-14 13:06:22 -0500159
csharptestb00ea132011-06-10 01:09:57 -0500160 /// <summary>
161 /// Writes a fixed 32-bit field value, including tag, to the stream.
162 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500163 void WriteSFixed32(int fieldNumber, string fieldName, int value);
csharptest74c5e0c2011-07-14 13:06:22 -0500164
csharptestb00ea132011-06-10 01:09:57 -0500165 /// <summary>
166 /// Writes a signed fixed 64-bit field value, including tag, to the stream.
167 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500168 void WriteSFixed64(int fieldNumber, string fieldName, long value);
csharptest74c5e0c2011-07-14 13:06:22 -0500169
csharptestb00ea132011-06-10 01:09:57 -0500170 /// <summary>
171 /// Writes a signed 32-bit field value, including tag, to the stream.
172 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500173 void WriteSInt32(int fieldNumber, string fieldName, int value);
csharptest74c5e0c2011-07-14 13:06:22 -0500174
csharptestb00ea132011-06-10 01:09:57 -0500175 /// <summary>
176 /// Writes a signed 64-bit field value, including tag, to the stream.
177 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500178 void WriteSInt64(int fieldNumber, string fieldName, long value);
csharptestb00ea132011-06-10 01:09:57 -0500179
csharptestd95293e2011-07-14 14:11:48 -0500180 /// <summary>
181 /// Writes a repeated field value, including tag(s), to the stream.
182 /// </summary>
csharptest74c5e0c2011-07-14 13:06:22 -0500183 void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
csharptestb00ea132011-06-10 01:09:57 -0500184
csharptestd95293e2011-07-14 14:11:48 -0500185 /// <summary>
186 /// Writes a repeated group value, including tag(s), to the stream.
187 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500188 void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
189 where T : IMessageLite;
csharptest74c5e0c2011-07-14 13:06:22 -0500190
csharptestd95293e2011-07-14 14:11:48 -0500191 /// <summary>
192 /// Writes a repeated message value, including tag(s), to the stream.
193 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500194 void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
195 where T : IMessageLite;
csharptest74c5e0c2011-07-14 13:06:22 -0500196
csharptestd95293e2011-07-14 14:11:48 -0500197 /// <summary>
198 /// Writes a repeated string value, including tag(s), to the stream.
199 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500200 void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500201
csharptestd95293e2011-07-14 14:11:48 -0500202 /// <summary>
203 /// Writes a repeated ByteString value, including tag(s), to the stream.
204 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500205 void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500206
csharptestd95293e2011-07-14 14:11:48 -0500207 /// <summary>
208 /// Writes a repeated boolean value, including tag(s), to the stream.
209 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500210 void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500211
csharptestd95293e2011-07-14 14:11:48 -0500212 /// <summary>
213 /// Writes a repeated Int32 value, including tag(s), to the stream.
214 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500215 void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500216
csharptestd95293e2011-07-14 14:11:48 -0500217 /// <summary>
218 /// Writes a repeated SInt32 value, including tag(s), to the stream.
219 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500220 void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500221
csharptestd95293e2011-07-14 14:11:48 -0500222 /// <summary>
223 /// Writes a repeated UInt32 value, including tag(s), to the stream.
224 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500225 void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500226
csharptestd95293e2011-07-14 14:11:48 -0500227 /// <summary>
228 /// Writes a repeated Fixed32 value, including tag(s), to the stream.
229 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500230 void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500231
csharptestd95293e2011-07-14 14:11:48 -0500232 /// <summary>
233 /// Writes a repeated SFixed32 value, including tag(s), to the stream.
234 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500235 void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500236
csharptestd95293e2011-07-14 14:11:48 -0500237 /// <summary>
238 /// Writes a repeated Int64 value, including tag(s), to the stream.
239 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500240 void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500241
csharptestd95293e2011-07-14 14:11:48 -0500242 /// <summary>
243 /// Writes a repeated SInt64 value, including tag(s), to the stream.
244 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500245 void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500246
csharptestd95293e2011-07-14 14:11:48 -0500247 /// <summary>
248 /// Writes a repeated UInt64 value, including tag(s), to the stream.
249 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500250 void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500251
csharptestd95293e2011-07-14 14:11:48 -0500252 /// <summary>
253 /// Writes a repeated Fixed64 value, including tag(s), to the stream.
254 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500255 void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500256
csharptestd95293e2011-07-14 14:11:48 -0500257 /// <summary>
258 /// Writes a repeated SFixed64 value, including tag(s), to the stream.
259 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500260 void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
261
csharptestd95293e2011-07-14 14:11:48 -0500262 /// <summary>
263 /// Writes a repeated Double value, including tag(s), to the stream.
264 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500265 void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500266
csharptestd95293e2011-07-14 14:11:48 -0500267 /// <summary>
268 /// Writes a repeated Float value, including tag(s), to the stream.
269 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500270 void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list);
271
csharptestd95293e2011-07-14 14:11:48 -0500272 /// <summary>
273 /// Writes a repeated enumeration value of type T, including tag(s), to the stream.
274 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500275 [CLSCompliant(false)]
csharptest74c5e0c2011-07-14 13:06:22 -0500276 void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
csharptestb00ea132011-06-10 01:09:57 -0500277 where T : struct, IComparable, IFormattable, IConvertible;
278
csharptestd95293e2011-07-14 14:11:48 -0500279 /// <summary>
280 /// Writes a packed repeated primitive, including tag and length, to the stream.
281 /// </summary>
csharptest74c5e0c2011-07-14 13:06:22 -0500282 void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
283
csharptestd95293e2011-07-14 14:11:48 -0500284 /// <summary>
285 /// Writes a packed repeated boolean, including tag and length, to the stream.
286 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500287 void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list);
288
csharptestd95293e2011-07-14 14:11:48 -0500289 /// <summary>
290 /// Writes a packed repeated Int32, including tag and length, to the stream.
291 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500292 void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
293
csharptestd95293e2011-07-14 14:11:48 -0500294 /// <summary>
295 /// Writes a packed repeated SInt32, including tag and length, to the stream.
296 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500297 void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
298
csharptestd95293e2011-07-14 14:11:48 -0500299 /// <summary>
300 /// Writes a packed repeated UInt32, including tag and length, to the stream.
301 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500302 void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
303
csharptestd95293e2011-07-14 14:11:48 -0500304 /// <summary>
305 /// Writes a packed repeated Fixed32, including tag and length, to the stream.
306 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500307 void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
308
csharptestd95293e2011-07-14 14:11:48 -0500309 /// <summary>
310 /// Writes a packed repeated SFixed32, including tag and length, to the stream.
311 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500312 void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
313
csharptestd95293e2011-07-14 14:11:48 -0500314 /// <summary>
315 /// Writes a packed repeated Int64, including tag and length, to the stream.
316 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500317 void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
318
csharptestd95293e2011-07-14 14:11:48 -0500319 /// <summary>
320 /// Writes a packed repeated SInt64, including tag and length, to the stream.
321 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500322 void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
323
csharptestd95293e2011-07-14 14:11:48 -0500324 /// <summary>
325 /// Writes a packed repeated UInt64, including tag and length, to the stream.
326 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500327 void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
328
csharptestd95293e2011-07-14 14:11:48 -0500329 /// <summary>
330 /// Writes a packed repeated Fixed64, including tag and length, to the stream.
331 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500332 void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
333
csharptestd95293e2011-07-14 14:11:48 -0500334 /// <summary>
335 /// Writes a packed repeated SFixed64, including tag and length, to the stream.
336 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500337 void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
338
csharptestd95293e2011-07-14 14:11:48 -0500339 /// <summary>
340 /// Writes a packed repeated Double, including tag and length, to the stream.
341 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500342 void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<double> list);
343
csharptestd95293e2011-07-14 14:11:48 -0500344 /// <summary>
345 /// Writes a packed repeated Float, including tag and length, to the stream.
346 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500347 void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list);
348
csharptestd95293e2011-07-14 14:11:48 -0500349 /// <summary>
350 /// Writes a packed repeated enumeration of type T, including tag and length, to the stream.
351 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500352 [CLSCompliant(false)]
353 void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
354 where T : struct, IComparable, IFormattable, IConvertible;
csharptestcc8d2aa2011-06-03 12:15:42 -0500355 }
356}