summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-10-12 11:11:06 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-10-12 11:11:06 (GMT)
commitfa90b5749693d9f5817ad1f106334a0877171fd3 (patch)
tree8d53b5c820590cad54893bc575ef55df38f55d23 /src/uscxml/util
parentc36b123a60278caef5d06e8a7d0b3d338d669c75 (diff)
downloaduscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.zip
uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.tar.gz
uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.tar.bz2
Major work on PROMELA datamodel
Diffstat (limited to 'src/uscxml/util')
-rw-r--r--src/uscxml/util/Trie.cpp14
-rw-r--r--src/uscxml/util/Trie.h6
2 files changed, 15 insertions, 5 deletions
diff --git a/src/uscxml/util/Trie.cpp b/src/uscxml/util/Trie.cpp
index ebcc3ef..8934c73 100644
--- a/src/uscxml/util/Trie.cpp
+++ b/src/uscxml/util/Trie.cpp
@@ -19,17 +19,18 @@
#include "Trie.h"
#include <iostream>
+#include <boost/algorithm/string.hpp>
namespace uscxml {
Trie::Trie() {
root = new TrieNode();
- lastIdentifier = 0;
+ lastIndex = 0;
}
Trie::Trie(const std::string& seperator) : seperator(seperator) {
root = new TrieNode();
- lastIdentifier = 0;
+ lastIndex = 0;
}
Trie::~Trie() {
@@ -67,6 +68,12 @@ size_t Trie::getNextToken(const std::string& word, size_t offset, std::string& t
return offset + 1;
}
+std::string Trie::escapeWord(const std::string& word) {
+ std::string identifier = word;
+ boost::replace_all(identifier, ".", "_");
+ return identifier;
+}
+
void Trie::addWord(const std::string& word) {
TrieNode* currNode = root;
@@ -86,8 +93,9 @@ void Trie::addWord(const std::string& word) {
break;
}
if (!currNode->hasWord) {
- currNode->identifier = lastIdentifier++;
+ currNode->index = lastIndex++;
currNode->value = word;
+ currNode->identifier = escapeWord(word);
currNode->hasWord = true;
}
}
diff --git a/src/uscxml/util/Trie.h b/src/uscxml/util/Trie.h
index 1f8b201..73d75e7 100644
--- a/src/uscxml/util/Trie.h
+++ b/src/uscxml/util/Trie.h
@@ -32,7 +32,8 @@ struct USCXML_API TrieNode {
virtual ~TrieNode();
bool hasWord;
- int identifier;
+ int index;
+ std::string identifier;
std::string value;
std::map<std::string, TrieNode*> childs;
void dump(int indent = 0);
@@ -45,6 +46,7 @@ struct USCXML_API Trie {
void addWord(const std::string& word);
size_t getNextToken(const std::string& word, size_t offset, std::string& token);
+ std::string escapeWord(const std::string& word);
TrieNode* getNodeWithPrefix(const std::string& prefix);
std::list<TrieNode*> getWordsWithPrefix(const std::string& prefix);
@@ -53,7 +55,7 @@ struct USCXML_API Trie {
TrieNode* root;
std::string seperator;
- int lastIdentifier;
+ int lastIndex;
};
}