blob: a686fed178b47032eae36b161296d73f8e544ecf [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>
csharptest819b7152011-09-08 20:28:22 -050052 public interface ICodedOutputStream : IDisposable
csharptestcc8d2aa2011-06-03 12:15:42 -050053 {
csharptestd95293e2011-07-14 14:11:48 -050054 /// <summary>
csharptest60fd7732011-09-09 12:18:16 -050055 /// Writes any message initialization data needed to the output stream
56 /// </summary>
57 /// <remarks>
58 /// This is primarily used by text formats and unnecessary for protobuffers' own
59 /// binary format. The API for MessageStart/End was added for consistent handling
60 /// of output streams regardless of the actual writer implementation.
61 /// </remarks>
62 void WriteMessageStart();
63 /// <summary>
64 /// Writes any message finalization data needed to the output stream
65 /// </summary>
66 /// <remarks>
67 /// This is primarily used by text formats and unnecessary for protobuffers' own
68 /// binary format. The API for MessageStart/End was added for consistent handling
69 /// of output streams regardless of the actual writer implementation.
70 /// </remarks>
71 void WriteMessageEnd();
72 /// <summary>
csharptestd95293e2011-07-14 14:11:48 -050073 /// Indicates that all temporary buffers be written to the final output.
74 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050075 void Flush();
csharptestd95293e2011-07-14 14:11:48 -050076 /// <summary>
77 /// Writes an unknown message as a group
78 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050079 [Obsolete]
csharptest2b868842011-06-10 14:41:47 -050080 void WriteUnknownGroup(int fieldNumber, IMessageLite value);
csharptestd95293e2011-07-14 14:11:48 -050081 /// <summary>
82 /// Writes an unknown field value of bytes
83 /// </summary>
csharptest2b868842011-06-10 14:41:47 -050084 void WriteUnknownBytes(int fieldNumber, ByteString value);
csharptestd95293e2011-07-14 14:11:48 -050085 /// <summary>
86 /// Writes an unknown field of a primitive type
87 /// </summary>
csharptest2b868842011-06-10 14:41:47 -050088 [CLSCompliant(false)]
89 void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value);
csharptestd95293e2011-07-14 14:11:48 -050090 /// <summary>
91 /// Writes an extension as a message-set group
92 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050093 void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
csharptestd95293e2011-07-14 14:11:48 -050094 /// <summary>
95 /// Writes an unknown extension as a message-set group
96 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -050097 void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);
98
csharptestd95293e2011-07-14 14:11:48 -050099 /// <summary>
100 /// Writes a field value, including tag, to the stream.
101 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500102 void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value);
103
csharptestcc8d2aa2011-06-03 12:15:42 -0500104 /// <summary>
105 /// Writes a double field value, including tag, to the stream.
106 /// </summary>
107 void WriteDouble(int fieldNumber, string fieldName, double value);
108
109 /// <summary>
110 /// Writes a float field value, including tag, to the stream.
111 /// </summary>
112 void WriteFloat(int fieldNumber, string fieldName, float value);
113
114 /// <summary>
115 /// Writes a uint64 field value, including tag, to the stream.
116 /// </summary>
117 [CLSCompliant(false)]
118 void WriteUInt64(int fieldNumber, string fieldName, ulong value);
119
120 /// <summary>
121 /// Writes an int64 field value, including tag, to the stream.
122 /// </summary>
123 void WriteInt64(int fieldNumber, string fieldName, long value);
124
125 /// <summary>
126 /// Writes an int32 field value, including tag, to the stream.
127 /// </summary>
128 void WriteInt32(int fieldNumber, string fieldName, int value);
129
130 /// <summary>
131 /// Writes a fixed64 field value, including tag, to the stream.
132 /// </summary>
133 [CLSCompliant(false)]
134 void WriteFixed64(int fieldNumber, string fieldName, ulong value);
135
136 /// <summary>
137 /// Writes a fixed32 field value, including tag, to the stream.
138 /// </summary>
139 [CLSCompliant(false)]
140 void WriteFixed32(int fieldNumber, string fieldName, uint value);
141
142 /// <summary>
143 /// Writes a bool field value, including tag, to the stream.
144 /// </summary>
145 void WriteBool(int fieldNumber, string fieldName, bool value);
146
147 /// <summary>
148 /// Writes a string field value, including tag, to the stream.
149 /// </summary>
150 void WriteString(int fieldNumber, string fieldName, string value);
151
152 /// <summary>
153 /// Writes a group field value, including tag, to the stream.
154 /// </summary>
155 void WriteGroup(int fieldNumber, string fieldName, IMessageLite value);
156
csharptestb00ea132011-06-10 01:09:57 -0500157 /// <summary>
158 /// Writes a message field value, including tag, to the stream.
159 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500160 void WriteMessage(int fieldNumber, string fieldName, IMessageLite value);
csharptest74c5e0c2011-07-14 13:06:22 -0500161
csharptestb00ea132011-06-10 01:09:57 -0500162 /// <summary>
163 /// Writes a byte array field value, including tag, to the stream.
164 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500165 void WriteBytes(int fieldNumber, string fieldName, ByteString value);
166
csharptestb00ea132011-06-10 01:09:57 -0500167 /// <summary>
168 /// Writes a UInt32 field value, including tag, to the stream.
169 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500170 [CLSCompliant(false)]
171 void WriteUInt32(int fieldNumber, string fieldName, uint value);
172
csharptestb00ea132011-06-10 01:09:57 -0500173 /// <summary>
174 /// Writes an enum field value, including tag, to the stream.
175 /// </summary>
csharptestced18e12011-06-09 19:47:56 -0500176 void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
csharptest74c5e0c2011-07-14 13:06:22 -0500177
csharptestb00ea132011-06-10 01:09:57 -0500178 /// <summary>
179 /// Writes a fixed 32-bit field value, including tag, to the stream.
180 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500181 void WriteSFixed32(int fieldNumber, string fieldName, int value);
csharptest74c5e0c2011-07-14 13:06:22 -0500182
csharptestb00ea132011-06-10 01:09:57 -0500183 /// <summary>
184 /// Writes a signed fixed 64-bit field value, including tag, to the stream.
185 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500186 void WriteSFixed64(int fieldNumber, string fieldName, long value);
csharptest74c5e0c2011-07-14 13:06:22 -0500187
csharptestb00ea132011-06-10 01:09:57 -0500188 /// <summary>
189 /// Writes a signed 32-bit field value, including tag, to the stream.
190 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500191 void WriteSInt32(int fieldNumber, string fieldName, int value);
csharptest74c5e0c2011-07-14 13:06:22 -0500192
csharptestb00ea132011-06-10 01:09:57 -0500193 /// <summary>
194 /// Writes a signed 64-bit field value, including tag, to the stream.
195 /// </summary>
csharptestcc8d2aa2011-06-03 12:15:42 -0500196 void WriteSInt64(int fieldNumber, string fieldName, long value);
csharptestb00ea132011-06-10 01:09:57 -0500197
csharptestd95293e2011-07-14 14:11:48 -0500198 /// <summary>
199 /// Writes a repeated field value, including tag(s), to the stream.
200 /// </summary>
csharptest74c5e0c2011-07-14 13:06:22 -0500201 void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
csharptestb00ea132011-06-10 01:09:57 -0500202
csharptestd95293e2011-07-14 14:11:48 -0500203 /// <summary>
204 /// Writes a repeated group value, including tag(s), to the stream.
205 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500206 void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
207 where T : IMessageLite;
csharptest74c5e0c2011-07-14 13:06:22 -0500208
csharptestd95293e2011-07-14 14:11:48 -0500209 /// <summary>
210 /// Writes a repeated message value, including tag(s), to the stream.
211 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500212 void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
213 where T : IMessageLite;
csharptest74c5e0c2011-07-14 13:06:22 -0500214
csharptestd95293e2011-07-14 14:11:48 -0500215 /// <summary>
216 /// Writes a repeated string value, including tag(s), to the stream.
217 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500218 void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500219
csharptestd95293e2011-07-14 14:11:48 -0500220 /// <summary>
221 /// Writes a repeated ByteString value, including tag(s), to the stream.
222 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500223 void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500224
csharptestd95293e2011-07-14 14:11:48 -0500225 /// <summary>
226 /// Writes a repeated boolean value, including tag(s), to the stream.
227 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500228 void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500229
csharptestd95293e2011-07-14 14:11:48 -0500230 /// <summary>
231 /// Writes a repeated Int32 value, including tag(s), to the stream.
232 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500233 void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500234
csharptestd95293e2011-07-14 14:11:48 -0500235 /// <summary>
236 /// Writes a repeated SInt32 value, including tag(s), to the stream.
237 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500238 void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500239
csharptestd95293e2011-07-14 14:11:48 -0500240 /// <summary>
241 /// Writes a repeated UInt32 value, including tag(s), to the stream.
242 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500243 void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500244
csharptestd95293e2011-07-14 14:11:48 -0500245 /// <summary>
246 /// Writes a repeated Fixed32 value, including tag(s), to the stream.
247 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500248 void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500249
csharptestd95293e2011-07-14 14:11:48 -0500250 /// <summary>
251 /// Writes a repeated SFixed32 value, including tag(s), to the stream.
252 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500253 void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500254
csharptestd95293e2011-07-14 14:11:48 -0500255 /// <summary>
256 /// Writes a repeated Int64 value, including tag(s), to the stream.
257 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500258 void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500259
csharptestd95293e2011-07-14 14:11:48 -0500260 /// <summary>
261 /// Writes a repeated SInt64 value, including tag(s), to the stream.
262 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500263 void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500264
csharptestd95293e2011-07-14 14:11:48 -0500265 /// <summary>
266 /// Writes a repeated UInt64 value, including tag(s), to the stream.
267 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500268 void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500269
csharptestd95293e2011-07-14 14:11:48 -0500270 /// <summary>
271 /// Writes a repeated Fixed64 value, including tag(s), to the stream.
272 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500273 void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500274
csharptestd95293e2011-07-14 14:11:48 -0500275 /// <summary>
276 /// Writes a repeated SFixed64 value, including tag(s), to the stream.
277 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500278 void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
279
csharptestd95293e2011-07-14 14:11:48 -0500280 /// <summary>
281 /// Writes a repeated Double value, including tag(s), to the stream.
282 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500283 void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list);
csharptest74c5e0c2011-07-14 13:06:22 -0500284
csharptestd95293e2011-07-14 14:11:48 -0500285 /// <summary>
286 /// Writes a repeated Float value, including tag(s), to the stream.
287 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500288 void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list);
289
csharptestd95293e2011-07-14 14:11:48 -0500290 /// <summary>
291 /// Writes a repeated enumeration value of type T, including tag(s), to the stream.
292 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500293 [CLSCompliant(false)]
csharptest74c5e0c2011-07-14 13:06:22 -0500294 void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
csharptestb00ea132011-06-10 01:09:57 -0500295 where T : struct, IComparable, IFormattable, IConvertible;
296
csharptestd95293e2011-07-14 14:11:48 -0500297 /// <summary>
298 /// Writes a packed repeated primitive, including tag and length, to the stream.
299 /// </summary>
csharptest74c5e0c2011-07-14 13:06:22 -0500300 void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
301
csharptestd95293e2011-07-14 14:11:48 -0500302 /// <summary>
303 /// Writes a packed repeated boolean, including tag and length, to the stream.
304 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500305 void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list);
306
csharptestd95293e2011-07-14 14:11:48 -0500307 /// <summary>
308 /// Writes a packed repeated Int32, including tag and length, to the stream.
309 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500310 void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
311
csharptestd95293e2011-07-14 14:11:48 -0500312 /// <summary>
313 /// Writes a packed repeated SInt32, including tag and length, to the stream.
314 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500315 void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
316
csharptestd95293e2011-07-14 14:11:48 -0500317 /// <summary>
318 /// Writes a packed repeated UInt32, including tag and length, to the stream.
319 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500320 void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
321
csharptestd95293e2011-07-14 14:11:48 -0500322 /// <summary>
323 /// Writes a packed repeated Fixed32, including tag and length, to the stream.
324 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500325 void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
326
csharptestd95293e2011-07-14 14:11:48 -0500327 /// <summary>
328 /// Writes a packed repeated SFixed32, including tag and length, to the stream.
329 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500330 void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
331
csharptestd95293e2011-07-14 14:11:48 -0500332 /// <summary>
333 /// Writes a packed repeated Int64, including tag and length, to the stream.
334 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500335 void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
336
csharptestd95293e2011-07-14 14:11:48 -0500337 /// <summary>
338 /// Writes a packed repeated SInt64, including tag and length, to the stream.
339 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500340 void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
341
csharptestd95293e2011-07-14 14:11:48 -0500342 /// <summary>
343 /// Writes a packed repeated UInt64, including tag and length, to the stream.
344 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500345 void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
346
csharptestd95293e2011-07-14 14:11:48 -0500347 /// <summary>
348 /// Writes a packed repeated Fixed64, including tag and length, to the stream.
349 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500350 void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
351
csharptestd95293e2011-07-14 14:11:48 -0500352 /// <summary>
353 /// Writes a packed repeated SFixed64, including tag and length, to the stream.
354 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500355 void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
356
csharptestd95293e2011-07-14 14:11:48 -0500357 /// <summary>
358 /// Writes a packed repeated Double, including tag and length, to the stream.
359 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500360 void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<double> list);
361
csharptestd95293e2011-07-14 14:11:48 -0500362 /// <summary>
363 /// Writes a packed repeated Float, including tag and length, to the stream.
364 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500365 void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list);
366
csharptestd95293e2011-07-14 14:11:48 -0500367 /// <summary>
368 /// Writes a packed repeated enumeration of type T, including tag and length, to the stream.
369 /// </summary>
csharptestb00ea132011-06-10 01:09:57 -0500370 [CLSCompliant(false)]
371 void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
372 where T : struct, IComparable, IFormattable, IConvertible;
csharptestcc8d2aa2011-06-03 12:15:42 -0500373 }
374}