14 #include <unordered_map>
45 std::unordered_map<unsigned int,std::string> classes;
46 unsigned int highestclass;
66 void load(
const std::string & filename);
68 std::vector<std::string>
decodeseq(
const std::vector<int> & seq);
78 void decodefile(
const std::string & filename, std::ostream*,
unsigned int start = 0,
unsigned int end = 0,
bool quiet=
false);
79 void decodefile_v1(std::ifstream* in, std::ostream* out ,
unsigned int start=0,
unsigned int end=0,
bool quiet=
false);
89 std::string
decodefiletostring(
const std::string & filename,
unsigned int start = 0,
unsigned int end = 0,
bool quiet=
true);
95 return classes.size();
103 std::unordered_map<unsigned int, std::string>::const_iterator it = classes.find(key);
104 if (it != classes.end()) {
114 void add(
const unsigned int,
const std::string &);
124 bool hasclass(
unsigned int key)
const {
return (classes.count(key) > 0); }
134 void prune(
unsigned int threshold);
137 typedef std::unordered_map<unsigned int, std::string>::const_iterator
const_iterator;
140 return classes.begin();
142 const_iterator
end()
const {
143 return classes.end();
148 unsigned int bytestoint(std::istream* IN,
const unsigned char version = 2);
149 unsigned int bytestoint(
const unsigned char* a,
unsigned int * length = NULL);
151 unsigned int bytestoint_v1(
const unsigned char* a,
const int l);
155 int readline(std::istream* IN,
unsigned char* buffer,
const int);
void add(const unsigned int, const std::string &)
Definition: classdecoder.cpp:243
const_iterator begin() const
Definition: classdecoder.h:139
unsigned char getdataversion(std::istream *IN)
Definition: classdecoder.cpp:257
int readline(std::istream *IN, unsigned char *buffer, const int)
std::unordered_map< unsigned int, std::string >::const_iterator const_iterator
Definition: classdecoder.h:137
void load(const std::string &filename)
Definition: classdecoder.cpp:96
Class for decoding binary class-encoded data back to plain-text. The ClassDecoder maintains a mapping...
Definition: classdecoder.h:43
void prune(unsigned int threshold)
Definition: classdecoder.cpp:250
unsigned int gethighestclass()
Definition: classdecoder.h:119
ClassDecoder()
Definition: classdecoder.cpp:84
static const unsigned char flexclass
Definition: classdecoder.h:51
bool hasclass(unsigned int key) const
Definition: classdecoder.h:124
std::vector< std::string > decodeseq(const std::vector< int > &seq)
Definition: classdecoder.cpp:128
static const unsigned char skipclass
Definition: classdecoder.h:50
static const unsigned char delimiterclass
Definition: classdecoder.h:48
void decodefile(const std::string &filename, std::ostream *, unsigned int start=0, unsigned int end=0, bool quiet=false)
Definition: classdecoder.cpp:167
static const unsigned char unknownclass
Definition: classdecoder.h:49
unsigned int bytestoint_v1(const unsigned char *a, const int l)
Definition: classdecoder.cpp:75
int size() const
Definition: classdecoder.h:94
std::string operator[](unsigned int key) const
Definition: classdecoder.h:102
void decodefile_v1(std::ifstream *in, std::ostream *out, unsigned int start=0, unsigned int end=0, bool quiet=false)
Definition: classdecoder.cpp:197
std::string decodefiletostring(const std::string &filename, unsigned int start=0, unsigned int end=0, bool quiet=true)
Definition: classdecoder.cpp:236
unsigned int bytestoint(std::istream *IN, const unsigned char version=2)
Definition: classdecoder.cpp:44
const_iterator end() const
Definition: classdecoder.h:142