diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-05-23 10:50:59 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-05-23 10:50:59 (GMT) |
commit | 9f3dfcd9982cff90cf0466413d17fc1061c43f00 (patch) | |
tree | e29d0f70ecdfb742e3bbbc522e87281c8bbd58e7 /src/uscxml/Message.h | |
parent | 216e8efb0f1aff9afd3881ab89b49e017e255228 (diff) | |
download | uscxml-9f3dfcd9982cff90cf0466413d17fc1061c43f00.zip uscxml-9f3dfcd9982cff90cf0466413d17fc1061c43f00.tar.gz uscxml-9f3dfcd9982cff90cf0466413d17fc1061c43f00.tar.bz2 |
Fixed the 100% CPU utilization bug and replaced the bool() cast operator for data by empty()
Diffstat (limited to 'src/uscxml/Message.h')
-rw-r--r-- | src/uscxml/Message.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index 57e8680..27b2ac5 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -106,8 +106,15 @@ public: explicit Data(const Arabica::DOM::Node<std::string>& dom); virtual ~Data() {} - operator bool() const { - return (atom.length() > 0 || !compound.empty() || !array.empty() || binary || node); + bool empty() const { + bool hasContent = (atom.length() > 0 || !compound.empty() || !array.empty() || binary || node); + return !hasContent; + } + + bool operator<(const Data& other) const { + std::string thisJSON = Data::toJSON(*this); + std::string otherJSON = Data::toJSON(other); + return (thisJSON < otherJSON); } void merge(const Data& other); @@ -120,10 +127,18 @@ public: return operator[](key.c_str()); } + const Data& operator[](const std::string& key) const { + return operator[](key.c_str()); + } + Data& operator[](const char* key) { return compound[key]; } + const Data& operator[](const char* key) const { + return compound.at(key); + } + Data& operator[](const size_t index) { while(array.size() < index) { array.push_back(Data("", Data::VERBATIM)); |