libAlgAudio
v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
|
#include <CanvasXML.hpp>
Public Member Functions | |
LateReturn< std::shared_ptr < Canvas > > | ApplyToCanvas (std::shared_ptr< Canvas > c) |
void | CloneToAnotherXMLTree (rapidxml::xml_node<> *node, rapidxml::xml_document<> *doc) |
LateReturn< std::shared_ptr < Canvas > > | CreateNewCanvas (std::shared_ptr< Canvas > parent) |
std::string | GetXMLAsString () |
void | SaveToFile (std::string path) |
~CanvasXML () | |
Static Public Member Functions | |
static std::shared_ptr< CanvasXML > | CreateFromCanvas (std::shared_ptr< Canvas > canvas) |
static std::shared_ptr< CanvasXML > | CreateFromFile (std::string path) |
static std::shared_ptr< CanvasXML > | CreateFromNode (rapidxml::xml_node<> *node) |
static std::shared_ptr< CanvasXML > | CreateFromString (std::string string) |
An instanceable class that exports canvas state to an XML document, and vice versa. A CanvasXML maintains an XML document, which can be loaded from a file or created according to canvas state, as well as saved to file or applied to a Canvas.
To open a file to a new Canvas, you would usually cretate a CanvasXML with CreateFromFile(), and then use CreateNewCanvas() member function.
To save a Canvas to file, you should create a CanvasXML with CreateFromCanvas, and then use SaveToFile() member function.
AlgAudio::CanvasXML::~CanvasXML | ( | ) |
LateReturn<std::shared_ptr<Canvas> > AlgAudio::CanvasXML::ApplyToCanvas | ( | std::shared_ptr< Canvas > | c | ) |
Applies the data in stored document to a given Canvas, creating new modules, setting params, adding connections etc. On success, latereturns the same canvas pointer. Never returns a nullptr. May latethrow Exceptions::XMLParse.
|
inline |
Puts the stored XML document as a subtree of some other rapidxml document. All data is fully cloned, so it's safe to destruct this CanvasXML instance and continue using the parent xml document.
node | The subtree node the stored document shall be placed at. |
doc | The xml_document the node is in. |
|
static |
Opens the file at the given path, reads the contents, parses the XML document, and creates a new CanvasXML using that data.
path | The path to file to load. |
|
static |
Uses the given rapidxml XML node to create a new CanvasXML. The node data will be fully cloned, so it's safe to delete the node afterwards.
|
static |
Parses the given string as an XML document, and creates a new CanvasXML which uses that data.
LateReturn<std::shared_ptr<Canvas> > AlgAudio::CanvasXML::CreateNewCanvas | ( | std::shared_ptr< Canvas > | parent | ) |
Creates a new canvas basing on the stored document. Never returns a nullptr. May latethrow Exceptions::XMLParse.
std::string AlgAudio::CanvasXML::GetXMLAsString | ( | ) |
Returns the stored XML document as a string.
void AlgAudio::CanvasXML::SaveToFile | ( | std::string | path | ) |
Stores the XML document in a file.
path | The path to file the XML document shall be saved to. |