diff --git a/alib2/src/label/LabelBase.cpp b/alib2/src/label/LabelBase.cpp index fffd790b9bd18e0c73f1262f7b42023893e9a342..17db046d994332aa7840052b4dc3b5c9135544f6 100644 --- a/alib2/src/label/LabelBase.cpp +++ b/alib2/src/label/LabelBase.cpp @@ -10,6 +10,7 @@ #include "StringLabel.h" #include "IntegerLabel.h" +#include "CharacterLabel.h" namespace label { @@ -25,6 +26,10 @@ bool LabelBase::operator<(const IntegerLabel& other) const { return typeid(*this).before(typeid(other)); } +bool LabelBase::operator<(const CharacterLabel& other) const { + return typeid(*this).before(typeid(other)); +} + bool LabelBase::operator>=(const LabelBase& other) const { return !(*this < other); } @@ -45,6 +50,10 @@ bool LabelBase::operator==(const IntegerLabel&) const { return false; } +bool LabelBase::operator==(const CharacterLabel&) const { + return false; +} + std::ostream& operator<<(std::ostream& os, const LabelBase& label) { label >> os; return os; diff --git a/alib2/src/label/LabelBase.h b/alib2/src/label/LabelBase.h index 1246f791590804dee4f316018f941d0362359cf8..0ffa8f44c89aa971f7c3ab38696eff535dac937a 100644 --- a/alib2/src/label/LabelBase.h +++ b/alib2/src/label/LabelBase.h @@ -34,6 +34,8 @@ public: virtual bool operator<(const IntegerLabel& other) const; + virtual bool operator<(const CharacterLabel& other) const; + virtual bool operator>(const LabelBase& other) const = 0; @@ -50,6 +52,8 @@ public: virtual bool operator==(const IntegerLabel& other) const; + virtual bool operator==(const CharacterLabel& other) const; + friend std::ostream& operator<<(std::ostream& os, const LabelBase& label); virtual void operator>>(std::ostream&) const = 0; diff --git a/alib2/src/label/LabelToStringComposer.cpp b/alib2/src/label/LabelToStringComposer.cpp index dfb00fbb9d3a0e0c15144f7bbd744bbc060f5035..0480d50a2ff8f0e610f1b24336b34b65798b0c3d 100644 --- a/alib2/src/label/LabelToStringComposer.cpp +++ b/alib2/src/label/LabelToStringComposer.cpp @@ -26,7 +26,7 @@ void LabelToStringComposer::Visit(void* userData, const label::StringLabel& labe std::string tmp = label.getData(); replace(tmp, "'", "\\'" ); - out << tmp; + out << '\'' << tmp << '\''; } void LabelToStringComposer::Visit(void* userData, const CharacterLabel& symbol) {