/** * Writes the given NUML document to an in-memory string and returns a * pointer to it. The string is owned by the caller and should be freed * (with free()) when no longer needed. This convenience function is * functionally equivalent to: * * NUMLWriter_writeNUMLToString(NUMLWriter_create(), d); * * @return the string on success and NULL if one of the underlying parser * components fail (rare). */ LIBNUML_EXTERN char * writeNUMLToString (const NUMLDocument_t *d) { NUMLWriter sw; return sw.writeToString(d); }
/** * Writes the given NUML document to filename. This convenience function * is functionally equivalent to: * * NUMLWriter_writeNUML(NUMLWriter_create(), d, filename); * * @return non-zero on success and zero if the filename could not be opened * for writing. */ LIBNUML_EXTERN int writeNUML (const NUMLDocument_t *d, const char *filename) { NUMLWriter sw; return static_cast<int>( sw.writeNUML(d, filename) ); }
/** * * Writes the given NUMLDocument to the given file. * */ bool writeExampleNUML(const NUMLDocument* numlDoc, const string& filename) { NUMLWriter numlWriter; bool result = numlWriter.writeNUML(numlDoc, filename); if (result) { cout << "Wrote file \"" << filename << "\"" << endl; return true; } else { cerr << "Failed to write \"" << filename << "\"" << endl; return false; } }