EncoderChannel.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. /*
  2. * Copyright (C) 2007-2018 Siemens AG
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published
  6. * by the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*******************************************************************
  18. *
  19. * @author Daniel.Peintner.EXT@siemens.com
  20. * @version 2017-03-02
  21. * @contact Richard.Kuntschke@siemens.com
  22. *
  23. * <p>Code generated by EXIdizer</p>
  24. * <p>Schema: V2G_CI_MsgDef.xsd</p>
  25. *
  26. *
  27. ********************************************************************/
  28. /**
  29. * \file EncoderChannel.h
  30. * \brief EXI Encoder Channel
  31. *
  32. */
  33. #ifndef ENCODER_CHANNEL_H
  34. #define ENCODER_CHANNEL_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. #include "EXITypes.h"
  39. /**
  40. * \brief Encode byte value
  41. *
  42. * \param stream Output Stream
  43. * \param b byte
  44. * \return Error-Code <> 0
  45. *
  46. */
  47. int encode(bitstream_t* stream, uint8_t b);
  48. /**
  49. * \brief Encode a single boolean value
  50. *
  51. * A false value is encoded as 0 and true value is encode as 1.
  52. *
  53. * \param stream Output Stream
  54. * \param b boolean
  55. * \return Error-Code <> 0
  56. *
  57. */
  58. int encodeBoolean(bitstream_t* stream, int b);
  59. /**
  60. * \brief Encode n-bit unsigned integer
  61. *
  62. * The n least significant bits of parameter b starting with the
  63. * most significant, i.e. from left to right.
  64. *
  65. * \param stream Output Stream
  66. * \param nbits number of bits
  67. * \param val value
  68. * \return Error-Code <> 0
  69. *
  70. */
  71. int encodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint32_t val);
  72. /**
  73. * \brief Encode unsigned integer
  74. *
  75. * Encode an arbitrary precision non negative integer using
  76. * a sequence of octets. The most significant bit of the last
  77. * octet is set to zero to indicate sequence termination.
  78. * Only seven bits per octet are used to store the integer's value.
  79. *
  80. * \param stream Output Stream
  81. * \param iv Unsigned integer value
  82. * \return Error-Code <> 0
  83. *
  84. */
  85. int encodeUnsignedInteger(bitstream_t* stream, exi_integer_t* iv);
  86. /**
  87. * \brief Encode unsigned integer
  88. *
  89. * Encode an arbitrary precision non negative integer using
  90. * a sequence of octets. The most significant bit of the last
  91. * octet is set to zero to indicate sequence termination.
  92. * Only seven bits per octet are used to store the integer's value.
  93. *
  94. * \param stream Output Stream
  95. * \param n Unsigned integer value 16 bits
  96. * \return Error-Code <> 0
  97. *
  98. */
  99. int encodeUnsignedInteger16(bitstream_t* stream, uint16_t n);
  100. /**
  101. * \brief Encode unsigned integer
  102. *
  103. * Encode an arbitrary precision non negative integer using
  104. * a sequence of octets. The most significant bit of the last
  105. * octet is set to zero to indicate sequence termination.
  106. * Only seven bits per octet are used to store the integer's value.
  107. *
  108. * \param stream Output Stream
  109. * \param n Unsigned integer value 32 bits
  110. * \return Error-Code <> 0
  111. *
  112. */
  113. int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n);
  114. /**
  115. * \brief Encode unsigned integer
  116. *
  117. * Encode an arbitrary precision non negative integer using
  118. * a sequence of octets. The most significant bit of the last
  119. * octet is set to zero to indicate sequence termination.
  120. * Only seven bits per octet are used to store the integer's value.
  121. *
  122. * \param stream Output Stream
  123. * \param n Unsigned integer value 64 bits
  124. * \return Error-Code <> 0
  125. *
  126. */
  127. int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n);
  128. /**
  129. * \brief Encode unsigned integer
  130. *
  131. * Encode an arbitrary precision non negative integer using
  132. * a sequence of octets. The most significant bit of the last
  133. * octet is set to zero to indicate sequence termination.
  134. * Only seven bits per octet are used to store the integer's value.
  135. *
  136. * \param stream Output Stream
  137. * \param size size array
  138. * \param data data array
  139. * \param len length array
  140. * \return Error-Code <> 0
  141. *
  142. */
  143. int encodeUnsignedIntegerBig(bitstream_t* stream, size_t size, uint8_t* data, size_t len);
  144. /**
  145. * \brief Encode integer
  146. *
  147. * Encode an arbitrary precision integer using a sign boolean
  148. * followed by a sequence of octets. The most significant bit
  149. * of the last octet is set to zero to indicate sequence termination.
  150. * Only seven bits per octet are used to store the integer's value.
  151. *
  152. * \param stream Output Stream
  153. * \param iv Integer value
  154. * \return Error-Code <> 0
  155. *
  156. */
  157. int encodeInteger(bitstream_t* stream, exi_integer_t* iv);
  158. /**
  159. * \brief Encode integer
  160. *
  161. * Encode an arbitrary precision integer using a sign boolean
  162. * followed by a sequence of octets. The most significant bit
  163. * of the last octet is set to zero to indicate sequence termination.
  164. * Only seven bits per octet are used to store the integer's value.
  165. *
  166. * \param stream Output Stream
  167. * \param n Integer value 16 bits
  168. * \return Error-Code <> 0
  169. *
  170. */
  171. int encodeInteger16(bitstream_t* stream, int16_t n);
  172. /**
  173. * \brief Encode integer
  174. *
  175. * Encode an arbitrary precision integer using a sign boolean
  176. * followed by a sequence of octets. The most significant bit
  177. * of the last octet is set to zero to indicate sequence termination.
  178. * Only seven bits per octet are used to store the integer's value.
  179. *
  180. * \param stream Output Stream
  181. * \param n Integer value 32 bits
  182. * \return Error-Code <> 0
  183. *
  184. */
  185. int encodeInteger32(bitstream_t* stream, int32_t n);
  186. /**
  187. * \brief Encode integer
  188. *
  189. * Encode an arbitrary precision integer using a sign boolean
  190. * followed by a sequence of octets. The most significant bit
  191. * of the last octet is set to zero to indicate sequence termination.
  192. * Only seven bits per octet are used to store the integer's value.
  193. *
  194. * \param stream Output Stream
  195. * \param n Integer value 64 bits
  196. * \return Error-Code <> 0
  197. *
  198. */
  199. int encodeInteger64(bitstream_t* stream, int64_t n);
  200. /**
  201. * \brief Encode integer
  202. *
  203. * Encode an arbitrary precision integer using a sign boolean
  204. * followed by a sequence of octets. The most significant bit
  205. * of the last octet is set to zero to indicate sequence termination.
  206. * Only seven bits per octet are used to store the integer's value.
  207. *
  208. * \param stream Output Stream
  209. * \param negative negative integer
  210. * \param size size array
  211. * \param data data array
  212. * \param len length array
  213. * \return Error-Code <> 0
  214. *
  215. */
  216. int encodeIntegerBig(bitstream_t* stream, int negative, size_t size, uint8_t* data, size_t len);
  217. /**
  218. * \brief Encode float
  219. *
  220. * Encode a Float datatype as two consecutive Integers. The first
  221. * Integer represents the mantissa of the floating point number
  222. * and the second Integer represents the base-10 exponent of the
  223. * floating point number.
  224. *
  225. * \param stream Output Stream
  226. * \param f Float value
  227. * \return Error-Code <> 0
  228. *
  229. */
  230. int encodeFloat(bitstream_t* stream, exi_float_me_t* f);
  231. /**
  232. * \brief Encode decimal
  233. *
  234. * Encode a decimal represented as a Boolean sign followed by two
  235. * Unsigned Integers. A sign value of zero (0) is used to represent
  236. * positive Decimal values and a sign value of one (1) is used to
  237. * represent negative Decimal values The first Integer represents
  238. * the integral portion of the Decimal value. The second positive
  239. * integer represents the fractional portion of the decimal with
  240. * the digits in reverse order to preserve leading zeros.
  241. *
  242. * \param stream Output Stream
  243. * \param d Decimal value
  244. * \return Error-Code <> 0
  245. *
  246. */
  247. int encodeDecimal(bitstream_t* stream, exi_decimal_t* d);
  248. /**
  249. * \brief Encode string
  250. *
  251. * Encode a length prefixed sequence of characters.
  252. *
  253. * \param stream Output Stream
  254. * \param string String
  255. * \return Error-Code <> 0
  256. *
  257. */
  258. int encodeString(bitstream_t* stream, exi_string_t* string);
  259. /**
  260. * \brief Encode string value
  261. *
  262. * Encode a length prefixed sequence of characters
  263. * in the sense of string tables
  264. *
  265. * \param stream Output Stream
  266. * \param stringTable String Table
  267. * \param namespaceUriID Qualified Namespace ID
  268. * \param localNameID Qualified LocalName ID
  269. * \param string String value
  270. * \return Error-Code <> 0
  271. *
  272. */
  273. int encodeStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, size_t namespaceUriID, size_t localNameID,
  274. exi_string_value_t* string);
  275. /**
  276. * \brief Encode restricted character set value
  277. *
  278. * Encode a length prefixed sequence of characters
  279. * in the sense of string tables
  280. *
  281. * \param stream Output Stream
  282. * \param StringTable StringTable
  283. * \param namespaceUriID Qualified Namespace ID
  284. * \param localNameID Qualified LocalName ID
  285. * \param rcs Restricted character set
  286. * \param string String value
  287. * \return Error-Code <> 0
  288. *
  289. */
  290. int encodeRCSStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable,
  291. size_t namespaceUriID, size_t localNameID, exi_rcs_t* rcs, exi_string_value_t* string);
  292. /**
  293. * \brief Encode characters
  294. *
  295. * Encode a sequence of characters according to a given length.
  296. * Each character is represented by its UCS [ISO/IEC 10646]
  297. * code point encoded as an Unsigned Integer.
  298. *
  299. * \param stream Output Stream
  300. * \param chars Characters
  301. * \param len Numbr of characters
  302. * \return Error-Code <> 0
  303. *
  304. */
  305. int encodeCharacters(bitstream_t* stream, exi_string_character_t* chars, size_t len);
  306. /**
  307. * \brief Encode characters
  308. *
  309. * Encode a sequence of characters according to a given length.
  310. * Each character is represented by its UCS [ISO/IEC 10646]
  311. * code point encoded as an Unsigned Integer.
  312. *
  313. * \param stream Output Stream
  314. * \param chars Characters
  315. * \param len Numbr of characters
  316. * \param rcsCodeLength RCS code-length
  317. * \param rcsCodeLength RCS size
  318. * \param rcsCodeLength RCS set
  319. * \return Error-Code <> 0
  320. *
  321. */
  322. int encodeRCSCharacters(bitstream_t* stream, exi_string_character_t* chars, size_t len, size_t rcsCodeLength, size_t rcsSize, const exi_string_character_t rcsSet[]);
  323. /**
  324. * \brief Encode binary
  325. *
  326. * Encode a binary value as a length-prefixed sequence of octets.
  327. *
  328. * \param stream Output Stream
  329. * \param bytes Byte values
  330. * \return Error-Code <> 0
  331. *
  332. */
  333. int encodeBinary(bitstream_t* stream, exi_bytes_t* bytes);
  334. /**
  335. * \brief Encode binary data
  336. *
  337. * Encode a sequence of octets.
  338. *
  339. * \param stream Output Stream
  340. * \param data Byte values
  341. * \param len Length
  342. * \return Error-Code <> 0
  343. *
  344. */
  345. int encodeBytes(bitstream_t* stream, uint8_t* data, size_t len);
  346. /**
  347. * \brief Encode datetime
  348. *
  349. * Encode a datetime representation which is a sequence of values
  350. * representing the individual components of the Date-Time.
  351. *
  352. * \param stream Output Stream
  353. * \param datetime Datetime values
  354. * \return Error-Code <> 0
  355. *
  356. */
  357. int encodeDateTime(bitstream_t* stream, exi_datetime_t* datetime);
  358. /**
  359. * \brief Flush underlying bit output stream
  360. *
  361. * \param stream Output Stream
  362. * \return Error-Code <> 0
  363. *
  364. */
  365. int encodeFinish(bitstream_t* stream);
  366. #ifdef __cplusplus
  367. }
  368. #endif
  369. #endif