2013-11-12 22:08:37 +01:00
|
|
|
#ifndef WORD_MAP_HDR
|
|
|
|
#define WORD_MAP_HDR
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include "concordia/concordia_exception.hpp"
|
2013-11-14 15:44:50 +01:00
|
|
|
#include <boost/archive/text_oarchive.hpp>
|
|
|
|
#include <boost/archive/text_iarchive.hpp>
|
|
|
|
#include <boost/serialization/map.hpp>
|
2013-11-12 22:08:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-11-14 15:44:50 +01:00
|
|
|
Class representing dictionary for word to int encoding.
|
2013-11-12 22:08:37 +01:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class WordMap {
|
|
|
|
public:
|
|
|
|
explicit WordMap() throw(ConcordiaException);
|
2013-11-14 15:44:50 +01:00
|
|
|
|
2013-11-12 22:08:37 +01:00
|
|
|
/*! Destructor.
|
|
|
|
*/
|
|
|
|
virtual ~WordMap();
|
|
|
|
|
|
|
|
int getWordCode(const string & word);
|
|
|
|
|
|
|
|
private:
|
2013-11-14 15:44:50 +01:00
|
|
|
friend class boost::serialization::access;
|
|
|
|
|
|
|
|
template<class Archive>
|
2013-11-12 22:08:37 +01:00
|
|
|
|
2013-11-14 15:44:50 +01:00
|
|
|
void serialize(Archive & ar, const unsigned int version) {
|
|
|
|
ar & _map;
|
|
|
|
ar & _nextFree;
|
|
|
|
}
|
|
|
|
|
|
|
|
map<string, int> _map;
|
|
|
|
|
|
|
|
int _nextFree;
|
2013-11-12 22:08:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|