Arduino DLNA Server
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tiny_dlna::XMLParserPrint Class Reference

Helper class that implements a Print interface to accumulate XML data and then parse it using XMLParser. More...

#include <XMLParserPrint.h>

Inheritance diagram for tiny_dlna::XMLParserPrint:
Inheritance graph
[legend]

Classes

struct  CBRef
 Internal callback reference used to capture the callback data from XMLParser and forward it to the caller. More...
 

Public Member Functions

 XMLParserPrint ()
 Constructor.
 
size_t write (uint8_t ch) override
 Writes a single byte to the buffer (Print interface)
 
size_t write (const uint8_t *data, size_t size) override
 Writes a block of data to the buffer (Print interface)
 
void setExpandEncoded (bool flag)
 Forwards expand-entities setting to the underlying XMLParser.
 
bool parse (Str &outNodeName, Vector< Str > &outPath, Str &outText, Str &outAttributes)
 Parses the accumulated XML data and returns results via output parameters.
 
void end ()
 Resets the internal buffer.
 
const char * c_str ()
 Returns the internal buffer as a C string.
 
size_t length ()
 Returns the length of the internal buffer.
 

Static Protected Member Functions

static void wrapperCallback (Str &nodeName, Vector< Str > &path, Str &text, Str &attributes, int start, int len, void *ref)
 Static wrapper used as XMLParser callback. Copies the first invocation's data into the CBRef and forwards the event to the user-provided callback if present.
 

Protected Attributes

StrPrint buffer
 Internal buffer for accumulating XML data.
 
XMLParser p
 XMLParser instance used for parsing.
 
struct tiny_dlna::XMLParserPrint::CBRef cbref
 

Detailed Description

Helper class that implements a Print interface to accumulate XML data and then parse it using XMLParser.

This class allows you to write XML data using the Print interface, accumulate it in an internal buffer, and then parse the buffer using an XMLParser. The parsing result is returned via output parameters.

Constructor & Destructor Documentation

◆ XMLParserPrint()

tiny_dlna::XMLParserPrint::XMLParserPrint ( )
inline

Constructor.

Member Function Documentation

◆ c_str()

const char * tiny_dlna::XMLParserPrint::c_str ( )
inline

Returns the internal buffer as a C string.

Returns
Pointer to buffer data

◆ end()

void tiny_dlna::XMLParserPrint::end ( )
inline

Resets the internal buffer.

◆ length()

size_t tiny_dlna::XMLParserPrint::length ( )
inline

Returns the length of the internal buffer.

Returns
Buffer length

◆ parse()

bool tiny_dlna::XMLParserPrint::parse ( Str outNodeName,
Vector< Str > &  outPath,
Str outText,
Str outAttributes 
)
inline

Parses the accumulated XML data and returns results via output parameters.

Parameters
outNodeNameOutput: node name
outPathOutput: path vector
outTextOutput: text content
outAttributesOutput: attributes string
Returns
True if parsing was successful, false otherwise

◆ setExpandEncoded()

void tiny_dlna::XMLParserPrint::setExpandEncoded ( bool  flag)
inline

Forwards expand-entities setting to the underlying XMLParser.

Parameters
flagIf true, expand encoded entities

◆ wrapperCallback()

static void tiny_dlna::XMLParserPrint::wrapperCallback ( Str nodeName,
Vector< Str > &  path,
Str text,
Str attributes,
int  start,
int  len,
void *  ref 
)
inlinestaticprotected

Static wrapper used as XMLParser callback. Copies the first invocation's data into the CBRef and forwards the event to the user-provided callback if present.

Parameters
nodeNameName of the node
pathPath vector
textText content
attributesAttributes string
startStart position
lenLength
refReference to CBRef

◆ write() [1/2]

size_t tiny_dlna::XMLParserPrint::write ( const uint8_t *  data,
size_t  size 
)
inlineoverride

Writes a block of data to the buffer (Print interface)

Parameters
dataPointer to data
sizeNumber of bytes to write
Returns
Number of bytes written

◆ write() [2/2]

size_t tiny_dlna::XMLParserPrint::write ( uint8_t  ch)
inlineoverride

Writes a single byte to the buffer (Print interface)

Parameters
chByte to write
Returns
Number of bytes written

Member Data Documentation

◆ buffer

StrPrint tiny_dlna::XMLParserPrint::buffer
protected

Internal buffer for accumulating XML data.

◆ cbref

struct tiny_dlna::XMLParserPrint::CBRef tiny_dlna::XMLParserPrint::cbref
protected

◆ p

XMLParser tiny_dlna::XMLParserPrint::p
protected

XMLParser instance used for parsing.


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