| Octane v1.01.20 - The Open Compression Toolkit for C++ | http://octane.sourceforge.net/ |
#include <bitparser.hpp>
Inheritance diagram for BitParser:

Because it uses a fixed symbol set it is ready to parse without any training.
Definition at line 41 of file bitparser.hpp.
Public Member Functions | |
| BitParser () | |
| constructor | |
| ~BitParser () | |
| destructor | |
| virtual bool | CreateSymbolSetUsingStream (bitreader &from) |
| Process (train on) an input stream to update/create a symbol set from it. | |
| virtual bool | IsReadyToParse () |
| are we ready to parse? i.e. has symbol set been built. | |
| virtual bool | RewindAnyBufferedInput (bitreader &from) |
| Let go of any buffered stream - this is an odd function that can be called be compressor if it wants to hand off the input stream to a new parser or otherwise access the input bitstream from after last symbol parsed. | |
| virtual void | SynchronizeStateForNewStream () |
| Synchronize state for a new stream - this will always be called before beginning a new parsing stream, and should be used to reset the parse into any initial predictable state. | |
| virtual int | GetSymbolCount () |
| Get a count of the number of symbols stored in the parser. | |
| virtual bool | ParseNextSymbolFromInput (bitreader &from, int &symbolnum) |
| Parse the next symbol from the input and return its #. | |
| virtual bool | WriteSymbolText (bitwriter &to, int symbolnum, bool &isendofstreamsymbol) |
| Parse the next symbol from the input, and set symbolnum to the symbol id#,. | |
| virtual string | LookupSymbolText (int symbolnum) |
| Helper function to return the text string of a symbol number. | |
| virtual void | ShowDebuggingInfo () |
| show any debugging info on request (used by various derived classes) [optional] | |
| virtual unsigned int | GetMemoryUsed () |
| Report actual current memory usage (in bytes). | |
| virtual unsigned int | GetDiskspaceUsed (bool fortempdecompressiononly) |
| Report disk space (in bytes) that would be used when saving state to file (in bytes). | |
| virtual std::string | GetParametersInformation () |
| Reports information about any parameters available. | |
| virtual void | SetDefaultParameters () |
| Reset any parameters to their default values. | |
| virtual bool | SetParameter (const std::string ¶metername, const std::string ¶metervalue) |
| This function is called to set a variable value. | |
| virtual bool | SaveState (bitwriter &to, bool fortempdecompressiononly) |
| Save state of object to output stream (if appropriate). | |
| virtual bool | LoadState (bitreader &from) |
| Load state of object from input stream (if appropriate). | |
Protected Attributes | |
| int | Parameter_bitlength |
| The number of bits per chunk. | |
| bool | senteos |
| We need to track whether we sent an EOS yet. | |
|
|
Process (train on) an input stream to update/create a symbol set from it.
Reimplemented from OctaneParser. Definition at line 60 of file bitparser.hpp.
00060 {return true;};
|
|
|
Let go of any buffered stream - this is an odd function that can be called be compressor if it wants to hand off the input stream to a new parser or otherwise access the input bitstream from after last symbol parsed. it is necessary because some parsers can read-ahead in input buffer, and so must rewind the bitstream. Reimplemented from OctaneParser. Definition at line 62 of file bitparser.hpp.
00062 {return true;};
|
|
||||||||||||
|
Parse the next symbol from the input and return its #.
Implements OctaneParser. Definition at line 32 of file bitparser.cpp. References bitreader::empty(), bitreader::get(), and senteos.
00033 {
00034 // grab an input stream symbol and set its INDEX (in symbol vector) for symbolnum
00035 // return false after EOS
00036 unsigned char c;
00037
00038 // are we at end of from input - this is the only non-intuitive step
00039 // the issue is that only the parser knows about end-of-stream symbols, and when it hits and end of input
00040 // it basically needs to reply TWICE, first with an end-of-stream, and then with a reply saying 'no more symbols'
00041 if (from.empty())
00042 {
00043 // no more symbols left - BUT the question now is, do we return an EOS symbol, or false for no symbols left
00044 if (senteos)
00045 {
00046 // we already sent an EOS so from now on any requests for a symbol returns false saying no more symbols available
00047 return false;
00048 }
00049 else
00050 {
00051 // we are going to drop down to return the EOS signal, but we set flag so we don't do it again
00052 senteos=true;
00053 }
00054 // end of stream symbol number
00055 symbolnum=SampleParser_EndOfStreamSYMBOL;
00056 }
00057 else
00058 {
00059 // grab an unsigned character from input and assign the symbol # to its ascii number
00060 from.get(c);
00061 symbolnum=(int)c;
00062 }
00063
00064 // return true, saying we read a symbol
00065 return true;
00066 }
|
|
||||||||||||||||
|
Parse the next symbol from the input, and set symbolnum to the symbol id#,.
Implements OctaneParser. Definition at line 69 of file bitparser.cpp. References bitwriter::put().
00070 {
00071 // write the symbol indexed by symbolnum
00072 // sets isendofostreamsymbol to true or false depending on if the symbol written is the EOS symbol
00073 // return true on success
00074
00075 if (symbolnum==SampleParser_EndOfStreamSYMBOL)
00076 {
00077 // this is end of stream symbol, so do nothing but set EOS flag
00078 isendofstreamsymbol=true;
00079 }
00080 else
00081 {
00082 // not EOS, so write it and set EOS flag false
00083 to.put((unsigned char)symbolnum);
00084 isendofstreamsymbol=false;
00085 }
00086
00087 // return success
00088 return true;
00089 }
|
|
|
Helper function to return the text string of a symbol number.
Implements OctaneParser. Definition at line 92 of file bitparser.cpp.
00093 {
00094 // return the string text corresponding to symbol 'symbolnum'
00095 if (symbolnum==SampleParser_EndOfStreamSYMBOL)
00096 return "";
00097 char cstr[2];
00098 cstr[0]=(unsigned char)symbolnum;
00099 cstr[1]='\0';
00100 return string(cstr);
00101 }
|
|
||||||||||||
|
This function is called to set a variable value.
Reimplemented from OctaneClass. Definition at line 81 of file bitparser.hpp.
00081 {return false;};
|
|
||||||||||||
|
Save state of object to output stream (if appropriate).
Reimplemented from OctaneClass. Definition at line 82 of file bitparser.hpp.
00082 {return true;};
|
|
|
Load state of object from input stream (if appropriate).
Reimplemented from OctaneClass. Definition at line 83 of file bitparser.hpp.
00083 {return true;};
|
|
|
We need to track whether we sent an EOS yet.
Definition at line 49 of file bitparser.hpp. Referenced by ParseNextSymbolFromInput(), and SynchronizeStateForNewStream(). |