DecoderChannel.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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 DecoderChannel.h
  30. * \brief EXI Decoder Channel
  31. *
  32. */
  33. #ifndef DECODER_CHANNEL_H
  34. #define DECODER_CHANNEL_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. #include "EXIOptions.h"
  39. #include "EXITypes.h"
  40. /**
  41. * \brief Decode byte value
  42. *
  43. * \param stream Input Stream
  44. * \param b byte (out)
  45. * \return Error-Code <> 0
  46. *
  47. */
  48. int decode(bitstream_t* stream, uint8_t* b);
  49. /**
  50. * \brief Decode boolean
  51. *
  52. * Decode a single boolean value. The value false is
  53. * represented by 0, and the value true is represented by 1.
  54. *
  55. * \param stream Input Stream
  56. * \param b boolean (out)
  57. * \return Error-Code <> 0
  58. *
  59. */
  60. int decodeBoolean(bitstream_t* stream, int* b);
  61. /**
  62. * \brief Decode n-bit unsigned integer
  63. *
  64. * Decodes and returns an n-bit unsigned integer.
  65. *
  66. * \param stream Input Stream
  67. * \param nbits Number of bits
  68. * \param uint32 Value (out)
  69. * \return Error-Code <> 0
  70. *
  71. */
  72. int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint32_t* uint32);
  73. /**
  74. * \brief Decode unsigned integer
  75. *
  76. * Decode an arbitrary precision non negative integer using
  77. * a sequence of octets. The most significant bit of the last
  78. * octet is set to zero to indicate sequence termination.
  79. * Only seven bits per octet are used to store the integer's value.
  80. *
  81. * \param stream Input Stream
  82. * \param iv Unsigned Integer Value (out)
  83. * \return Error-Code <> 0
  84. *
  85. */
  86. int decodeUnsignedInteger(bitstream_t* stream, exi_integer_t* iv);
  87. /**
  88. * \brief Decode unsigned integer
  89. *
  90. * Decode an arbitrary precision non negative integer using
  91. * a sequence of octets. The most significant bit of the last
  92. * octet is set to zero to indicate sequence termination.
  93. * Only seven bits per octet are used to store the integer's value.
  94. *
  95. * \param stream Input Stream
  96. * \param uint16 Unsigned Integer Value 16 bits (out)
  97. * \return Error-Code <> 0
  98. *
  99. */
  100. int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16);
  101. /**
  102. * \brief Decode unsigned integer
  103. *
  104. * Decode an arbitrary precision non negative integer using
  105. * a sequence of octets. The most significant bit of the last
  106. * octet is set to zero to indicate sequence termination.
  107. * Only seven bits per octet are used to store the integer's value.
  108. *
  109. * \param stream Input Stream
  110. * \param uint32 Unsigned Integer Value 32 bits (out)
  111. * \return Error-Code <> 0
  112. *
  113. */
  114. int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32);
  115. /**
  116. * \brief Decode unsigned integer
  117. *
  118. * Decode an arbitrary precision non negative integer using
  119. * a sequence of octets. The most significant bit of the last
  120. * octet is set to zero to indicate sequence termination.
  121. * Only seven bits per octet are used to store the integer's value.
  122. *
  123. * \param stream Input Stream
  124. * \param sizeT Unsigned Integer Value (out)
  125. * \return Error-Code <> 0
  126. *
  127. */
  128. int decodeUnsignedIntegerSizeT(bitstream_t* stream, size_t* sizeT);
  129. /**
  130. * \brief Decode unsigned integer
  131. *
  132. * Decode an arbitrary precision non negative integer using
  133. * a sequence of octets. The most significant bit of the last
  134. * octet is set to zero to indicate sequence termination.
  135. * Only seven bits per octet are used to store the integer's value.
  136. *
  137. * \param stream Input Stream
  138. * \param uint64 Unsigned Integer Value 64 bits (out)
  139. * \return Error-Code <> 0
  140. *
  141. */
  142. int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64);
  143. /**
  144. * \brief Decode unsigned integer
  145. *
  146. * Decode an arbitrary precision non negative integer using
  147. * a sequence of octets. The most significant bit of the last
  148. * octet is set to zero to indicate sequence termination.
  149. * Only seven bits per octet are used to store the integer's value.
  150. *
  151. * \param stream Input Stream
  152. * \param size size array
  153. * \param data data array
  154. * \param len length array
  155. * \return Error-Code <> 0
  156. *
  157. */
  158. int decodeUnsignedIntegerBig(bitstream_t* stream, size_t size, uint8_t* data, size_t* len);
  159. /**
  160. * \brief Decode integer
  161. *
  162. * Decode an arbitrary precision integer using a sign bit
  163. * followed by a sequence of octets. The most significant bit
  164. * of the last octet is set to zero to indicate sequence termination.
  165. * Only seven bits per octet are used to store the integer's value.
  166. *
  167. * \param stream Input Stream
  168. * \param iv Integer Value 64 bits (out)
  169. * \return Error-Code <> 0
  170. *
  171. */
  172. int decodeInteger(bitstream_t* stream, exi_integer_t* iv);
  173. /**
  174. * \brief Decode integer
  175. *
  176. * Decode an arbitrary precision integer using a sign bit
  177. * followed by a sequence of octets. The most significant bit
  178. * of the last octet is set to zero to indicate sequence termination.
  179. * Only seven bits per octet are used to store the integer's value.
  180. *
  181. * \param stream Input Stream
  182. * \param int16 Integer Value 16 bits (out)
  183. * \return Error-Code <> 0
  184. *
  185. */
  186. int decodeInteger16(bitstream_t* stream, int16_t* int16);
  187. /**
  188. * \brief Decode integer
  189. *
  190. * Decode an arbitrary precision integer using a sign bit
  191. * followed by a sequence of octets. The most significant bit
  192. * of the last octet is set to zero to indicate sequence termination.
  193. * Only seven bits per octet are used to store the integer's value.
  194. *
  195. * \param stream Input Stream
  196. * \param int32 Integer Value 32 bits (out)
  197. * \return Error-Code <> 0
  198. *
  199. */
  200. int decodeInteger32(bitstream_t* stream, int32_t* int32);
  201. /**
  202. * \brief Decode integer
  203. *
  204. * Decode an arbitrary precision integer using a sign bit
  205. * followed by a sequence of octets. The most significant bit
  206. * of the last octet is set to zero to indicate sequence termination.
  207. * Only seven bits per octet are used to store the integer's value.
  208. *
  209. * \param stream Input Stream
  210. * \param int64 Integer Value 64 bits (out)
  211. * \return Error-Code <> 0
  212. *
  213. */
  214. int decodeInteger64(bitstream_t* stream, int64_t* int64);
  215. /**
  216. * \brief Decode integer
  217. *
  218. * Decode an arbitrary precision integer using a sign bit
  219. * followed by a sequence of octets. The most significant bit
  220. * of the last octet is set to zero to indicate sequence termination.
  221. * Only seven bits per octet are used to store the integer's value.
  222. *
  223. * \param stream Input Stream
  224. * \param negative negative integer
  225. * \param size size array
  226. * \param data data array
  227. * \param len length array
  228. * \return Error-Code <> 0
  229. *
  230. */
  231. int decodeIntegerBig(bitstream_t* stream, int* negative, size_t size, uint8_t* data, size_t* len);
  232. /**
  233. * \brief Decode float
  234. *
  235. * Decode a Float datatype as two consecutive Integers. The
  236. * first Integer represents the mantissa of the floating point
  237. * number and the second Integer represents the base-10 exponent
  238. * of the floating point number.
  239. *
  240. * \param stream Input Stream
  241. * \param f Float Value (out)
  242. * \return Error-Code <> 0
  243. *
  244. */
  245. int decodeFloat(bitstream_t* stream, exi_float_me_t* f);
  246. /**
  247. * \brief Decode decimal
  248. *
  249. * Decode a decimal represented as a Boolean sign followed by two
  250. * Unsigned Integers. A sign value of zero (0) is used to represent
  251. * positive Decimal values and a sign value of one (1) is used to
  252. * represent negative Decimal values The first Integer represents
  253. * the integral portion of the Decimal value. The second positive
  254. * integer represents the fractional portion of the decimal with
  255. * the digits in reverse order to preserve leading zeros.
  256. *
  257. * \param stream Input Stream
  258. * \param d Decimal Value (out)
  259. * \return Error-Code <> 0
  260. *
  261. */
  262. int decodeDecimal(bitstream_t* stream, exi_decimal_t* d);
  263. /**
  264. * \brief Decode String (no length prefix)
  265. *
  266. * Decode a sequence of characters for a given length.
  267. *
  268. * \param stream Input Stream
  269. * \param len Characters length
  270. * \param s String Value (out)
  271. * \return Error-Code <> 0
  272. *
  273. */
  274. int decodeStringOnly(bitstream_t* stream, size_t len, exi_string_t* s);
  275. /**
  276. * \brief Decode String
  277. *
  278. * Decode a length prefixed sequence of characters.
  279. *
  280. * \param stream Input Stream
  281. * \param s String Value (out)
  282. * \return Error-Code <> 0
  283. *
  284. */
  285. int decodeString(bitstream_t* stream, exi_string_t* s);
  286. /**
  287. * \brief Decode String value
  288. *
  289. * Decode a length prefixed sequence of characters in the sense of string tables.
  290. * length == 0: local value partition hit.
  291. * length == 1: global value partition hit.
  292. * length > 1: string literal is encoded as a String with the length incremented by two
  293. *
  294. * \param stream Input Stream
  295. * \param stringTable String Table
  296. * \param qnameID Qualified Name ID
  297. * \param namespaceUriID Qualified Namespace ID
  298. * \param localNameID Qualified LocalName ID
  299. * \param s String Value (out)
  300. * \return Error-Code <> 0
  301. *
  302. */
  303. int decodeStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, size_t namespaceUriID, size_t localNameID, exi_string_value_t* s);
  304. /**
  305. * \brief Decode Restricted characters set string value
  306. *
  307. * \param stream Input Stream
  308. * \param stringTable StringTable
  309. * \param namespaceUriID qualified namespace ID
  310. * \param localNameID qualified localName ID
  311. * \param rcs Restricted character set
  312. * \param s String Value (out)
  313. * \return Error-Code <> 0
  314. *
  315. */
  316. int decodeRCSStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, size_t namespaceUriID, size_t localNameID, exi_rcs_t* rcs, exi_string_value_t* s);
  317. /**
  318. * \brief Decode characters
  319. *
  320. * Decode a sequence of characters according to a given length.
  321. *
  322. * \param stream Input Stream
  323. * \param len Length
  324. * \param chars Characters (out)
  325. * \param charsSize Size of possible characters
  326. * \return Error-Code <> 0
  327. *
  328. */
  329. int decodeCharacters(bitstream_t* stream, size_t len, exi_string_character_t* chars, size_t charsSize);
  330. /**
  331. * \brief Decode restricted character set characters
  332. *
  333. * Decode a sequence of characters according to a given length and rcs code-length, size and set.
  334. *
  335. * \param stream Input Stream
  336. * \param len Length
  337. * \param chars Characters (out)
  338. * \param charsSize Size of possible characters
  339. * \param rcsCodeLength RCS code-length
  340. * \param rcsCodeLength RCS size
  341. * \param rcsCodeLength RCS set
  342. * \return Error-Code <> 0
  343. *
  344. */
  345. int decodeRCSCharacters(bitstream_t* stream, size_t len, exi_string_character_t* chars, size_t charsSize, size_t rcsCodeLength, size_t rcsSize, const exi_string_character_t rcsSet[]);
  346. /**
  347. * \brief Decode Binary
  348. *
  349. * Decode a binary value as a length-prefixed sequence of octets.
  350. *
  351. * \param stream Input Stream
  352. * \param bytes Bytes (out)
  353. * \return Error-Code <> 0
  354. *
  355. */
  356. int decodeBinary(bitstream_t* stream, exi_bytes_t* bytes);
  357. /**
  358. * \brief Decode Binary data
  359. *
  360. * Decode a sequence of octets.
  361. *
  362. * \param stream Input Stream
  363. * \param len Length
  364. * \param data Bytes (out)
  365. * \return Error-Code <> 0
  366. *
  367. */
  368. int decodeBytes(bitstream_t* stream, size_t len, uint8_t* data);
  369. /**
  370. * \brief Decode DateTime
  371. *
  372. * Decode Date-Time as sequence of values representing the
  373. * individual components of the Date-Time.
  374. *
  375. * \param stream Input Stream
  376. * \param type Datetime type
  377. * \param datetime Datetime (out)
  378. * \return Error-Code <> 0
  379. *
  380. */
  381. int decodeDateTime(bitstream_t* stream, exi_datetime_type_t type, exi_datetime_t* datetime);
  382. #ifdef __cplusplus
  383. }
  384. #endif
  385. #endif