File size: 3,115 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 |
// Copyright (C) 2003 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_BIT_STREAM_MULTi_C_
#define DLIB_BIT_STREAM_MULTi_C_
#include "bit_stream_multi_abstract.h"
#include "../algs.h"
#include "../assert.h"
namespace dlib
{
template <
typename bit_stream_base // implements bit_stream/bit_stream_multi_abstract.h
>
class bit_stream_multi_c : public bit_stream_base
{
public:
void multi_write (
unsigned long data,
int num_to_write
);
int multi_read (
unsigned long& data,
int num_to_read
);
};
template <
typename bit_stream_base
>
inline void swap (
bit_stream_multi_c<bit_stream_base>& a,
bit_stream_multi_c<bit_stream_base>& b
) { a.swap(b); }
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename bit_stream_base
>
void bit_stream_multi_c<bit_stream_base>::
multi_write (
unsigned long data,
int num_to_write
)
{
// make sure requires clause is not broken
DLIB_CASSERT( (this->is_in_write_mode() == true) && (num_to_write >= 0 && num_to_write <=32),
"\tvoid bit_stream::write"
<< "\n\tthe bit stream bust be in write mode and"
<< "\n\tnum_to_write must be between 0 and 32 inclusive"
<< "\n\tnum_to_write == " << num_to_write
<< "\n\tis_in_write_mode() == " << this->is_in_write_mode()
<< "\n\tthis: " << this
);
// call the real function
bit_stream_base::multi_write(data,num_to_write);
}
// ----------------------------------------------------------------------------------------
template <
typename bit_stream_base
>
int bit_stream_multi_c<bit_stream_base>::
multi_read (
unsigned long& data,
int num_to_read
)
{
// make sure requires clause is not broken
DLIB_CASSERT(( this->is_in_read_mode() == true && ( num_to_read >= 0 && num_to_read <=32 ) ),
"\tvoid bit_stream::read"
<< "\n\tyou can't read from a bit_stream that isn't in read mode and"
<< "\n\tnum_to_read must be between 0 and 32 inclusive"
<< "\n\tnum_to_read == " << num_to_read
<< "\n\tis_in_read_mode() == " << this->is_in_read_mode()
<< "\n\tthis: " << this
);
// call the real function
return bit_stream_base::multi_read(data,num_to_read);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_BIT_STREAM_MULTi_C_
|