diff --git a/libwccl/CMakeLists.txt b/libwccl/CMakeLists.txt index 7760bcc2fbf2f193b5accf9c31440ff187e2484c..e8fcba589d01d5495cf50d3dad7be4d3df628ff5 100644 --- a/libwccl/CMakeLists.txt +++ b/libwccl/CMakeLists.txt @@ -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 diff --git a/libwccl/bool.cpp b/libwccl/bool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ab84cd371b9b3e09eef697f4ded65dd1c91c6be1 --- /dev/null +++ b/libwccl/bool.cpp @@ -0,0 +1,7 @@ +#include <libwccl/bool.h> + +namespace Wccl { + +const char* Bool::type_name = "Bool"; + +} /* end ns Wccl */ diff --git a/libwccl/bool.h b/libwccl/bool.h new file mode 100644 index 0000000000000000000000000000000000000000..d1b75b5246322d870f346a27b94ce47ce2273453 --- /dev/null +++ b/libwccl/bool.h @@ -0,0 +1,37 @@ +#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 diff --git a/libwccl/position.cpp b/libwccl/position.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2acf821c2c2a4cd3d7c26992221822c0a5d647c --- /dev/null +++ b/libwccl/position.cpp @@ -0,0 +1,12 @@ +#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 */ diff --git a/libwccl/position.h b/libwccl/position.h new file mode 100644 index 0000000000000000000000000000000000000000..ea0b06a5a093b618d293640bdd268a5a89b5eb62 --- /dev/null +++ b/libwccl/position.h @@ -0,0 +1,37 @@ +#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 diff --git a/libwccl/value.cpp b/libwccl/value.cpp index f46f947cb4bb240297f589d39225e22a56f870c1..89c49ac3b4a43a66219e2aa01446a966cdd33437 100644 --- a/libwccl/value.cpp +++ b/libwccl/value.cpp @@ -2,4 +2,6 @@ namespace Wccl { +const char* Value::type_name = "Value"; + } /* end ns Wccl */ diff --git a/libwccl/value.h b/libwccl/value.h index c761d7805e18cef30566b65237928e806433e8f0..4e9e54ab15f5b70447ddd320a5877ec7c4f04ada 100644 --- a/libwccl/value.h +++ b/libwccl/value.h @@ -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() {} /**