EncoderChannel.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*
  2. * Copyright (C) 2007-2013 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. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*******************************************************************
  19. *
  20. * @author Daniel.Peintner.EXT@siemens.com
  21. * @version 0.8
  22. * @contact Joerg.Heuer@siemens.com
  23. *
  24. * <p>Code generated by EXIdizer.com</p>
  25. * <p>Schema: input/test_v2g/V2G_CI_MsgDef.xsd</p>
  26. *
  27. *
  28. ********************************************************************/
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include "EXITypes.h"
  33. /**
  34. * \file EncoderChannel.h
  35. * \brief EXI Encoder Channel
  36. *
  37. */
  38. #ifndef ENCODER_CHANNEL_H
  39. #define ENCODER_CHANNEL_H
  40. /**
  41. * \brief Encode byte value
  42. *
  43. * \param stream Output Stream
  44. * \param b byte
  45. * \return Error-Code <> 0
  46. *
  47. */
  48. int encode(bitstream_t* stream, uint8_t b);
  49. /**
  50. * \brief Encode a single boolean value
  51. *
  52. * A false value is encoded as 0 and true value is encode as 1.
  53. *
  54. * \param stream Output Stream
  55. * \param b boolean
  56. * \return Error-Code <> 0
  57. *
  58. */
  59. int encodeBoolean(bitstream_t* stream, int b);
  60. /**
  61. * \brief Encode n-bit unsigned integer
  62. *
  63. * The n least significant bits of parameter b starting with the
  64. * most significant, i.e. from left to right.
  65. *
  66. * \param stream Output Stream
  67. * \param nbits number of bits
  68. * \param val value
  69. * \return Error-Code <> 0
  70. *
  71. */
  72. int encodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t val);
  73. /**
  74. * \brief Encode unsigned integer
  75. *
  76. * Encode 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 Output Stream
  82. * \param iv Unsigned integer value
  83. * \return Error-Code <> 0
  84. *
  85. */
  86. int encodeUnsignedInteger(bitstream_t* stream, exi_integer_t* iv);
  87. /**
  88. * \brief Encode unsigned integer
  89. *
  90. * Encode 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 Output Stream
  96. * \param n Unsigned integer value 32 bits
  97. * \return Error-Code <> 0
  98. *
  99. */
  100. int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n);
  101. /**
  102. * \brief Encode unsigned integer
  103. *
  104. * Encode 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 Output Stream
  110. * \param n Unsigned integer value 64 bits
  111. * \return Error-Code <> 0
  112. *
  113. */
  114. int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n);
  115. /**
  116. * \brief Encode integer
  117. *
  118. * Encode an arbitrary precision integer using a sign boolean
  119. * followed by a sequence of octets. The most significant bit
  120. * of the last 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 Output Stream
  124. * \param iv Integer value
  125. * \return Error-Code <> 0
  126. *
  127. */
  128. int encodeInteger(bitstream_t* stream, exi_integer_t* iv);
  129. /**
  130. * \brief Encode integer
  131. *
  132. * Encode an arbitrary precision integer using a sign boolean
  133. * followed by a sequence of octets. The most significant bit
  134. * of the last 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 Output Stream
  138. * \param n Integer value 32 bits
  139. * \return Error-Code <> 0
  140. *
  141. */
  142. int encodeInteger32(bitstream_t* stream, int32_t n);
  143. /**
  144. * \brief Encode integer
  145. *
  146. * Encode an arbitrary precision integer using a sign boolean
  147. * followed by a sequence of octets. The most significant bit
  148. * of the last 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 Output Stream
  152. * \param n Integer value 64 bits
  153. * \return Error-Code <> 0
  154. *
  155. */
  156. int encodeInteger64(bitstream_t* stream, int64_t n);
  157. /**
  158. * \brief Encode float
  159. *
  160. * Encode a Float datatype as two consecutive Integers. The first
  161. * Integer represents the mantissa of the floating point number
  162. * and the second Integer represents the base-10 exponent of the
  163. * floating point number.
  164. *
  165. * \param stream Output Stream
  166. * \param f Float value
  167. * \return Error-Code <> 0
  168. *
  169. */
  170. int encodeFloat(bitstream_t* stream, exi_float_me_t* f);
  171. /**
  172. * \brief Encode decimal
  173. *
  174. * Encode a decimal represented as a Boolean sign followed by two
  175. * Unsigned Integers. A sign value of zero (0) is used to represent
  176. * positive Decimal values and a sign value of one (1) is used to
  177. * represent negative Decimal values The first Integer represents
  178. * the integral portion of the Decimal value. The second positive
  179. * integer represents the fractional portion of the decimal with
  180. * the digits in reverse order to preserve leading zeros.
  181. *
  182. * \param stream Output Stream
  183. * \param d Decimal value
  184. * \return Error-Code <> 0
  185. *
  186. */
  187. int encodeDecimal(bitstream_t* stream, exi_decimal_t* d);
  188. /**
  189. * \brief Encode string
  190. *
  191. * Encode a length prefixed sequence of characters.
  192. *
  193. * \param stream Output Stream
  194. * \param string String
  195. * \return Error-Code <> 0
  196. *
  197. */
  198. int encodeString(bitstream_t* stream, exi_string_ucs_t* string);
  199. /**
  200. * \brief Encode string value
  201. *
  202. * Encode a length prefixed sequence of characters
  203. * in the sense of string tables
  204. *
  205. * \param stream Output Stream
  206. * \param state Codec state
  207. * \param qnameID Qualified Name ID
  208. * \param string String value
  209. * \return Error-Code <> 0
  210. *
  211. */
  212. int encodeStringValue(bitstream_t* stream, exi_state_t* state, uint16_t qnameID,
  213. exi_string_value_t* string);
  214. /**
  215. * \brief Encode restricted character set value
  216. *
  217. * Encode a length prefixed sequence of characters
  218. * in the sense of string tables
  219. *
  220. * \param stream Output Stream
  221. * \param state Codec state
  222. * \param qnameID Qualified Name ID
  223. * \param rcs Restricted character set
  224. * \param string String value
  225. * \return Error-Code <> 0
  226. *
  227. */
  228. int encodeRCSStringValue(bitstream_t* stream, exi_state_t* state,
  229. uint16_t qnameID, exi_rcs_t* rcs, exi_string_value_t* string);
  230. /**
  231. * \brief Encode characters
  232. *
  233. * Encode a sequence of characters according to a given length.
  234. * Each character is represented by its UCS [ISO/IEC 10646]
  235. * code point encoded as an Unsigned Integer.
  236. *
  237. * \param stream Output Stream
  238. * \param chars Characters
  239. * \param len Numbr of characters
  240. * \return Error-Code <> 0
  241. *
  242. */
  243. int encodeUCSCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len);
  244. /**
  245. * \brief Encode binary
  246. *
  247. * Encode a binary value as a length-prefixed sequence of octets.
  248. *
  249. * \param stream Output Stream
  250. * \param bytes Byte values
  251. * \return Error-Code <> 0
  252. *
  253. */
  254. int encodeBinary(bitstream_t* stream, exi_bytes_t* bytes);
  255. /**
  256. * \brief Encode datetime
  257. *
  258. * Encode a datetime representation which is a sequence of values
  259. * representing the individual components of the Date-Time.
  260. *
  261. * \param stream Output Stream
  262. * \param datetime Datetime values
  263. * \return Error-Code <> 0
  264. *
  265. */
  266. int encodeDateTime(bitstream_t* stream, exi_datetime_t* datetime);
  267. /**
  268. * \brief Flush underlying bit output stream
  269. *
  270. * \param stream Output Stream
  271. * \return Error-Code <> 0
  272. *
  273. */
  274. int encodeFinish(bitstream_t* stream);
  275. #endif
  276. #ifdef __cplusplus
  277. }
  278. #endif