LMMS
Loading...
Searching...
No Matches
zyncarla::XMLwrapper Class Reference

#include <XMLwrapper.h>

Public Member Functions

 XMLwrapper ()
 ~XMLwrapper ()
int saveXMLfile (const std::string &filename, int compression) const
char * getXMLdata () const
void addpar (const std::string &name, int val)
void addparreal (const std::string &name, float val)
void addparbool (const std::string &name, int val)
void addparstr (const std::string &name, const std::string &val)
void beginbranch (const std::string &name)
void beginbranch (const std::string &name, int id)
void endbranch ()
int loadXMLfile (const std::string &filename)
bool putXMLdata (const char *xmldata)
int enterbranch (const std::string &name)
int enterbranch (const std::string &name, int id)
void exitbranch ()
int getbranchid (int min, int max) const
int getpar (const std::string &name, int defaultpar, int min, int max) const
int getpar127 (const std::string &name, int defaultpar) const
int getparbool (const std::string &name, int defaultpar) const
void getparstr (const std::string &name, char *par, int maxstrlen) const
std::string getparstr (const std::string &name, const std::string &defaultpar) const
float getparreal (const char *name, float defaultpar) const
float getparreal (const char *name, float defaultpar, float min, float max) const
void setPadSynth (bool enabled)
bool hasPadSynth () const
void add (const XmlNode &node)
std::vector< XmlNodegetBranch (void) const
const version_typefileversion () const

Public Attributes

bool minimal
version_type _fileversion

Private Member Functions

int dosavefile (const char *filename, int compression, const char *xmldata) const
char * doloadfile (const std::string &filename) const
void cleanup (void)
mxml_node_t * addparams (const char *name, unsigned int params,...) const

Private Attributes

mxml_node_t * tree
mxml_node_t * root
mxml_node_t * node
mxml_node_t * info

Detailed Description

Mxml wrapper

Constructor & Destructor Documentation

◆ XMLwrapper()

XMLwrapper::XMLwrapper ( )

Constructor. Will Construct the object and fill in top level branch

◆ ~XMLwrapper()

XMLwrapper::~XMLwrapper ( )

Destructor

Member Function Documentation

◆ add()

void zyncarla::XMLwrapper::add ( const XmlNode & node)

◆ addpar()

void XMLwrapper::addpar ( const std::string & name,
int val )

Add simple parameter.

Parameters
nameThe name of the mXML node.
valThe string value of the mXml node

◆ addparams()

mxml_node_t * XMLwrapper::addparams ( const char * name,
unsigned int params,
... ) const
private

Create mxml_node_t with specified name and parameters

Results should look like: <name optionalParam1="value1" optionalParam2="value2" ...>

Parameters
nameThe name of the xml node
paramsThe number of the attributes
...const char * pairs that are in the format attribute_name, attribute_value

Private members

Todo
make this function send out a good error message if something goes wrong

◆ addparbool()

void XMLwrapper::addparbool ( const std::string & name,
int val )

Add boolean parameter.

Todo
Fix this reverse boolean logic.
Parameters
nameThe name of the mXML node.
valThe boolean value of the node (0->"yes";else->"no").

◆ addparreal()

void XMLwrapper::addparreal ( const std::string & name,
float val )

Adds a realtype parameter.

Parameters
nameThe name of the mXML node.
valThe float value of the node.

◆ addparstr()

void XMLwrapper::addparstr ( const std::string & name,
const std::string & val )

Add string parameter.

Parameters
nameThe name of the mXML node.
valThe string value of the node.

◆ beginbranch() [1/2]

void zyncarla::XMLwrapper::beginbranch ( const std::string & name)

Create a new branch.

Parameters
nameName of new branch
See also
void endbranch()

◆ beginbranch() [2/2]

void zyncarla::XMLwrapper::beginbranch ( const std::string & name,
int id )

Create a new branch.

Parameters
nameName of new branch
id"id" value of branch
See also
void endbranch()

◆ cleanup()

void zyncarla::XMLwrapper::cleanup ( void )
private

Cleanup XML tree before loading new one.

◆ doloadfile()

char * XMLwrapper::doloadfile ( const std::string & filename) const
private

Loads specified file and returns data.

Will load a gziped file or an uncompressed file.

Parameters
filenamethe file
Returns
The decompressed data

◆ dosavefile()

int XMLwrapper::dosavefile ( const char * filename,
int compression,
const char * xmldata ) const
private

Save the file.

Parameters
filenameFile to save to
compressionLevel of gzip compression
xmldataString to be saved

◆ endbranch()

void XMLwrapper::endbranch ( )

Closes new branches. This must be called to exit each branch created by beginbranch( ).

See also
void beginbranch(const std::string &name)
void beginbranch(const std::string &name, int id)

◆ enterbranch() [1/2]

int zyncarla::XMLwrapper::enterbranch ( const std::string & name)

