EncoderChannel.h 8.9 KB

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