File size: 3,084 Bytes
9375c9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
// Copyright (C) 2003 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_BIT_STREAM_KERNEl_1_
#define DLIB_BIT_STREAM_KERNEl_1_
#include "bit_stream_kernel_abstract.h"
#include <iosfwd>
namespace dlib
{
class bit_stream_kernel_1
{
/*!
INITIAL VALUE
write_mode == false
read_mode == false
CONVENTION
write_mode == is_in_write_mode()
read_mode == is_in_read_mode()
if (write_mode)
{
osp == pointer to an ostream object
buffer == the low order bits of buffer are the bits to be
written
buffer_size == the number of low order bits in buffer that are
bits that should be written
the lowest order bit is the last bit entered by the user
}
if (read_mode)
{
isp == pointer to an istream object
buffer == the high order bits of buffer are the bits
waiting to be read by the user
buffer_size == the number of high order bits in buffer that
are bits that are waiting to be read
the highest order bit is the next bit to give to the user
}
!*/
public:
bit_stream_kernel_1 (
) :
write_mode(false),
read_mode(false)
{}
virtual ~bit_stream_kernel_1 (
)
{}
void clear (
);
void set_input_stream (
std::istream& is
);
void set_output_stream (
std::ostream& os
);
void close (
);
inline bool is_in_write_mode (
) const;
inline bool is_in_read_mode (
) const;
inline void write (
int bit
);
bool read (
int& bit
);
void swap (
bit_stream_kernel_1& item
);
private:
// member data
std::istream* isp;
std::ostream* osp;
bool write_mode;
bool read_mode;
unsigned char buffer;
unsigned short buffer_size;
// restricted functions
bit_stream_kernel_1(bit_stream_kernel_1&); // copy constructor
bit_stream_kernel_1& operator=(bit_stream_kernel_1&); // assignment operator
};
inline void swap (
bit_stream_kernel_1& a,
bit_stream_kernel_1& b
);
// ----------------------------------------------------------------------------------------
}
#ifdef NO_MAKEFILE
#include "bit_stream_kernel_1.cpp"
#endif
#endif // DLIB_BIT_STREAM_KERNEl_1_
|