?? bitio.h
字號:
// BitIO.h : Define BitIO class and its child classes
//
// Author: Shen Hongwei
// Date: 10.10, 2005
// Location: Beijing, China
//
#pragma once
#ifndef _BitIO_H_
#define _BitIO_H_
// #include "stdio.h"
#include <iostream>
#include <fstream>
using namespace std;
#include <assert.h>
class BitOp
{
public:
void static AddPrefix(char * bits, int & bits_len, char * pre, int pre_len);
};
virtual class BitIO
{
public:
BitIO(void);
~BitIO(void);
bool Init();
bool Init(int buf_size, int mode);
virtual bool Write(const char * bits, int bits_len);
virtual void Flush();
virtual void FlushEnd() = 0;
virtual void Close();
virtual int ReadABit() = 0;
virtual int ReadABit(char * c, int start);
virtual bool ReadAByte(char & c);
virtual bool ReadAInversedByte(char & c) = 0;
virtual bool ReadAULong(unsigned long &ul) = 0;
// bool Read(char * bits, int &bits_len);
int GetMode(); // return the working mode of current object
inline unsigned long GetBitsNum(void) { return bits_num;};
protected:
unsigned long bits_num;
unsigned long max_bits_num;
int mode; // 0 for read only; 1 for write only; 2 for read & write
char * buf;
unsigned long used; // used buffer (by number of bits)
unsigned long buf_size; // size of buf by bytes.
unsigned long unhandled; // the number of unhandled bits in buffer, set for reading funtion
unsigned long handled; // the number of handled bits in buffer, set for reading funtion
};
class FileBitIO : public BitIO
{
public:
FileBitIO(void);
~FileBitIO(void);
bool Init(fstream * p_fs);
bool Init(fstream * p_fs, int bufsize, int work_mode, unsigned long leng);
bool Init(fstream * p_fs, int bufsize, int work_mode);
bool Write(const char * bits, int bits_len);
void Flush();
void FlushEnd();
void Close();
int ReadABit();
int ReadABit(char * c, int start);
bool ReadAByte(char & c);
bool ReadAInversedByte(char & c);
bool ReadAULong(unsigned long & ul);
unsigned long GetBitsNum(void);
protected:
int RenewReadBuf();
fstream * fs;
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -