PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/ProtocolBuffers/ICodedOutputStream.cs

https://code.google.com/p/protobuf-csharp-port/
C# | 374 lines | 86 code | 58 blank | 230 comment | 0 complexity | 10786808ce236132e7086dd744b93030 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, GPL-2.0
  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
  48. {
  49. /// <summary>
  50. /// Writes any message initialization data needed to the output stream
  51. /// </summary>
  52. /// <remarks>
  53. /// This is primarily used by text formats and unnecessary for protobuffers' own
  54. /// binary format. The API for MessageStart/End was added for consistent handling
  55. /// of output streams regardless of the actual writer implementation.
  56. /// </remarks>
  57. void WriteMessageStart();
  58. /// <summary>
  59. /// Writes any message finalization data needed to the output stream
  60. /// </summary>
  61. /// <remarks>
  62. /// This is primarily used by text formats and unnecessary for protobuffers' own
  63. /// binary format. The API for MessageStart/End was added for consistent handling
  64. /// of output streams regardless of the actual writer implementation.
  65. /// </remarks>
  66. void WriteMessageEnd();
  67. /// <summary>
  68. /// Indicates that all temporary buffers be written to the final output.
  69. /// </summary>
  70. void Flush();
  71. /// <summary>
  72. /// Writes an unknown message as a group
  73. /// </summary>
  74. [Obsolete]
  75. void WriteUnknownGroup(int fieldNumber, IMessageLite value);
  76. /// <summary>
  77. /// Writes an unknown field value of bytes
  78. /// </summary>
  79. void WriteUnknownBytes(int fieldNumber, ByteString value);
  80. /// <summary>
  81. /// Writes an unknown field of a primitive type
  82. /// </summary>
  83. [CLSCompliant(false)]
  84. void WriteUnknownField(int fieldNumber, WireFormat.WireType wireType, ulong value);
  85. /// <summary>
  86. /// Writes an extension as a message-set group
  87. /// </summary>
  88. void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value);
  89. /// <summary>
  90. /// Writes an unknown extension as a message-set group
  91. /// </summary>
  92. void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value);
  93. /// <summary>
  94. /// Writes a field value, including tag, to the stream.
  95. /// </summary>
  96. void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value);
  97. /// <summary>
  98. /// Writes a double field value, including tag, to the stream.
  99. /// </summary>
  100. void WriteDouble(int fieldNumber, string fieldName, double value);
  101. /// <summary>
  102. /// Writes a float field value, including tag, to the stream.
  103. /// </summary>
  104. void WriteFloat(int fieldNumber, string fieldName, float value);
  105. /// <summary>
  106. /// Writes a uint64 field value, including tag, to the stream.
  107. /// </summary>
  108. [CLSCompliant(false)]
  109. void WriteUInt64(int fieldNumber, string fieldName, ulong value);
  110. /// <summary>
  111. /// Writes an int64 field value, including tag, to the stream.
  112. /// </summary>
  113. void WriteInt64(int fieldNumber, string fieldName, long value);
  114. /// <summary>
  115. /// Writes an int32 field value, including tag, to the stream.
  116. /// </summary>
  117. void WriteInt32(int fieldNumber, string fieldName, int value);
  118. /// <summary>
  119. /// Writes a fixed64 field value, including tag, to the stream.
  120. /// </summary>
  121. [CLSCompliant(false)]
  122. void WriteFixed64(int fieldNumber, string fieldName, ulong value);
  123. /// <summary>
  124. /// Writes a fixed32 field value, including tag, to the stream.
  125. /// </summary>
  126. [CLSCompliant(false)]
  127. void WriteFixed32(int fieldNumber, string fieldName, uint value);
  128. /// <summary>
  129. /// Writes a bool field value, including tag, to the stream.
  130. /// </summary>
  131. void WriteBool(int fieldNumber, string fieldName, bool value);
  132. /// <summary>
  133. /// Writes a string field value, including tag, to the stream.
  134. /// </summary>
  135. void WriteString(int fieldNumber, string fieldName, string value);
  136. /// <summary>
  137. /// Writes a group field value, including tag, to the stream.
  138. /// </summary>
  139. void WriteGroup(int fieldNumber, string fieldName, IMessageLite value);
  140. /// <summary>
  141. /// Writes a message field value, including tag, to the stream.
  142. /// </summary>
  143. void WriteMessage(int fieldNumber, string fieldName, IMessageLite value);
  144. /// <summary>
  145. /// Writes a byte array field value, including tag, to the stream.
  146. /// </summary>
  147. void WriteBytes(int fieldNumber, string fieldName, ByteString value);
  148. /// <summary>
  149. /// Writes a UInt32 field value, including tag, to the stream.
  150. /// </summary>
  151. [CLSCompliant(false)]
  152. void WriteUInt32(int fieldNumber, string fieldName, uint value);
  153. /// <summary>
  154. /// Writes an enum field value, including tag, to the stream.
  155. /// </summary>
  156. void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
  157. /// <summary>
  158. /// Writes a fixed 32-bit field value, including tag, to the stream.
  159. /// </summary>
  160. void WriteSFixed32(int fieldNumber, string fieldName, int value);
  161. /// <summary>
  162. /// Writes a signed fixed 64-bit field value, including tag, to the stream.
  163. /// </summary>
  164. void WriteSFixed64(int fieldNumber, string fieldName, long value);
  165. /// <summary>
  166. /// Writes a signed 32-bit field value, including tag, to the stream.
  167. /// </summary>
  168. void WriteSInt32(int fieldNumber, string fieldName, int value);
  169. /// <summary>
  170. /// Writes a signed 64-bit field value, including tag, to the stream.
  171. /// </summary>
  172. void WriteSInt64(int fieldNumber, string fieldName, long value);
  173. /// <summary>
  174. /// Writes a repeated field value, including tag(s), to the stream.
  175. /// </summary>
  176. void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
  177. /// <summary>
  178. /// Writes a repeated group value, including tag(s), to the stream.
  179. /// </summary>
  180. void WriteGroupArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
  181. where T : IMessageLite;
  182. /// <summary>
  183. /// Writes a repeated message value, including tag(s), to the stream.
  184. /// </summary>
  185. void WriteMessageArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
  186. where T : IMessageLite;
  187. /// <summary>
  188. /// Writes a repeated string value, including tag(s), to the stream.
  189. /// </summary>
  190. void WriteStringArray(int fieldNumber, string fieldName, IEnumerable<string> list);
  191. /// <summary>
  192. /// Writes a repeated ByteString value, including tag(s), to the stream.
  193. /// </summary>
  194. void WriteBytesArray(int fieldNumber, string fieldName, IEnumerable<ByteString> list);
  195. /// <summary>
  196. /// Writes a repeated boolean value, including tag(s), to the stream.
  197. /// </summary>
  198. void WriteBoolArray(int fieldNumber, string fieldName, IEnumerable<bool> list);
  199. /// <summary>
  200. /// Writes a repeated Int32 value, including tag(s), to the stream.
  201. /// </summary>
  202. void WriteInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
  203. /// <summary>
  204. /// Writes a repeated SInt32 value, including tag(s), to the stream.
  205. /// </summary>
  206. void WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
  207. /// <summary>
  208. /// Writes a repeated UInt32 value, including tag(s), to the stream.
  209. /// </summary>
  210. void WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
  211. /// <summary>
  212. /// Writes a repeated Fixed32 value, including tag(s), to the stream.
  213. /// </summary>
  214. void WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable<uint> list);
  215. /// <summary>
  216. /// Writes a repeated SFixed32 value, including tag(s), to the stream.
  217. /// </summary>
  218. void WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable<int> list);
  219. /// <summary>
  220. /// Writes a repeated Int64 value, including tag(s), to the stream.
  221. /// </summary>
  222. void WriteInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
  223. /// <summary>
  224. /// Writes a repeated SInt64 value, including tag(s), to the stream.
  225. /// </summary>
  226. void WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
  227. /// <summary>
  228. /// Writes a repeated UInt64 value, including tag(s), to the stream.
  229. /// </summary>
  230. void WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
  231. /// <summary>
  232. /// Writes a repeated Fixed64 value, including tag(s), to the stream.
  233. /// </summary>
  234. void WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable<ulong> list);
  235. /// <summary>
  236. /// Writes a repeated SFixed64 value, including tag(s), to the stream.
  237. /// </summary>
  238. void WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable<long> list);
  239. /// <summary>
  240. /// Writes a repeated Double value, including tag(s), to the stream.
  241. /// </summary>
  242. void WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable<double> list);
  243. /// <summary>
  244. /// Writes a repeated Float value, including tag(s), to the stream.
  245. /// </summary>
  246. void WriteFloatArray(int fieldNumber, string fieldName, IEnumerable<float> list);
  247. /// <summary>
  248. /// Writes a repeated enumeration value of type T, including tag(s), to the stream.
  249. /// </summary>
  250. [CLSCompliant(false)]
  251. void WriteEnumArray<T>(int fieldNumber, string fieldName, IEnumerable<T> list)
  252. where T : struct, IComparable, IFormattable, IConvertible;
  253. /// <summary>
  254. /// Writes a packed repeated primitive, including tag and length, to the stream.
  255. /// </summary>
  256. void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list);
  257. /// <summary>
  258. /// Writes a packed repeated boolean, including tag and length, to the stream.
  259. /// </summary>
  260. void WritePackedBoolArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<bool> list);
  261. /// <summary>
  262. /// Writes a packed repeated Int32, including tag and length, to the stream.
  263. /// </summary>
  264. void WritePackedInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
  265. /// <summary>
  266. /// Writes a packed repeated SInt32, including tag and length, to the stream.
  267. /// </summary>
  268. void WritePackedSInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
  269. /// <summary>
  270. /// Writes a packed repeated UInt32, including tag and length, to the stream.
  271. /// </summary>
  272. void WritePackedUInt32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
  273. /// <summary>
  274. /// Writes a packed repeated Fixed32, including tag and length, to the stream.
  275. /// </summary>
  276. void WritePackedFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<uint> list);
  277. /// <summary>
  278. /// Writes a packed repeated SFixed32, including tag and length, to the stream.
  279. /// </summary>
  280. void WritePackedSFixed32Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<int> list);
  281. /// <summary>
  282. /// Writes a packed repeated Int64, including tag and length, to the stream.
  283. /// </summary>
  284. void WritePackedInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
  285. /// <summary>
  286. /// Writes a packed repeated SInt64, including tag and length, to the stream.
  287. /// </summary>
  288. void WritePackedSInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
  289. /// <summary>
  290. /// Writes a packed repeated UInt64, including tag and length, to the stream.
  291. /// </summary>
  292. void WritePackedUInt64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
  293. /// <summary>
  294. /// Writes a packed repeated Fixed64, including tag and length, to the stream.
  295. /// </summary>
  296. void WritePackedFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<ulong> list);
  297. /// <summary>
  298. /// Writes a packed repeated SFixed64, including tag and length, to the stream.
  299. /// </summary>
  300. void WritePackedSFixed64Array(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<long> list);
  301. /// <summary>
  302. /// Writes a packed repeated Double, including tag and length, to the stream.
  303. /// </summary>
  304. void WritePackedDoubleArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<double> list);
  305. /// <summary>
  306. /// Writes a packed repeated Float, including tag and length, to the stream.
  307. /// </summary>
  308. void WritePackedFloatArray(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<float> list);
  309. /// <summary>
  310. /// Writes a packed repeated enumeration of type T, including tag and length, to the stream.
  311. /// </summary>
  312. [CLSCompliant(false)]
  313. void WritePackedEnumArray<T>(int fieldNumber, string fieldName, int calculatedSize, IEnumerable<T> list)
  314. where T : struct, IComparable, IFormattable, IConvertible;
  315. }
  316. }