Octane v1.01.20 - The Open Compression Toolkit for C++ | http://octane.sourceforge.net/ |
#include <sampleparser.hpp>
Inheritance diagram for SampleParser:
Because it uses a fixed symbol set it is ready to parse without any training.
Definition at line 45 of file sampleparser.hpp.
Public Member Functions | |
SampleParser () | |
constructor | |
~SampleParser () | |
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 | |
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 61 of file sampleparser.hpp.
00061 {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 63 of file sampleparser.hpp.
00063 {return true;}; |
|
Parse the next symbol from the input and return its #.
Implements OctaneParser. Definition at line 28 of file sampleparser.cpp. References bitreader::empty(), bitreader::get(), and senteos.
00029 { 00030 // grab an input stream symbol and set its INDEX (in symbol vector) for symbolnum 00031 // return false after EOS 00032 unsigned char c; 00033 00034 // are we at end of from input - this is the only non-intuitive step 00035 // the issue is that only the parser knows about end-of-stream symbols, and when it hits and end of input 00036 // it basically needs to reply TWICE, first with an end-of-stream, and then with a reply saying 'no more symbols' 00037 if (from.empty()) 00038 { 00039 // no more symbols left - BUT the question now is, do we return an EOS symbol, or false for no symbols left 00040 if (senteos) 00041 { 00042 // we already sent an EOS so from now on any requests for a symbol returns false saying no more symbols available 00043 return false; 00044 } 00045 else 00046 { 00047 // we are going to drop down to return the EOS signal, but we set flag so we don't do it again 00048 senteos=true; 00049 } 00050 // end of stream symbol number 00051 symbolnum=SampleParser_EndOfStreamSYMBOL; 00052 } 00053 else 00054 { 00055 // grab an unsigned character from input and assign the symbol # to its ascii number 00056 from.get(c); 00057 symbolnum=(int)c; 00058 } 00059 00060 // return true, saying we read a symbol 00061 return true; 00062 } |
|
Parse the next symbol from the input, and set symbolnum to the symbol id#,.
Implements OctaneParser. Definition at line 65 of file sampleparser.cpp. References bitwriter::put().
00066 { 00067 // write the symbol indexed by symbolnum 00068 // sets isendofostreamsymbol to true or false depending on if the symbol written is the EOS symbol 00069 // return true on success 00070 00071 if (symbolnum==SampleParser_EndOfStreamSYMBOL) 00072 { 00073 // this is end of stream symbol, so do nothing but set EOS flag 00074 isendofstreamsymbol=true; 00075 } 00076 else 00077 { 00078 // not EOS, so write it and set EOS flag false 00079 to.put((unsigned char)symbolnum); 00080 isendofstreamsymbol=false; 00081 } 00082 00083 // return success 00084 return true; 00085 } |
|
Helper function to return the text string of a symbol number.
Implements OctaneParser. Definition at line 88 of file sampleparser.cpp.
00089 { 00090 // return the string text corresponding to symbol 'symbolnum' 00091 if (symbolnum==SampleParser_EndOfStreamSYMBOL) 00092 return ""; 00093 char cstr[2]; 00094 cstr[0]=(unsigned char)symbolnum; 00095 cstr[1]='\0'; 00096 return string(cstr); 00097 } |
|
This function is called to set a variable value.
Reimplemented from OctaneClass. Definition at line 82 of file sampleparser.hpp.
00082 {return false;}; |
|
Save state of object to output stream (if appropriate).
Reimplemented from OctaneClass. Definition at line 83 of file sampleparser.hpp.
00083 {return true;}; |
|
Load state of object from input stream (if appropriate).
Reimplemented from OctaneClass. Definition at line 84 of file sampleparser.hpp.
00084 {return true;}; |
|
We need to track whether we sent an EOS yet.
Definition at line 50 of file sampleparser.hpp. Referenced by ParseNextSymbolFromInput(), and SynchronizeStateForNewStream(). |