Skip to content
Snippets Groups Projects
Commit 3a20e3be authored by ilor's avatar ilor
Browse files

update Value, add simple Bool and Position classes

parent 16c71886
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,9 @@ link_directories(${Boost_LIBRARY_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
SET(libwccl_STAT_SRC
bool.cpp
main.cpp
position.cpp
sentencecontext.cpp
value.cpp
variables.cpp
......
#include <libwccl/bool.h>
namespace Wccl {
const char* Bool::type_name = "Bool";
} /* end ns Wccl */
#ifndef LIBWCCL_BOOL_H
#define LIBWCCL_BOOL_H
#include <libwccl/value.h>
namespace Wccl {
class Bool : public Value
{
public:
WCCL_VALUE_PREAMBLE
explicit Bool(bool v = false)
: val_(v)
{
}
bool get_value() const {
return val_;
}
void set_value(bool v) {
val_ = v;
}
/// Value override
std::string to_raw_string() const {
return val_ ? "true" : "false";
}
private:
bool val_;
};
} /* end ns Wccl */
#endif // LIBWCCL_BOOL_H
#include <libwccl/position.h>
#include <boost/lexical_cast.hpp>
namespace Wccl {
const char* Position::type_name = "Position";
std::string Position::to_raw_string() const
{
return boost::lexical_cast<std::string>(val_);
}
} /* end ns Wccl */
#ifndef LIBWCCL_POSITION_H
#define LIBWCCL_POSITION_H
#include <libwccl/value.h>
#include <cstdlib>
namespace Wccl {
class Position : public Value
{
public:
WCCL_VALUE_PREAMBLE
explicit Position(int v = 0)
: val_(v)
{
}
int get_value() const {
return val_;
}
void set_value(int v) {
val_ = v;
}
/// Value override
std::string to_raw_string() const;
private:
int val_;
};
} /* end ns Wccl */
#endif // LIBWCCL_POSITION_H
......@@ -2,4 +2,6 @@
namespace Wccl {
const char* Value::type_name = "Value";
} /* end ns Wccl */
......@@ -3,6 +3,11 @@
#include <libcorpus2/tagset.h>
#define WCCL_VALUE_PREAMBLE \
static const char* type_name; \
const char* get_type_name() const { return type_name; }
namespace Wccl {
/**
......@@ -11,6 +16,12 @@ namespace Wccl {
class Value
{
public:
static const char* type_name;
virtual const char* get_type_name() const {
return type_name;
}
virtual ~Value() {}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment