libNuML 1.1.1
Library for reading / writing NuML documents
|
The reader class implementing reading NuML documents from file / string. More...
#include <NUMLReader.h>
Public Member Functions | |
NUMLReader () | |
Creates a new NUMLReader and returns it. More... | |
virtual | ~NUMLReader () |
Destroys this NUMLReader. More... | |
NUMLDocument * | readNUML (const std::string &filename) |
Reads an NUML document from a file. More... | |
NUMLDocument * | readNUMLFromFile (const std::string &filename) |
Reads an NUML document from a file. More... | |
NUMLDocument * | readNUMLFromString (const std::string &xml) |
Reads an NUML document from the given XML string. More... | |
Static Public Member Functions | |
static bool | hasZlib () |
Predicate returning true or false depending on whether libNUML is linked with zlib at compile time. More... | |
static bool | hasBzip2 () |
Predicate returning true or false depending on whether libNUML is linked with bzip2 at compile time. More... | |
Protected Member Functions | |
NUMLDocument * | readInternal (const char *content, bool isFile=true) |
Used by readNUML() and readNUMLFromString(). More... | |
The reader class implementing reading NuML documents from file / string.
LIBNUML_CPP_NAMESPACE_BEGIN NUMLReader::NUMLReader | ( | ) |
Creates a new NUMLReader and returns it.
|
virtual |
Destroys this NUMLReader.
|
static |
Predicate returning true
or false
depending on whether libNUML is linked with bzip2 at compile time.
Predicate returning true
or false
depending on whether libNUML is linked with bzip2.
true
if bzip2 is linked, false
otherwise.true
if libNUML is linked with bzip2, false
otherwise.
|
static |
Predicate returning true
or false
depending on whether libNUML is linked with zlib at compile time.
Predicate returning true
or false
depending on whether libNUML is linked with zlib.
true
if zlib is linked, false
otherwise.true
if libNUML is linked with zlib, false
otherwise.
|
protected |
Used by readNUML() and readNUMLFromString().
@docnote The native C++ implementation of this method defines a default argument value. In the documentation generated for different libNUML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libNUML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.
TODO d->setModel(NULL);
NUMLDocument * NUMLReader::readNUML | ( | const std::string & | filename | ) |
Reads an NUML document from a file.
If the file named filename
does not exist or its content is not valid NUML, one or more errors will be logged with the NUMLDocument object returned by this method. Callers can use the methods on NUMLDocument such as NUMLDocument::getNumErrors() and to get the errors. The object returned by is an NUMLError object, and it has methods to get the error code, category, and severity level of the problem, as well as a textual description of the problem. The possible severity levels range from informational messages to fatal errors; see the documentation for NUMLError for more information.
If the file filename
could not be read, the file-reading error will appear first. The error code can provide a clue about what happened. For example, a file might be unreadable (either because it does not actually exist or because the user does not have the necessary access priviledges to read it) or some sort of file operation error may have bee reported by the underlying operating system. Callers can check for these situations using code such as the following:
If the given filename ends with the suffix ".gz"
(for example, "myfile.xml.gz"
), the file is assumed to be compressed in gzip format and will be automatically decompressed upon reading. Similarly, if the given filename ends with ".zip"
or ".bz2"
, the file is assumed to be compressed in zip or bzip2 format (respectively). Files whose names lack these suffixes will be read uncompressed. Note that if the file is in zip format but the archive contains more than one file, only the first file in the archive will be read and the rest ignored.
filename | the name or full pathname of the file to be read. |
NUMLDocument * NUMLReader::readNUMLFromFile | ( | const std::string & | filename | ) |
Reads an NUML document from a file.
If the file named filename
does not exist or its content is not valid NUML, one or more errors will be logged with the NUMLDocument object returned by this method. Callers can use the methods on NUMLDocument such as NUMLDocument::getNumErrors() and to get the errors. The object returned by is an NUMLError object, and it has methods to get the error code, category, and severity level of the problem, as well as a textual description of the problem. The possible severity levels range from informational messages to fatal errors; see the documentation for NUMLError for more information.
If the file filename
could not be read, the file-reading error will appear first. The error code can provide a clue about what happened. For example, a file might be unreadable (either because it does not actually exist or because the user does not have the necessary access priviledges to read it) or some sort of file operation error may have bee reported by the underlying operating system. Callers can check for these situations using code such as the following:
If the given filename ends with the suffix ".gz"
(for example, "myfile.xml.gz"
), the file is assumed to be compressed in gzip format and will be automatically decompressed upon reading. Similarly, if the given filename ends with ".zip"
or ".bz2"
, the file is assumed to be compressed in zip or bzip2 format (respectively). Files whose names lack these suffixes will be read uncompressed. Note that if the file is in zip format but the archive contains more than one file, only the first file in the archive will be read and the rest ignored.
filename | the name or full pathname of the file to be read. |
NUMLDocument * NUMLReader::readNUMLFromString | ( | const std::string & | xml | ) |
Reads an NUML document from the given XML string.
This method is flexible with respect to the presence of an XML declaration at the beginning of the string. In particular, if the string in xml
does not begin with the XML declaration <?xml version='1.0' encoding='UTF-8'?>
, then this method will automatically prepend the declaration to xml
.
This method will log a fatal error if the content given in the parameter xml
is not NUML. See the method documentation for for an example of code for testing the returned error code.
xml | a string containing a full NUML model |