summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-08 19:01:34 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-08 19:01:34 +0100
commitf6e7859a835375c25226719a46df99ec11037599 (patch)
tree54ae633d3f339f232d43a5c46282b0c87dd3c8b9 /src/plugins
parent51f09f4faa7cd4b6a0576758881d322e31e896ba (diff)
added some comments
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plain/PlainFormatStreamReader.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/plugins/plain/PlainFormatStreamReader.cpp b/src/plugins/plain/PlainFormatStreamReader.cpp
index f0721a0..498cd43 100644
--- a/src/plugins/plain/PlainFormatStreamReader.cpp
+++ b/src/plugins/plain/PlainFormatStreamReader.cpp
@@ -25,16 +25,49 @@
namespace ousia {
namespace {
-struct DataHandler {
+
+/**
+ * Class used internally to collect data issued via "DATA" event.
+ */
+class DataHandler {
+private:
+ /**
+ * Internal character buffer.
+ */
std::vector<char> buf;
+ /**
+ * Start location of the character data.
+ */
SourceOffset start;
+
+ /**
+ * End location of the character data.
+ */
SourceOffset end;
+public:
+
+ /**
+ * Default constructor, initializes start and end with zeros.
+ */
DataHandler() : start(0), end(0) {}
+ /**
+ * Returns true if the internal buffer is empty.
+ *
+ * @return true if no characters were added to the internal buffer, false
+ * otherwise.
+ */
bool isEmpty() { return buf.empty(); }
+ /**
+ * Appends a single character to the internal buffer.
+ *
+ * @param c is the character that should be added to the internal buffer.
+ * @param charStart is the start position of the character.
+ * @param charEnd is the end position of the character.
+ */
void append(char c, SourceOffset charStart, SourceOffset charEnd)
{
if (isEmpty()) {
@@ -44,6 +77,13 @@ struct DataHandler {
end = charEnd;
}
+ /**
+ * Appends a string to the internal buffer.
+ *
+ * @param s is the string that should be added to the internal buffer.
+ * @param stringStart is the start position of the string.
+ * @param stringEnd is the end position of the string.
+ */
void append(const std::string &s, SourceOffset stringStart,
SourceOffset stringEnd)
{
@@ -54,6 +94,15 @@ struct DataHandler {
end = stringEnd;
}
+ /**
+ * Converts the internal buffer to a variant with attached location
+ * information.
+ *
+ * @param sourceId is the source id which is needed for building the
+ * location information.
+ * @return a Variant with the internal buffer content as string and
+ * the correct start and end location.
+ */
Variant toVariant(SourceId sourceId)
{
Variant res = Variant::fromString(std::string(buf.data(), buf.size()));