summaryrefslogtreecommitdiff
path: root/src/core/common/WhitespaceHandler.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-15 00:02:54 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-15 00:02:54 +0100
commit2659b4595d809cbd69a77e5ff7e2fc08d225f065 (patch)
treebe6a39fcf7d7070494076832a2e652ea1aa4c91e /src/core/common/WhitespaceHandler.hpp
parent974afd3fdc54380a43445a180263fb162e1ff2c0 (diff)
Tidied OsxmlEventParser up, implemented correct whitespace handling, started to write unit tests for the osxml parser
Diffstat (limited to 'src/core/common/WhitespaceHandler.hpp')
-rw-r--r--src/core/common/WhitespaceHandler.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/core/common/WhitespaceHandler.hpp b/src/core/common/WhitespaceHandler.hpp
index 79e0518..ed52ea3 100644
--- a/src/core/common/WhitespaceHandler.hpp
+++ b/src/core/common/WhitespaceHandler.hpp
@@ -98,6 +98,25 @@ public:
*/
void append(char c, size_t start, size_t end)
{
+ append(c, start, end, textBuf, textStart, textEnd);
+ }
+
+ /**
+ * Static version of PreservingWhitespaceHandler append
+ *
+ * @param c is the character that should be appended to the internal buffer.
+ * @param start is the start byte offset of the given character.
+ * @param end is the end byte offset of the given character.
+ * @param textBuf is a reference at the text buffer that is to be used.
+ * @param textStart is a reference at the text start variable that is to be
+ * used.
+ * @param textEnd is a reference at the text end variable that is to be
+ * used.
+ */
+ static void append(char c, size_t start, size_t end,
+ std::vector<char> &textBuf, size_t &textStart,
+ size_t &textEnd)
+ {
if (textBuf.empty()) {
textStart = start;
}
@@ -130,6 +149,27 @@ public:
*/
void append(char c, size_t start, size_t end)
{
+ append(c, start, end, textBuf, textStart, textEnd, whitespaceBuf);
+ }
+
+ /**
+ * Static version of TrimmingWhitespaceHandler append
+ *
+ * @param c is the character that should be appended to the internal buffer.
+ * @param start is the start byte offset of the given character.
+ * @param end is the end byte offset of the given character.
+ * @param textBuf is a reference at the text buffer that is to be used.
+ * @param textStart is a reference at the text start variable that is to be
+ * used.
+ * @param textEnd is a reference at the text end variable that is to be
+ * used.
+ * @param whitespaceBuf is a reference at the buffer for storing whitespace
+ * characters.
+ */
+ static void append(char c, size_t start, size_t end,
+ std::vector<char> &textBuf, size_t &textStart,
+ size_t &textEnd, std::vector<char> &whitespaceBuf)
+ {
// Handle whitespace characters
if (Utils::isWhitespace(c)) {
if (!textBuf.empty()) {
@@ -175,6 +215,26 @@ public:
*/
void append(char c, size_t start, size_t end)
{
+ append(c, start, end, textBuf, textStart, textEnd, hasWhitespace);
+ }
+
+ /**
+ * Static version of CollapsingWhitespaceHandler append
+ *
+ * @param c is the character that should be appended to the internal buffer.
+ * @param start is the start byte offset of the given character.
+ * @param end is the end byte offset of the given character.
+ * @param textBuf is a reference at the text buffer that is to be used.
+ * @param textStart is a reference at the text start variable that is to be
+ * used.
+ * @param textEnd is a reference at the text end variable that is to be
+ * used.
+ * @param hasWhitespace is a reference at the "hasWhitespace" flag.
+ */
+ static void append(char c, size_t start, size_t end,
+ std::vector<char> &textBuf, size_t &textStart,
+ size_t &textEnd, bool &hasWhitespace)
+ {
// Handle whitespace characters
if (Utils::isWhitespace(c)) {
if (!textBuf.empty()) {