Skip to content

Commit

Permalink
AURORA: Add logic for reading through stream
Browse files Browse the repository at this point in the history
  • Loading branch information
rjshae authored and DrMcCoy committed Oct 28, 2018
1 parent d71793f commit d99d9bc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/aurora/xmlfixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,56 @@ Common::SeekableReadStream *XMLFixer::fixXMLStream(Common::SeekableReadStream &i
* Convert the input stream to a vector of elements.
*/
void XMLFixer::readXMLStream(Common::SeekableReadStream &in) {
Common::UString::iterator it;
Common::UString line, buffer;
bool openTag = false;
bool priorTag = false;

// Read in the header
readXMLHeader(in);

// Cycle through the remaining input stream
while (!in.eos()) {
// Track the previous state
priorTag = openTag;

// Read a line of text
line = Common::readStringLine(in, encoding);
line.trim(); // Trim now for maximum performance benefit

// Check for an end tag
openTag = !isTagClose(line);

/*
* If current element is still open, add line to buffer.
* Otherwise, add completed element to the vectors.
*/
if (openTag) {
// This is a multi-line wrap
if (!priorTag) {
// Starting a new buffer
buffer = line;
} else if (line.size() > 0) {
// Append line to the buffer with a space
buffer += " " + line;
}
} else {
// Check for a multi-line wrap
if (buffer.size() > 0) {
// Finish wrapping the lines
line = buffer + " " + line;
buffer = "";
}

// Only append if line has text
if (line.size() != 0) {
// Append to the vector
}

// Initialize for the next line
priorTag = false;
}
}
}

/**
Expand Down Expand Up @@ -100,4 +148,11 @@ void XMLFixer::readXMLHeader(Common::SeekableReadStream &in) {
header = line.substr(it, line.end());
}

/**
* Return true if the line ends with a closing tag
*/
bool XMLFixer::isTagClose(Common::UString line) {
return true; // TODO
}

} // End of namespace AURORA
1 change: 1 addition & 0 deletions src/aurora/xmlfixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class XMLFixer {
static Common::SeekableReadStream *fixXMLStream(Common::SeekableReadStream &in);

private:
bool isTagClose(Common::UString line);
void readXMLStream(Common::SeekableReadStream &in);
void readXMLHeader(Common::SeekableReadStream &in);
};
Expand Down

0 comments on commit d99d9bc

Please sign in to comment.