![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
A minimal XML DOM: read for the .lqnx interchange format, write for the JMT .jsimg and .jmva model files. More...
#include <cctype>#include <fstream>#include <memory>#include <sstream>#include <string>#include <vector>#include "line/util/error.h"Go to the source code of this file.
Classes | |
| struct | line::xml::Element |
Namespaces | |
| namespace | line |
| namespace | line::xml |
Functions | |
| std::unique_ptr< Element > | line::xml::parse (const std::string &text) |
| Parse a whole XML document and return its root element. | |
| std::unique_ptr< Element > | line::xml::parse_file (const std::string &path) |
| Read and parse a file. | |
| std::unique_ptr< Element > | line::xml::element (const std::string &tag) |
| A fresh detached element, the createElement of the write side. | |
| std::string | line::xml::serialize (const Element &root) |
| Serialize a document: the XML declaration MATLAB's xmlwrite emits, then the root subtree. | |
| void | line::xml::write_file (const std::string &path, const Element &root) |
| Serialize to a file, creating or truncating it. | |
A minimal XML DOM: read for the .lqnx interchange format, write for the JMT .jsimg and .jmva model files.
cpp/third_party carries doctest and nlohmann/json, both MIT, and nothing else; adding a full XML library for one input format would be a heavier dependency than the format warrants. The .lqnx grammar LINE emits and consumes uses only elements, attributes, character data and comments, with no namespaces to resolve, no DTD, no entity declarations and no processing instructions other than the leading declaration. That is what this parses.
The DOM mirrors the two org.w3c.dom operations MATLAB's parseXML uses: getAttribute (absent attribute reads as the empty string) and getElementsByTagName (a DESCENDANT search, not a child search – this distinction matters: parseXML relies on it to reach task elements nested inside processor, and separately guards against it with an explicit parent-name test when collecting activity under task-activities).
REFUSES rather than guesses: an unterminated tag, a mismatched close tag or an unquoted attribute value is an InputError. A silently mis-parsed model would produce a solvable network with the wrong topology, which is worse than no answer.
The write side mirrors the four org.w3c.dom operations the JMT writers use – createElement, setAttribute, appendChild and createTextNode – and serializes with serialize. TEXT-ONLY ELEMENTS ARE EMITTED INLINE, with no indentation inside the tags: JMT reads <value> bodies with Double.parseDouble and a newline plus leading spaces around the number is not what MATLAB's xmlwrite produces either. Mixed content (text alongside child elements) does not occur in either grammar and is not represented.
Definition in file xml.h.