Skip to content
Snippets Groups Projects
Commit 98210a20 authored by Franck Dary's avatar Franck Dary
Browse files

strongly typed enums

parent 92d8266b
Branches
No related tags found
No related merge requests found
...@@ -10,13 +10,14 @@ class Dict ...@@ -10,13 +10,14 @@ class Dict
{ {
public : public :
enum State {Open, Closed}; enum class State {Open, Closed};
enum Encoding {Binary, Ascii}; enum class Encoding {Binary, Ascii};
public : public :
static constexpr char const * unknownValueStr = "__unknownValue__"; static constexpr char const * unknownValueStr = "__unknownValue__";
static constexpr char const * nullValueStr = "__nullValue__"; static constexpr char const * nullValueStr = "__nullValue__";
static constexpr char const * oobValueStr = "__oobValue__";
static constexpr char const * noChildValueStr = "__noChildValue__"; static constexpr char const * noChildValueStr = "__noChildValue__";
static constexpr char const * emptyValueStr = "__emptyValue__"; static constexpr char const * emptyValueStr = "__emptyValue__";
static constexpr char const * separatorValueStr = "__separatorValue__"; static constexpr char const * separatorValueStr = "__separatorValue__";
......
...@@ -6,6 +6,7 @@ Dict::Dict(State state) ...@@ -6,6 +6,7 @@ Dict::Dict(State state)
setState(state); setState(state);
insert(unknownValueStr); insert(unknownValueStr);
insert(nullValueStr); insert(nullValueStr);
insert(oobValueStr);
insert(noChildValueStr); insert(noChildValueStr);
insert(emptyValueStr); insert(emptyValueStr);
insert(numberValueStr); insert(numberValueStr);
...@@ -301,6 +302,7 @@ bool Dict::isSpecialValue(const std::string & value) ...@@ -301,6 +302,7 @@ bool Dict::isSpecialValue(const std::string & value)
{ {
return value == unknownValueStr return value == unknownValueStr
|| value == nullValueStr || value == nullValueStr
|| value == oobValueStr
|| value == noChildValueStr || value == noChildValueStr
|| value == emptyValueStr || value == emptyValueStr
|| value == separatorValueStr || value == separatorValueStr
......
...@@ -10,7 +10,7 @@ class Action ...@@ -10,7 +10,7 @@ class Action
{ {
public : public :
enum Type enum class Type
{ {
Push, Push,
Pop, Pop,
......
...@@ -31,7 +31,7 @@ class Config ...@@ -31,7 +31,7 @@ class Config
static constexpr int nbHypothesesMax = 1; static constexpr int nbHypothesesMax = 1;
static constexpr int maxNbAppliableSplitTransitions = 8; static constexpr int maxNbAppliableSplitTransitions = 8;
enum Object enum class Object
{ {
Buffer, Buffer,
Stack Stack
......
...@@ -19,7 +19,7 @@ class Strategy ...@@ -19,7 +19,7 @@ class Strategy
{ {
private : private :
enum EndCondition enum class EndCondition
{ {
CannotMove CannotMove
}; };
......
...@@ -758,7 +758,7 @@ void Transition::initEOS(int bufferIndex) ...@@ -758,7 +758,7 @@ void Transition::initEOS(int bufferIndex)
costDynamic = [bufferIndex](const Config & config) costDynamic = [bufferIndex](const Config & config)
{ {
int lineIndex = config.getRelativeWordIndex(Config::Buffer, bufferIndex); int lineIndex = config.getRelativeWordIndex(Config::Object::Buffer, bufferIndex);
if (config.getConst(Config::EOSColName, lineIndex, 0) != Config::EOSSymbol1) if (config.getConst(Config::EOSColName, lineIndex, 0) != Config::EOSSymbol1)
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();
...@@ -772,7 +772,7 @@ void Transition::initNotEOS(int bufferIndex) ...@@ -772,7 +772,7 @@ void Transition::initNotEOS(int bufferIndex)
{ {
costDynamic = [bufferIndex](const Config & config) costDynamic = [bufferIndex](const Config & config)
{ {
int lineIndex = config.getRelativeWordIndex(Config::Buffer, bufferIndex); int lineIndex = config.getRelativeWordIndex(Config::Object::Buffer, bufferIndex);
if (config.getConst(Config::EOSColName, lineIndex, 0) == Config::EOSSymbol1) if (config.getConst(Config::EOSColName, lineIndex, 0) == Config::EOSSymbol1)
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();
......
...@@ -9,7 +9,7 @@ class Trainer ...@@ -9,7 +9,7 @@ class Trainer
{ {
public : public :
enum TrainAction enum class TrainAction
{ {
ExtractGold, ExtractGold,
ExtractDynamic, ExtractDynamic,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment