diff --git a/libwccl/values/strset.cpp b/libwccl/values/strset.cpp index 18f194691f21f1ac5f47655dd13b13a3b777c541..e3c6999674df70901e7dca2cbd2ca443783971c8 100644 --- a/libwccl/values/strset.cpp +++ b/libwccl/values/strset.cpp @@ -23,6 +23,23 @@ std::string StrSet::to_raw_string() const return ss.str(); } +UnicodeString StrSet::to_raw_string_u() const +{ + UnicodeString u; + u.append(UNICODE_STRING("[", 1)); + value_type::const_iterator it = set_.begin(); + while(it != set_.end()) { + u.append(UNICODE_STRING("\"", 1)); + u.append(*it); //TODO escaping + u.append(UNICODE_STRING("\"", 1)); + if(++it != set_.end()) { + u.append(UNICODE_STRING(", ", 2)); + } + } + u.append(UNICODE_STRING("]", 1)); + return u; +} + bool StrSet::intersects(const StrSet &other) const { if (empty() || other.empty()) { return false; diff --git a/libwccl/values/strset.h b/libwccl/values/strset.h index 5b9546796bd3d0f90bf709d0a8cfbe847858b087..e1abb89004ea866bc38efb93956d8788f370ca63 100644 --- a/libwccl/values/strset.h +++ b/libwccl/values/strset.h @@ -96,6 +96,9 @@ public: /// Value override std::string to_raw_string() const; + /// Value override + UnicodeString to_raw_string_u() const; + private: value_type set_; }; diff --git a/libwccl/values/value.h b/libwccl/values/value.h index f4048c04e298b78d9d2e80794af0bacc291a2de3..89b276d7cca19f4630ce2621454a0750bf45ec5d 100644 --- a/libwccl/values/value.h +++ b/libwccl/values/value.h @@ -49,6 +49,13 @@ public: return to_raw_string(); } + /** + * Unicode variant of to_string + */ + virtual UnicodeString to_string_u(const Corpus2::Tagset& /*tagset*/) const { + return to_raw_string_u(); + } + /** * String representation of the Value that does not require a tagset, * might be incomplete and/or contain internal info. @@ -57,6 +64,13 @@ public: */ virtual std::string to_raw_string() const = 0; + /** + * Unicode variant of to_raw_string + */ + virtual UnicodeString to_raw_string_u() const { + return UnicodeString::fromUTF8(to_raw_string()); + } + protected: Value() {} };