Enters the branch.

Parameters
nameName of branch.
Returns
1 if is ok, or 0 otherwise.

◆ enterbranch() [2/2]

int zyncarla::XMLwrapper::enterbranch ( const std::string & name,
int id )

Enter into the branch name with id id.

Parameters
nameName of branch.
idValue of branch's "id".
Returns
1 if is ok, or 0 otherwise.

◆ exitbranch()

void XMLwrapper::exitbranch ( )

Exits from a branch

◆ fileversion()

const version_type & zyncarla::XMLwrapper::fileversion ( ) const
inline

◆ getBranch()

std::vector< XmlNode > zyncarla::XMLwrapper::getBranch ( void ) const

◆ getbranchid()

int XMLwrapper::getbranchid ( int min,
int max ) const

Get the the branch_id and limits it between the min and max. if min==max==0, it will not limit it if there isn't any id, will return min this must be called only imediately after enterbranch()

◆ getpar()

int XMLwrapper::getpar ( const std::string & name,
int defaultpar,
int min,
int max ) const

Returns the integer value stored in node name. It returns the integer value between the limits min and max. If min==max==0, then the value will not be limited. If there is no location named name, then defaultpar will be returned.

Parameters
nameThe parameter name.
defaultparThe default value if the real value is not found.
minThe minimum return value.
maxThe maximum return value.

◆ getpar127()

int XMLwrapper::getpar127 ( const std::string & name,
int defaultpar ) const

Returns the integer value stored in the node with range [0,127].

Parameters
nameThe parameter name.
defaultparThe default value if the real value is not found.

◆ getparbool()

int XMLwrapper::getparbool ( const std::string & name,
int defaultpar ) const

Returns the boolean value stored in the node.

Parameters
nameThe parameter name.
defaultparThe default value if the real value is not found.

◆ getparreal() [1/2]

float XMLwrapper::getparreal ( const char * name,
float defaultpar ) const

Returns the real value stored in the node.

Parameters
nameThe parameter name.
defaultparThe default value if the real value is not found.

◆ getparreal() [2/2]

float XMLwrapper::getparreal ( const char * name,
float defaultpar,
float min,
float max ) const

Returns the real value stored in the node.

Parameters
nameThe parameter name.
defaultparThe default value if the real value is not found.
minThe minimum value
maxThe maximum value

◆ getparstr() [1/2]

void zyncarla::XMLwrapper::getparstr ( const std::string & name,
char * par,
int maxstrlen ) const

Get the string value stored in the node.

Parameters
nameThe parameter name.
parPointer to destination string
maxstrlenMax string length for destination

◆ getparstr() [2/2]

std::string zyncarla::XMLwrapper::getparstr ( const std::string & name,
const std::string & defaultpar ) const

Get the string value stored in the node.

Parameters
nameThe parameter name.
defaultparThe default value if the real value is not found.

◆ getXMLdata()

char * XMLwrapper::getXMLdata ( ) const

Return XML tree as a string. Note: The string must be freed with free() to deallocate

Returns
a newly allocated NULL terminated string of the XML data.

◆ hasPadSynth()

bool XMLwrapper::hasPadSynth ( ) const

Checks the current tree for PADsynth usage

Right now this has a copied implementation of setparbool, so this should be reworked as XMLwrapper evolves

◆ loadXMLfile()

int XMLwrapper::loadXMLfile ( const std::string & filename)

Loads file into XMLwrapper.

Parameters
filenamefile to be loaded
Returns
0 if ok or -1 if the file cannot be loaded

◆ putXMLdata()

bool XMLwrapper::putXMLdata ( const char * xmldata)

Loads string into XMLwrapper.

Parameters
xmldataNULL terminated string of XML data.
Returns
true if successful.

◆ saveXMLfile()

int XMLwrapper::saveXMLfile ( const std::string & filename,
int compression ) const

Saves the XML to a file.

Parameters
filenamethe name of the destination file.
Returns
0 if ok or -1 if the file cannot be saved.

◆ setPadSynth()

void XMLwrapper::setPadSynth ( bool enabled)

Sets the current tree's PAD Synth usage

Bug
this might create multiple nodes when only one is needed

Member Data Documentation

◆ _fileversion

version_type zyncarla::XMLwrapper::_fileversion

◆ info

mxml_node_t* zyncarla::XMLwrapper::info
private

Node used to store the information about the data

◆ minimal

bool zyncarla::XMLwrapper::minimal

false if all parameters will be stored (used only for clipboard)

◆ node

mxml_node_t* zyncarla::XMLwrapper::node
private

current subtree in parsing or writing

◆ root

mxml_node_t* zyncarla::XMLwrapper::root
private

xml data used by zynaddsubfx

◆ tree

mxml_node_t* zyncarla::XMLwrapper::tree
private

all xml data


The documentation for this class was generated from the following files: