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