EncoderChannel.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /*
  2. * Copyright (C) 2007-2014 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 0.9.2
  21. * @contact Joerg.Heuer@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, uint16_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 integer
  130. *
  131. * Encode an arbitrary precision integer using a sign boolean
  132. * followed by a sequence of octets. The most significant bit
  133. * of the last 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 iv Integer value
  138. * \return Error-Code <> 0
  139. *
  140. */
  141. int encodeInteger(bitstream_t* stream, exi_integer_t* iv);
  142. /**
  143. * \brief Encode integer
  144. *
  145. * Encode an arbitrary precision integer using a sign boolean
  146. * followed by a sequence of octets. The most significant bit
  147. * of the last octet is set to zero to indicate sequence termination.
  148. * Only seven bits per octet are used to store the integer's value.
  149. *
  150. * \param stream Output Stream
  151. * \param n Integer value 16 bits
  152. * \return Error-Code <> 0
  153. *
  154. */
  155. int encodeInteger16(bitstream_t* stream, int16_t n);
  156. /**
  157. * \brief Encode integer
  158. *
  159. * Encode an arbitrary precision integer using a sign boolean
  160. * followed by a sequence of octets. The most significant bit
  161. * of the last octet is set to zero to indicate sequence termination.
  162. * Only seven bits per octet are used to store the integer's value.
  163. *
  164. * \param stream Output Stream
  165. * \param n Integer value 32 bits
  166. * \return Error-Code <> 0
  167. *
  168. */
  169. int encodeInteger32(bitstream_t* stream, int32_t n);
  170. /**
  171. * \brief Encode integer
  172. *
  173. * Encode an arbitrary precision integer using a sign boolean
  174. * followed by a sequence of octets. The most significant bit
  175. * of the last octet is set to zero to indicate sequence termination.
  176. * Only seven bits per octet are used to store the integer's value.
  177. *
  178. * \param stream Output Stream
  179. * \param n Integer value 64 bits
  180. * \return Error-Code <> 0
  181. *
  182. */
  183. int encodeInteger64(bitstream_t* stream, int64_t n);
  184. /**
  185. * \brief Encode float
  186. *
  187. * Encode a Float datatype as two consecutive Integers. The first
  188. * Integer represents the mantissa of the floating point number
  189. * and the second Integer represents the base-10 exponent of the
  190. * floating point number.
  191. *
  192. * \param stream Output Stream
  193. * \param f Float value
  194. * \return Error-Code <> 0
  195. *
  196. */
  197. int encodeFloat(bitstream_t* stream, exi_float_me_t* f);
  198. /**
  199. * \brief Encode decimal
  200. *
  201. * Encode a decimal represented as a Boolean sign followed by two
  202. * Unsigned Integers. A sign value of zero (0) is used to represent
  203. * positive Decimal values and a sign value of one (1) is used to
  204. * represent negative Decimal values The first Integer represents
  205. * the integral portion of the Decimal value. The second positive
  206. * integer represents the fractional portion of the decimal with
  207. * the digits in reverse order to preserve leading zeros.
  208. *
  209. * \param stream Output Stream
  210. * \param d Decimal value
  211. * \return Error-Code <> 0
  212. *
  213. */
  214. int encodeDecimal(bitstream_t* stream, exi_decimal_t* d);
  215. /**
  216. * \brief Encode string
  217. *
  218. * Encode a length prefixed sequence of characters.
  219. *
  220. * \param stream Output Stream
  221. * \param string String
  222. * \return Error-Code <> 0
  223. *
  224. */
  225. int encodeString(bitstream_t* stream, exi_string_t* string);
  226. /**
  227. * \brief Encode string value
  228. *
  229. * Encode a length prefixed sequence of characters
  230. * in the sense of string tables
  231. *
  232. * \param stream Output Stream
  233. * \param state Codec state
  234. * \param qnameID Qualified Name ID
  235. * \param string String value
  236. * \return Error-Code <> 0
  237. *
  238. */
  239. int encodeStringValue(bitstream_t* stream, exi_state_t* state, uint16_t qnameID,
  240. exi_string_value_t* string);
  241. /**
  242. * \brief Encode restricted character set value
  243. *
  244. * Encode a length prefixed sequence of characters
  245. * in the sense of string tables
  246. *
  247. * \param stream Output Stream
  248. * \param state Codec state
  249. * \param qnameID Qualified Name ID
  250. * \param rcs Restricted character set
  251. * \param string String value
  252. * \return Error-Code <> 0
  253. *
  254. */
  255. int encodeRCSStringValue(bitstream_t* stream, exi_state_t* state,
  256. uint16_t qnameID, exi_rcs_t* rcs, exi_string_value_t* string);
  257. /**
  258. * \brief Encode characters
  259. *
  260. * Encode a sequence of characters according to a given length.
  261. * Each character is represented by its UCS [ISO/IEC 10646]
  262. * code point encoded as an Unsigned Integer.
  263. *
  264. * \param stream Output Stream
  265. * \param chars Characters
  266. * \param len Numbr of characters
  267. * \return Error-Code <> 0
  268. *
  269. */
  270. int encodeCharacters(bitstream_t* stream, exi_string_character_t* chars, uint16_t len);
  271. /**
  272. * \brief Encode characters
  273. *
  274. * Encode a sequence of characters according to a given length.
  275. * Each character is represented by its UCS [ISO/IEC 10646]
  276. * code point encoded as an Unsigned Integer.
  277. *
  278. * \param stream Output Stream
  279. * \param chars Characters
  280. * \param len Numbr of characters
  281. * \param rcsCodeLength RCS code-length
  282. * \param rcsCodeLength RCS size
  283. * \param rcsCodeLength RCS set
  284. * \return Error-Code <> 0
  285. *
  286. */
  287. int encodeRCSCharacters(bitstream_t* stream, exi_string_character_t* chars, uint16_t len, uint16_t rcsCodeLength, uint16_t rcsSize, const exi_string_character_t rcsSet[]);
  288. /**
  289. * \brief Encode binary
  290. *
  291. * Encode a binary value as a length-prefixed sequence of octets.
  292. *
  293. * \param stream Output Stream
  294. * \param bytes Byte values
  295. * \return Error-Code <> 0
  296. *
  297. */
  298. int encodeBinary(bitstream_t* stream, exi_bytes_t* bytes);
  299. /**
  300. * \brief Encode binary data
  301. *
  302. * Encode a sequence of octets.
  303. *
  304. * \param stream Output Stream
  305. * \param data Byte values
  306. * \param len Length
  307. * \return Error-Code <> 0
  308. *
  309. */
  310. int encodeBytes(bitstream_t* stream, uint8_t* data, uint16_t len);
  311. /**
  312. * \brief Encode datetime
  313. *
  314. * Encode a datetime representation which is a sequence of values
  315. * representing the individual components of the Date-Time.
  316. *
  317. * \param stream Output Stream
  318. * \param datetime Datetime values
  319. * \return Error-Code <> 0
  320. *
  321. */
  322. int encodeDateTime(bitstream_t* stream, exi_datetime_t* datetime);
  323. /**
  324. * \brief Flush underlying bit output stream
  325. *
  326. * \param stream Output Stream
  327. * \return Error-Code <> 0
  328. *
  329. */
  330. int encodeFinish(bitstream_t* stream);
  331. #ifdef __cplusplus
  332. }
  333. #endif
  334. #endif