Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cStreamBit.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cStreamBit_H
7 #define _INC_cStreamBit_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
15 
16 namespace GrayLib
17 {
19  {
22  short m_Value;
23  short m_nZero;
24  short m_nOne;
25  };
26 
27  class GRAYLIB_LINK cStreamBitTree : public cSingleton<cStreamBitTree>
28  {
33 
34  friend class cSingleton<cStreamBitTree>;
36  public:
37  static const short k_SIZE = (256 + 1);
38  static const WORD k_EncoderData[k_SIZE];
39 
40  cStreamBitBranch m_Decoder[k_SIZE * 2];
42 
43  protected:
44  bool AddBitBranch(short Value, WORD wCode, int iBits);
45 
46  protected:
48  ~cStreamBitTree();
49 
50  public:
51  // Populate the tree.
52  bool InitTree();
53  bool isInitTree() const noexcept
54  {
55  return m_iDecoderTree != 0;
56  }
57  static size_t GRAYCALL Encode(BYTE* pOutput, const BYTE* pInput, size_t inplen);
58 
59  UNITTEST_FRIEND(cStreamBit);
60  };
61 
63  {
67 
68  private:
70  int m_iDecodeWork;
71  int m_iDecodeIndex;
72  public:
74  {
75  ResetDecoder();
76  }
77  void ResetDecoder() noexcept
78  {
79  m_iDecodeWork = 0;
80  m_iDecodeIndex = 0;
81  }
82  bool isCompletePacket() const noexcept
83  {
84  return(m_iDecodeIndex == 0);
85  }
86  int get_IncompleteSize() const noexcept
87  {
88  return(m_iDecodeIndex);
89  }
90  int Decode(BYTE* pOutput, const BYTE* pInput, size_t nInputSize);
91  };
92 };
93 #endif // _INC_cStreamBit_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define CHEAPOBJECT_IMPL
Definition: cHeapObject.h:32
Definition: cStreamBit.h:63
void ResetDecoder() noexcept
Definition: cStreamBit.h:77
bool isCompletePacket() const noexcept
Definition: cStreamBit.h:82
cStreamBitDecompress() noexcept
Definition: cStreamBit.h:73
int get_IncompleteSize() const noexcept
Definition: cStreamBit.h:86
Definition: cStreamBit.h:28
short m_iDecoderTree
Definition: cStreamBit.h:41
bool isInitTree() const noexcept
Definition: cStreamBit.h:53
UNITTEST_FRIEND(cStreamBit)
Definition: cSingleton.h:127
Definition: cMesh.h:22
Definition: cStreamBit.h:19
short m_nZero
index to branch for bit set.
Definition: cStreamBit.h:23
short m_nOne
index to branch for bit clear.
Definition: cStreamBit.h:24
short m_Value
-1=tree branch, 0-255=character value, 256=PROXY_BRANCH_QTY-1=end
Definition: cStreamBit.h:22