⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitparser.hpp

📁 Octane v1.01.20 The Open Compression Toolkit for C++ . The Open Compression Toolkit is a set of mo
💻 HPP
字号:
/// @file bitparser.hpp
/// A bit-level parser that can be told how many bits per symbol, and returns numbers converted bit chunks
///
/// @remarks
/// the basic idea is you can set bitlength from 1 to 99, and it will parse
/// the input in chunks of bitlength bytes, returning a symbol #
/// corresponding to the index of the bitstring in the list of possible
/// bit patterns of bitlength.
///
/// @author mouser
/// @date   2004.01.25
///
/// @todo:
/// this is not finished yet
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// recursive header protection
#ifndef BitParserH
#define BitParserH
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// application includes
#include "../parser.hpp"
#include "../../bitio/bitio.hpp"
// system includes
using namespace std;
//---------------------------------------------------------------------------






//---------------------------------------------------------------------------
/// Sample parser class is just character based, uses one symbol for each ascii
/// character plus one for end-of-stream.  Because it uses a fixed symbol set
/// it is ready to parse without any training.
/// @ingroup Parsers
class BitParser : public OctaneParser
{
protected:
	/// The number of bits per chunk
	int Parameter_bitlength;
protected:
	/// We need to track whether we sent an EOS yet
	/// @todo there should be a way to do this automatically perhaps with a wrapper, rather than insisting all derived parsers deal with returning an EOS symbol.
	bool senteos;
public:
	//---------------------------------------------------------------------------
	/// constructor
	BitParser() {bitlength=1;};
	/// destructor
	~BitParser() {;};
	//---------------------------------------------------------------------------
public:
	//---------------------------------------------------------------------------
	// PARSER PUBLIC API - PREPARATIONS FOR PARSING
	virtual bool CreateSymbolSetUsingStream(bitreader &from) {return true;};
	virtual bool IsReadyToParse() {return true;};
	virtual bool RewindAnyBufferedInput(bitreader &from) {return true;};
	//---------------------------------------------------------------------------
public:
	//---------------------------------------------------------------------------
	// PARSER PUBLIC API - MAIN PARSING FUNCTIONS
	virtual void SynchronizeStateForNewStream();
	virtual int GetSymbolCount() {return 256;};
	virtual bool ParseNextSymbolFromInput(bitreader &from, int &symbolnum);
	virtual bool WriteSymbolText(bitwriter &to, int symbolnum,bool &isendofstreamsymbol);
	virtual string LookupSymbolText(int symbolnum);
	//---------------------------------------------------------------------------
public:
	//---------------------------------------------------------------------------
	// OCTANE PUBLIC API - AUXILIARY FUNCTIONS - these are supported by all derived classes
	virtual void ShowDebuggingInfo() {;};
	virtual unsigned int GetMemoryUsed() {return (unsigned int)(sizeof(this));};
	virtual unsigned int GetDiskspaceUsed(bool fortempdecompressiononly) {return (unsigned int)0;};
	virtual std::string GetParametersInformation() {return "";};
	virtual void SetDefaultParameters() {;};
	virtual bool SetParameter(const std::string &parametername,const std::string &parametervalue) {return false;};
	virtual bool SaveState(bitwriter &to,bool fortempdecompressiononly) {return true;};
	virtual bool LoadState(bitreader &from) {return true;};
	//---------------------------------------------------------------------------
};
//---------------------------------------------------------------------------





//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -