Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Friends | List of all members
Mezzanine::XML::NodeText Class Reference

A helper for working with text inside PCDATA nodes. More...

#include <nodetext.h>

Public Member Functions

 NodeText ()
 Default constructor. Constructs an empty object.
 
bool AsBool (bool def=false) const
 Get text as bool. More...
 
double AsDouble (double def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
float AsFloat (float def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
int AsInt (int def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
Integer AsInteger (Integer def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
Real AsReal (Real def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
const Char8AsString (const Char8 *def="") const
 Get text, or the default Value if object is empty. More...
 
unsigned int AsUint (unsigned int def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
Whole AsWhole (Whole def=0) const
 Get text as a number, or the default Value if conversion did not succeed or object is empty. More...
 
Node data () const
 Get the data node (NodePcdata or NodeCdata) for this object. More...
 
bool Empty () const
 Is this storing anything at all? More...
 
const Char8GetString () const
 Get text, or "" if object is empty. More...
 
 operator unspecified_bool_type () const
 Used to convert this to a boolean value in a safe way. More...
 
bool operator! () const
 Used to convert this attribute the opposite of it's normal boolean value. More...
 
NodeTextoperator= (const Char8 *rhs)
 Set text (equivalent to set without error checking) More...
 
NodeTextoperator= (int rhs)
 Set text (equivalent to set without error checking) by lexigraphically converting rhs. More...
 
NodeTextoperator= (unsigned int rhs)
 Set text (equivalent to set without error checking) by lexigraphically converting rhs. More...
 
NodeTextoperator= (double rhs)
 Set text (equivalent to set without error checking) by lexigraphically converting rhs. More...
 
NodeTextoperator= (bool rhs)
 Set text (equivalent to set without error checking)by converting value to "true"/"false". More...
 
bool Set (const Char8 *rhs)
 Set text. More...
 
bool Set (int rhs)
 Set text by lexigraphically converting rhs. More...
 
bool Set (unsigned int rhs)
 Set text by lexigraphically converting rhs. More...
 
bool Set (double rhs)
 Set text by lexigraphically converting rhs. More...
 
bool Set (bool rhs)
 Set text by converting value to "true"/"false". More...
 

Friends

class Node
 

Detailed Description

A helper for working with text inside PCDATA nodes.

Definition at line 73 of file nodetext.h.

Member Function Documentation

bool Mezzanine::XML::NodeText::AsBool ( bool  def = false) const

Get text as bool.

Parameters
defThe default value to return if conversion is not possible.
Returns
True if first character is in '1tTyY' set), or the default Value if object is empty.
double Mezzanine::XML::NodeText::AsDouble ( double  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as a double or def if the text is invalid for conversion or generates an error.
float Mezzanine::XML::NodeText::AsFloat ( float  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as a float or def if the text is invalid for conversion or generates an error.
int Mezzanine::XML::NodeText::AsInt ( int  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as an int or def if the text is invalid for conversion or generates an error.
Integer Mezzanine::XML::NodeText::AsInteger ( Integer  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as a Mezzanine::Integer or def if the text is invalid for conversion or generates an error.
Real Mezzanine::XML::NodeText::AsReal ( Real  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as a Mezzanine::Real or def if the text is invalid for conversion or generates an error.
const Char8* Mezzanine::XML::NodeText::AsString ( const Char8 def = "") const

Get text, or the default Value if object is empty.

Parameters
defThe value to be returned if there is no valid return
Returns
This will return The content of this node or def
unsigned int Mezzanine::XML::NodeText::AsUint ( unsigned int  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as an unisgned int or def if the text is invalid for conversion or generates an error.
Whole Mezzanine::XML::NodeText::AsWhole ( Whole  def = 0) const

Get text as a number, or the default Value if conversion did not succeed or object is empty.

Parameters
defThe value To be returned if an error occurs in conversion, like a an out of memory condition.
Returns
The value in this NodeText as a Mezzanine::Whole or def if the text is invalid for conversion or generates an error.
Node Mezzanine::XML::NodeText::data ( ) const

Get the data node (NodePcdata or NodeCdata) for this object.

Returns
A Node that contains this NodeText.
bool Mezzanine::XML::NodeText::Empty ( ) const

Is this storing anything at all?

Returns
Returns True if this NodeText is storing nothing. False if it is storing anything.
const Char8* Mezzanine::XML::NodeText::GetString ( ) const

Get text, or "" if object is empty.

Returns
A pointer to the string or "" if this is empty.
Mezzanine::XML::NodeText::operator unspecified_bool_type ( ) const

Used to convert this to a boolean value in a safe way.

Returns
Returns true if the internal data is set and false otherwise.
bool Mezzanine::XML::NodeText::operator! ( ) const

Used to convert this attribute the opposite of it's normal boolean value.

This is described in the PugiXML source a a workaround for a borland c++ issue.

Returns
Returns false if the internal pointer AttributeStruct is set and true otherwise.
NodeText& Mezzanine::XML::NodeText::operator= ( const Char8 rhs)

Set text (equivalent to set without error checking)

Parameters
rhsThe value to store in this text.
Returns
A reference to the modified NodeText to allow operator chaining.
NodeText& Mezzanine::XML::NodeText::operator= ( int  rhs)

Set text (equivalent to set without error checking) by lexigraphically converting rhs.

Parameters
rhsThe value to store in this text.
Returns
A reference to the modified NodeText to allow operator chaining.
NodeText& Mezzanine::XML::NodeText::operator= ( unsigned int  rhs)

Set text (equivalent to set without error checking) by lexigraphically converting rhs.

Parameters
rhsThe value to store in this text.
Returns
A reference to the modified NodeText to allow operator chaining.
NodeText& Mezzanine::XML::NodeText::operator= ( double  rhs)

Set text (equivalent to set without error checking) by lexigraphically converting rhs.

Parameters
rhsThe value to store in this text.
Returns
A reference to the modified NodeText to allow operator chaining.
NodeText& Mezzanine::XML::NodeText::operator= ( bool  rhs)

Set text (equivalent to set without error checking)by converting value to "true"/"false".

Parameters
rhsThe value to store in this text.
Returns
A reference to the modified NodeText to allow operator chaining.
bool Mezzanine::XML::NodeText::Set ( const Char8 rhs)

Set text.

Parameters
rhsThe value to store in this text.
Returns
False if object is empty or there is not enough memory.
bool Mezzanine::XML::NodeText::Set ( int  rhs)

Set text by lexigraphically converting rhs.

Parameters
rhsThe value to store in this text.
Returns
False if object is empty or there is not enough memory.
bool Mezzanine::XML::NodeText::Set ( unsigned int  rhs)

Set text by lexigraphically converting rhs.

Parameters
rhsThe value to store in this text.
Returns
False if object is empty or there is not enough memory.
bool Mezzanine::XML::NodeText::Set ( double  rhs)

Set text by lexigraphically converting rhs.

Parameters
rhsThe value to store in this text.
Returns
False if object is empty or there is not enough memory.
bool Mezzanine::XML::NodeText::Set ( bool  rhs)

Set text by converting value to "true"/"false".

Parameters
rhsThe value to store in this text.
Returns
False if object is empty or there is not enough memory.

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