ICodedOutputStream.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. #region Copyright notice and license
  2. // Protocol Buffers - Google's data interchange format
  3. // Copyright 2008 Google Inc. All rights reserved.
  4. // http://github.com/jskeet/dotnet-protobufs/
  5. // Original C++/Java/Python code:
  6. // http://code.google.com/p/protobuf/
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are
  10. // met:
  11. //
  12. // * Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. // * Redistributions in binary form must reproduce the above
  15. // copyright notice, this list of conditions and the following disclaimer
  16. // in the documentation and/or other materials provided with the
  17. // distribution.
  18. // * Neither the name of Google Inc. nor the names of its
  19. // contributors may be used to endorse or promote products derived from
  20. // this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. #endregion
  34. using System;
  35. using System.Collections;
  36. using System.Collections.Generic;
  37. using Google.ProtocolBuffers.Descriptors;
  38. //Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
  39. #pragma warning disable 3010
  40. namespace Google.ProtocolBuffers
  41. {
  42. /// <summary>
  43. /// Provides an interface that is used write a message. Most often proto buffers are written
  44. /// in their binary form by creating a instance via the CodedOutputStream.CreateInstance
  45. /// static factory.
  46. /// </summary>
  47. public interface ICodedOutputStream : IDisposable
  48. {
  49. /// <summary>
  50. /// Indicates that all temporary buffers be written to the final output.
  51. /// </summary>
  52. void Flush();
  53. /// <summary>
  54. /// Writes an unknown message as a group
  55. /// </summary>
  56. [Obsolete]
  57. void WriteUnknownGroup(int fieldNumber, IMessageLite value);
  58. /// <summary>
  59. /// Writes an unknown field value of bytes
  60. /// </summary>
  61. void WriteUnknownBytes(int fieldNumber, ByteString value);
  62. /// <summary>
  63. /// Writes an unknown field of a primitive type
  64. /// </summary>
  65. [CLSCompliant(false)]
  66. void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value);
  67. /// <summary>
  68. /// Writes an extension as a message-set group
  69. /// </summary>
  70. void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
  71. /// <summary>
  72. /// Writes an unknown extension as a message-set group
  73. /// </summary>
  74. void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);
  75. /// <summary>
  76. /// Writes a field value, including tag, to the stream.
  77. /// </summary>
  78. void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value);
  79. /// <summary>
  80. /// Writes a double field value, including tag, to the stream.
  81. /// </summary>
  82. void WriteDouble(int fieldNumber, string fieldName, double value);
  83. /// <summary>
  84. /// Writes a float field value, including tag, to the stream.
  85. /// </summary>
  86. void WriteFloat(int fieldNumber, string fieldName, float value);
  87. /// <summary>
  88. /// Writes a uint64 field value, including tag, to the stream.
  89. /// </summary>
  90. [CLSCompliant(false)]
  91. void WriteUInt64(int fieldNumber, string fieldName, ulong value);
  92. /// <summary>
  93. /// Writes an int64 field value, including tag, to the stream.
  94. /// </summary>
  95. void WriteInt64(int fieldNumber, string fieldName, long value);
  96. /// <summary>
  97. /// Writes an int32 field value, including tag, to the stream.
  98. /// </summary>
  99. void WriteInt32(int fieldNumber, string fieldName, int value);
  100. /// <summary>
  101. /// Writes a fixed64 field value, including tag, to the stream.
  102. /// </summary>
  103. [CLSCompliant(false)]
  104. void WriteFixed64(int fieldNumber, string fieldName, ulong value);
  105. /// <summary>
  106. /// Writes a fixed32 field value, including tag, to the stream.
  107. /// </summary>
  108. [CLSCompliant(false)]
  109. void WriteFixed32(int fieldNumber, string fieldName, uint value);
  110. /// <summary>
  111. /// Writes a bool field value, including tag, to the stream.
  112. /// </summary>
  113. void WriteBool(int fieldNumber, string fieldName, bool value);
  114. /// <summary>
  115. /// Writes a string field value, including tag, to the stream.
  116. /// </summary>
  117. void WriteString(int fieldNumber, string fieldName, string value);
  118. /// <summary>
  119. /// Writes a group field value, including tag, to the stream.
  120. /// </summary>
  121. void WriteGroup(int fieldNumber, string fieldName, IMessageLite value);
  122. /// <summary>
  123. /// Writes a message field value, including tag, to the stream.
  124. /// </summary>
  125. void WriteMessage(int fieldNumber, string fieldName, IMessageLite value);
  126. /// <summary>
  127. /// Writes a byte array field value, including tag, to the stream.
  128. /// </summary>
  129. void WriteBytes(int fieldNumber, string fieldName, ByteString value);
  130. /// <summary>
  131. /// Writes a UInt32 field value, including tag, to the stream.
  132. /// </summary>
  133. [CLSCompliant(false)]
  134. void WriteUInt32(int fieldNumber, string fieldName, uint value);
  135. /// <summary>
  136. /// Writes an enum field value, including tag, to the stream.
  137. /// </summary>
  138. void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
  139. /// <summary>
  140. /// Writes a fixed 32-bit field value, including tag, to the stream.
  141. /// </summary>
  142. void WriteSFixed32(int fieldNumber, string fieldName, int value);
  143. /// <summary>
  144. /// Writes a signed fixed 64-bit field value, including tag, to the stream.
  145. /// </summary>
  146. void WriteSFixed64(int fieldNumber, string fieldName, long value);
  147. /// <summary>
  148. /// Writes a signed 32-bit field value, including tag, to the stream.
  149. /// </summary>
  150. void WriteSInt32(int fieldNumber, string fieldName, int value);
  151. /// <summary>
  152. /// Writes a signed 64-bit field value, including tag, to the stream.
  153. /// </summary>
  154. void WriteSInt64(int fieldNumber, string fieldName, long value);
  155. /// <summary>
  156. /// Writes a repeated field value, including tag(s), to the stream.
  157. /// </summary>
  158. void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
  159. /// <summary>
  160. /// Writes a repeated group value, including tag(s), to the stream.
  161. /// </summary>
  162. void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
  163. where T : IMessageLite;
  164. /// <summary>
  165. /// Writes a repeated message value, including tag(s), to the stream.
  166. /// </summary>
  167. void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
  168. where T : IMessageLite;
  169. /// <summary>
  170. /// Writes a repeated string value, including tag(s), to the stream.
  171. /// </summary>
  172. void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list);
  173. /// <summary>
  174. /// Writes a repeated ByteString value, including tag(s), to the stream.
  175. /// </summary>
  176. void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list);
  177. /// <summary>
  178. /// Writes a repeated boolean value, including tag(s), to the stream.
  179. /// </summary>
  180. void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list);
  181. /// <summary>
  182. /// Writes a repeated Int32 value, including tag(s), to the stream.
  183. /// </summary>
  184. void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
  185. /// <summary>
  186. /// Writes a repeated SInt32 value, including tag(s), to the stream.
  187. /// </summary>
  188. void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
  189. /// <summary>
  190. /// Writes a repeated UInt32 value, including tag(s), to the stream.
  191. /// </summary>
  192. void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
  193. /// <summary>
  194. /// Writes a repeated Fixed32 value, including tag(s), to the stream.
  195. /// </summary>
  196. void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
  197. /// <summary>
  198. /// Writes a repeated SFixed32 value, including tag(s), to the stream.
  199. /// </summary>
  200. void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
  201. /// <summary>
  202. /// Writes a repeated Int64 value, including tag(s), to the stream.
  203. /// </summary>
  204. void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
  205. /// <summary>
  206. /// Writes a repeated SInt64 value, including tag(s), to the stream.
  207. /// </summary>
  208. void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
  209. /// <summary>
  210. /// Writes a repeated UInt64 value, including tag(s), to the stream.
  211. /// </summary>
  212. void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
  213. /// <summary>
  214. /// Writes a repeated Fixed64 value, including tag(s), to the stream.
  215. /// </summary>
  216. void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
  217. /// <summary>
  218. /// Writes a repeated SFixed64 value, including tag(s), to the stream.
  219. /// </summary>
  220. void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
  221. /// <summary>
  222. /// Writes a repeated Double value, including tag(s), to the stream.
  223. /// </summary>
  224. void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list);
  225. /// <summary>
  226. /// Writes a repeated Float value, including tag(s), to the stream.
  227. /// </summary>
  228. void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list);
  229. /// <summary>
  230. /// Writes a repeated enumeration value of type T, including tag(s), to the stream.
  231. /// </summary>
  232. [CLSCompliant(false)]
  233. void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
  234. where T : struct, IComparable, IFormattable, IConvertible;
  235. /// <summary>
  236. /// Writes a packed repeated primitive, including tag and length, to the stream.
  237. /// </summary>
  238. void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
  239. /// <summary>
  240. /// Writes a packed repeated boolean, including tag and length, to the stream.
  241. /// </summary>
  242. void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list);
  243. /// <summary>
  244. /// Writes a packed repeated Int32, including tag and length, to the stream.
  245. /// </summary>
  246. void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
  247. /// <summary>
  248. /// Writes a packed repeated SInt32, including tag and length, to the stream.
  249. /// </summary>
  250. void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
  251. /// <summary>
  252. /// Writes a packed repeated UInt32, including tag and length, to the stream.
  253. /// </summary>
  254. void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
  255. /// <summary>
  256. /// Writes a packed repeated Fixed32, including tag and length, to the stream.
  257. /// </summary>
  258. void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
  259. /// <summary>
  260. /// Writes a packed repeated SFixed32, including tag and length, to the stream.
  261. /// </summary>
  262. void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
  263. /// <summary>
  264. /// Writes a packed repeated Int64, including tag and length, to the stream.
  265. /// </summary>
  266. void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
  267. /// <summary>
  268. /// Writes a packed repeated SInt64, including tag and length, to the stream.
  269. /// </summary>
  270. void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
  271. /// <summary>
  272. /// Writes a packed repeated UInt64, including tag and length, to the stream.
  273. /// </summary>
  274. void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
  275. /// <summary>
  276. /// Writes a packed repeated Fixed64, including tag and length, to the stream.
  277. /// </summary>
  278. void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
  279. /// <summary>
  280. /// Writes a packed repeated SFixed64, including tag and length, to the stream.
  281. /// </summary>
  282. void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
  283. /// <summary>
  284. /// Writes a packed repeated Double, including tag and length, to the stream.
  285. /// </summary>
  286. void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<double> list);
  287. /// <summary>
  288. /// Writes a packed repeated Float, including tag and length, to the stream.
  289. /// </summary>
  290. void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list);
  291. /// <summary>
  292. /// Writes a packed repeated enumeration of type T, including tag and length, to the stream.
  293. /// </summary>
  294. [CLSCompliant(false)]
  295. void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
  296. where T : struct, IComparable, IFormattable, IConvertible;
  297. }
  298. }