summaryrefslogtreecommitdiffstats
path: root/src/uscxml/Message.cpp
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-02-19 19:50:17 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-02-19 19:50:17 (GMT)
commitbbec87d314f5b706afda260d04f3180b1f848d6b (patch)
tree6d720ab67a7213e10756ca234ccc53ad31034e2e /src/uscxml/Message.cpp
parent6926b730e79e1e7bbb5080c4182d8c2862b08fdc (diff)
downloaduscxml-bbec87d314f5b706afda260d04f3180b1f848d6b.zip
uscxml-bbec87d314f5b706afda260d04f3180b1f848d6b.tar.gz
uscxml-bbec87d314f5b706afda260d04f3180b1f848d6b.tar.bz2
More work on prolog datamodel
Diffstat (limited to 'src/uscxml/Message.cpp')
-rw-r--r--src/uscxml/Message.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp
index bbd7f28..e8ae98c 100644
--- a/src/uscxml/Message.cpp
+++ b/src/uscxml/Message.cpp
@@ -123,6 +123,40 @@ Data::Data(const char* _data, size_t _size, const std::string& mimeType, bool ad
binary = boost::shared_ptr<Blob>(new Blob((void*)_data, _size, mimeType, adopt));
}
+void Data::merge(const Data& other) {
+ if (other.compound.size() > 0) {
+ if (compound.size() == 0) {
+ compound = other.compound;
+ } else {
+ std::map<std::string, Data>::const_iterator compIter = other.compound.begin();
+ while (compIter != other.compound.end()) {
+ if (compound.find(compIter->first) != compound.end()) {
+ // we do have the same key, merge
+ compound[compIter->first].merge(compIter->second);
+ } else {
+ compound[compIter->first] = compIter->second;
+ }
+ compIter++;
+ }
+ }
+ }
+ if (other.array.size() > 0) {
+ if (array.size() == 0) {
+ array = other.array;
+ } else {
+ std::list<Data>::const_iterator arrIter = other.array.begin();
+ while(arrIter != other.array.end()) {
+ array.push_back(*arrIter);
+ arrIter++;
+ }
+ }
+ }
+ if (other.atom.size() > 0) {
+ atom = other.atom;
+ type = other.type;
+ }
+}
+
Data::Data(const Arabica::DOM::Node<std::string>& dom) {
// we may need to convert some keys to arrays if we have the same name as an element
std::map<std::string, std::list<Data> > arrays;