MUSX Document Model
Loading...
Searching...
No Matches
musx::factory::DocumentFactory Class Reference

Factory class for creating Document objects from XML. More...

#include <DocumentFactory.h>

+ Inheritance diagram for musx::factory::DocumentFactory:

Classes

struct  CreateOptions
 Optional arguments for document creation. More...
 

Public Types

template<typename Container >
using IsCharContainer = std::enable_if_t<(sizeof(std::remove_cv_t< typename Container::value_type >)==1) &&!std::is_same_v< std::remove_cv_t< typename Container::value_type >, bool > >
 SFINAE helper for containers whose element type is 1 byte (excluding bool).
 

Static Public Member Functions

template<typename XmlDocumentType >
static DocumentPtr create (const char *data, size_t size)
 Creates a Document object from an XML buffer.
 
template<typename XmlDocumentType , typename Container , typename = IsCharContainer<Container>>
static DocumentPtr create (const Container &xmlBuffer)
 Creates a Document object from a char container (e.g. std::string, std::vector<char>).
 
template<typename XmlDocumentType >
static DocumentPtr create (const char *data, size_t size, CreateOptions &&createOptions)
 Creates a Document object from an XML buffer.
 
template<typename XmlDocumentType , typename Container , typename = IsCharContainer<Container>>
static DocumentPtr create (const Container &xmlBuffer, CreateOptions &&createOptions)
 Creates a Document object from a char container and explicit create options.
 

Detailed Description

Factory class for creating Document objects from XML.

Member Function Documentation

◆ create() [1/2]

template<typename XmlDocumentType >
static DocumentPtr musx::factory::DocumentFactory::create ( const char *  data,
size_t  size 
)
inlinestatic

Creates a Document object from an XML buffer.

Parameters
dataPointer to a buffer containing EnigmaXML for a musx file.
sizeThe size of the buffer.
Returns
A fully populated Document object.
Exceptions
std::invalid_argumentIf required nodes or attributes are missing or invalid.

◆ create() [2/2]

template<typename XmlDocumentType >
static DocumentPtr musx::factory::DocumentFactory::create ( const char *  data,
size_t  size,
CreateOptions &&  createOptions 
)
inlinestatic

Creates a Document object from an XML buffer.

Parameters
dataPointer to a buffer containing EnigmaXML for a musx file.
sizeThe size of the buffer.
createOptionsOptional creation options, including part voicing policy and NotationMetadata.xml data.
Returns
A fully populated Document object.
Exceptions
std::invalid_argumentIf required nodes or attributes are missing or invalid.