libxspf  1.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
XspfWriter Class Reference

#include <XspfWriter.h>

Public Member Functions

 XspfWriter (XspfWriter const &source)
 
XspfWriteroperator= (XspfWriter const &source)
 
 ~XspfWriter ()
 
bool registerNamespace (XML_Char const *uri, XML_Char const *prefixSuggestion)
 
bool addTrack (XspfTrack const *track)
 
bool addTrack (XspfTrack const &track)
 
bool setProps (XspfProps const *props)
 
bool setProps (XspfProps const &props)
 
int writeFile (XML_Char const *filename)
 
int writeMemory (char *&memory, int &numBytes)
 
void reset (XspfXmlFormatter &formatter, XML_Char const *baseUri, bool embedBase=false)
 

Static Public Member Functions

static XspfWritermakeWriter (XspfXmlFormatter &formatter, XML_Char const *baseUri, bool embedBase=false, int *errorCode=NULL)
 

Static Public Attributes

static bool const EMBED_AS_XML_BASE
 Base URI is embedded into the document.
 
static bool const NO_XML_BASE
 Base URI is not embedded into the document.
 

Detailed Description

Writes a playlist as XSPF to a file. XSPF version 0 and 1 are supported.

Definition at line 75 of file XspfWriter.h.

Constructor & Destructor Documentation

◆ XspfWriter()

XspfWriter ( XspfWriter const &  source)

Copy constructor.

Parameters
sourceSource to copy from

◆ ~XspfWriter()

~XspfWriter ( )

Frees all own memory.

Member Function Documentation

◆ addTrack() [1/2]

bool addTrack ( XspfTrack const *  track)

Appends a track to the playlist. The track instance passed can be safely deleted after the call returns.

Parameters
trackTrack to append
Returns
Success flag
Since
1.0.0

◆ addTrack() [2/2]

bool addTrack ( XspfTrack const &  track)

Appends a track to the playlist. The track instance passed can be safely deleted after the call returns.

Parameters
trackTrack to append
Returns
Success flag
Since
1.0.0

◆ makeWriter()

static XspfWriter* makeWriter ( XspfXmlFormatter formatter,
XML_Char const *  baseUri,
bool  embedBase = false,
int *  errorCode = NULL 
)
static

Creates a new playlist writer.

Parameters
formatterXML formatter to use
baseUriAbsolute base URI to reduce against, pass NULL to keep all URIs absolute
embedBaseEmbeds base URI as xml:base in root node if true or not if false
errorCodePlace to write error code or XSPF_WRITER_SUCCESS to.
Returns
NULL on error or a new'ed XspfWriter that you have to delete manually later.
Since
1.0.0

◆ operator=()

XspfWriter& operator= ( XspfWriter const &  source)

Assignment operator.

Parameters
sourceSource to copy from

◆ registerNamespace()

bool registerNamespace ( XML_Char const *  uri,
XML_Char const *  prefixSuggestion 
)

Pre-registers a namespace so it can still appear in the root element.

Attention
registerNamespace() must be called before any calls to setProps() or addTrack().
Parameters
uriNamespace URI
prefixSuggestionSuggested prefix
Returns
Success flag

◆ reset()

void reset ( XspfXmlFormatter formatter,
XML_Char const *  baseUri,
bool  embedBase = false 
)

Clears all previously added tracks and makes the writer reusable by another playlist.

Parameters
formatterXML formatter to use
baseUriAbsolute base URI to reduce against.
embedBaseEmbeds base URI as xml:base in root node if true or not if false
Since
1.0.0

◆ setProps() [1/2]

bool setProps ( XspfProps const *  props)

Sets playlist-wide properties of the playlist to be written including the version of XSPF to be used. The props instance passed can be safely deleted after the call returns.

Attention
setProps() must be called before any calls to addTrack().
Parameters
propsPlaylist properties to set, can be NULL
Returns
Success flag
Since
1.0.0

◆ setProps() [2/2]

bool setProps ( XspfProps const &  props)

Sets playlist-wide properties of the playlist to be written including the version of XSPF to be used. The props instance passed can be safely deleted after the call returns.

Attention
setProps() must be called before any calls to addTrack().
Parameters
propsPlaylist properties to set, can be NULL
Returns
Success flag
Since
1.0.0

◆ writeFile()

int writeFile ( XML_Char const *  filename)

Finalizes the playlist and writes it to a file. You can call this method several times to write the same playlist to several files but you cannot add new tracks anymore. Call reset() to start over.

Parameters
filenameFilename of the file to write to
Returns
Error code

◆ writeMemory()

int writeMemory ( char *&  memory,
int &  numBytes 
)

Finalizes the playlist and writes it to a block of memory. You can call this method several times to write the same playlist to several files but you cannot add new tracks anymore. Call reset() to start over.

Parameters
memoryReference to output memory block, delete[] on your own
numBytesSize of the memory block in bytes
Returns
Error code

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