BitEncoderChannel.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2007-2010 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.3
  21. * @contact Joerg.Heuer@siemens.com
  22. *
  23. ********************************************************************/
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include <stdint.h>
  28. #include "EXITypes.h"
  29. #ifndef BIT_ENCODER_CHANNEL_H
  30. #define BIT_ENCODER_CHANNEL_H
  31. /**
  32. * Encode a single boolean value. A false value is encoded as bit 0 and true
  33. * value is encode as bit 1.
  34. */
  35. int encodeBoolean(bitstream_t* stream, int b);
  36. /**
  37. * Encode n-bit unsigned integer. The n least significant bits of parameter
  38. * b starting with the most significant, i.e. from left to right.
  39. */
  40. int encodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t val);
  41. /**
  42. * Encode an arbitrary precision non negative integer using a sequence of
  43. * octets. The most significant bit of the last octet is set to zero to
  44. * indicate sequence termination. Only seven bits per octet are used to
  45. * store the integer's value.
  46. */
  47. int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n);
  48. /**
  49. * Encode an arbitrary precision non negative integer using a sequence of
  50. * octets. The most significant bit of the last octet is set to zero to
  51. * indicate sequence termination. Only seven bits per octet are used to
  52. * store the integer's value.
  53. */
  54. int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n);
  55. /**
  56. * Encode an arbitrary precision integer using a sign bit followed by a
  57. * sequence of octets. The most significant bit of the last octet is set to
  58. * zero to indicate sequence termination. Only seven bits per octet are used
  59. * to store the integer's value.
  60. */
  61. int encodeInteger32(bitstream_t* stream, int32_t n);
  62. /**
  63. * Encode an arbitrary precision integer using a sign bit followed by a
  64. * sequence of octets. The most significant bit of the last octet is set to
  65. * zero to indicate sequence termination. Only seven bits per octet are used
  66. * to store the integer's value.
  67. */
  68. int encodeInteger64(bitstream_t* stream, int64_t n);
  69. /**
  70. * Encode a Float datatype as two consecutive Integers.
  71. * The first Integer represents the mantissa of the floating point
  72. * number and the second Integer represents the base-10 exponent
  73. * of the floating point number.
  74. */
  75. int encodeFloat(bitstream_t* stream, float_me_t* f);
  76. /**
  77. * Encode a length prefixed sequence of characters.
  78. */
  79. int encodeString(bitstream_t* stream, string_ucs_t* string);
  80. /**
  81. * Encode a length prefixed sequence of characters in the sense of string tables
  82. */
  83. int encodeStringValue(bitstream_t* stream, string_ucs_t* string);
  84. /**
  85. * Encode a sequence of characters according to a given length.
  86. * Each character is represented by its UCS [ISO/IEC 10646]
  87. * code point encoded as an Unsigned Integer
  88. */
  89. int encodeCharacters(bitstream_t* stream, uint32_t* chars, size_t len);
  90. /**
  91. * Encode a binary value as a length-prefixed sequence of octets.
  92. */
  93. int encodeBinary(bitstream_t* stream, bytes_t* bytes);
  94. /**
  95. * Flush underlying bit output stream
  96. */
  97. int encodeFinish(bitstream_t* stream);
  98. #endif
  99. #ifdef __cplusplus
  100. }
  101. #endif