Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::FileXML::Attribute Class Reference

XML Attribute key / value pair. More...

Inheritance diagram for Burger::FileXML::Attribute:
Collaboration diagram for Burger::FileXML::Attribute:

Public Member Functions

 Attribute ()
 Create an empty attribute object.
 
virtual ~Attribute ()
 Call the destructor for a Attribute object.
 
virtual uint_t Parse (InputMemoryStream *pInput)
 Parse an XML Attribute object.
 
virtual uint_t Save (OutputMemoryStream *pOutput, uint_t uDepth) const
 Write out an XML Attribute object.
 
const char * GetKey (void) const
 Return a pointer to the key string for the attribute.
 
void SetKey (const char *pInput)
 Set a new attribute key.
 
void SetKey (const String *pInput)
 Set a new attribute key.
 
const char * GetValue (void) const
 Return a pointer to the value string for the attribute.
 
void SetValue (const char *pInput)
 Set a new attribute value.
 
void SetValue (const String *pInput)
 Set a new attribute value.
 
uint_t GetBoolean (uint_t bDefault) const
 Return a boolean.
 
void SetBoolean (uint_t bValue)
 Return a boolean.
 
uint_t GetWord (uint_t uDefault, uint_t uMin=0, uint_t uMax=0xFFFFFFFFU) const
 Return an unsigned integer value.
 
void SetWord (uint_t uValue)
 Set an unsigned integer value.
 
void SetWordHex (uint_t uValue)
 Set an unsigned integer value as hex.
 
int_t GetInt (int_t iDefault, int_t iMin=(- 0x7FFFFFFF) -1, int_t iMax=0x7FFFFFFF) const
 Return a signed integer value.
 
void SetInt (int_t iValue)
 Set a signed integer value.
 
float GetFloat (float fDefault) const
 Return a floating point value.
 
float GetFloat (float fDefault, float fMin, float fMax) const
 Return a floating point value.
 
void SetFloat (float fValue)
 Set a 32 bit floating point value.
 
double GetDouble (double dDefault) const
 Return a 64 bit floating point value.
 
double GetDouble (double dDefault, double dMin, double dMax) const
 Return a 64 bit floating point value.
 
void SetDouble (double dValue)
 Set a 64 bit floating point value.
 
AttributeUpdate (Root *pRoot, const char *pKey, const char *pValue)
 Create or dispose of an attribute record.
 
- Public Member Functions inherited from Burger::FileXML::Generic
 Generic (eType uType)
 Initialize a generic object.
 
virtual ~Generic ()
 Call the destructor for a generic object.
 
GenericGetNext (void) const
 Get the pointer to the next object in the list.
 
GenericGetPrevious (void) const
 Get the pointer to the previous object in the list.
 
eType GetType (void) const
 Get the enumeration of the derived class' type.
 
void InsertBefore (Generic *pGeneric)
 Insert this object before this one in the linked list.
 
void InsertAfter (Generic *pGeneric)
 Insert this object after this one in the linked list.
 
ElementGetNextElement (void) const
 Follow the linked list of items to the next Element.
 
ElementGetNextElement (const char *pElementName) const
 Follow the linked list of items to the next named Element.
 
GenericGetNextItem (void) const
 Follow the linked list of items to the next object.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual const Burger::StaticRTTIget_StaticRTTI (void) const noexcept
 Get the description to the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Member Functions

static AttributeNew (InputMemoryStream *pInput)
 Create a new Attribute structure and initialize it from an input file.
 
static AttributeNew (const char *pInput, const char *pValue=0)
 Create a new Attribute structure and initialize it with a key value.
 

Private Attributes

String m_Key
 Attribute keyword.
 
String m_Value
 Value attached to the attribute.
 

Additional Inherited Members

- Public Types inherited from Burger::FileXML::Generic
enum  eType {
  XML_ROOT , XML_COMMENT , XML_CDATA , XML_ATTRIBUTE ,
  XML_DECLARATION , XML_DOCUMENT , XML_ELEMENT , XML_TEXT ,
  XML_UNKNOWN
}
 Enumeration to identify derived classes. More...
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Detailed Description

XML Attribute key / value pair.


Some XML elements have attached attributes. Each attribute is attached to an element in the form of attribute="value"

For parsing, ' is valid as is ". Due to the nature of some XML files, it will parse attribute=value as long as the value has no spaces. It will write out the value with quotes in all cases.

Note
This will identify with eType of XML_ATTRIBUTE
See also
FileXML, FileXML::Generic, FileXML::Declaration or FileXML::Element

Constructor & Destructor Documentation

◆ Attribute()

Burger::FileXML::Attribute::Attribute ( )

Create an empty attribute object.


◆ ~Attribute()

Burger::FileXML::Attribute::~Attribute ( )
virtual

Call the destructor for a Attribute object.


Unlink itself from the linked list and release the contained strings

Member Function Documentation

◆ GetBoolean()

uint_t Burger::FileXML::Attribute::GetBoolean ( uint_t bDefault) const
inline

Return a boolean.


Calls String::GetBoolean(uint_t) on the value text and returns the result.

Parameters
bDefaultValue to return on parse failure
See also
SetBoolean(uint_t)

◆ GetDouble() [1/2]

double Burger::FileXML::Attribute::GetDouble ( double dDefault) const
inline

Return a 64 bit floating point value.


Calls String::GetDouble(double) on the value text and returns the result.

Parameters
dDefaultValue to return on error
See also
SetDouble(double)

◆ GetDouble() [2/2]

double Burger::FileXML::Attribute::GetDouble ( double dDefault,
double dMin,
double dMax ) const
inline

Return a 64 bit floating point value.


Calls String::GetDouble(double,double,double) on the value text and returns the result.

Parameters
dDefaultValue to return on error
dMinMinimum acceptable value
dMaxMaximum acceptable value
See also
SetDouble(double)

◆ GetFloat() [1/2]

float Burger::FileXML::Attribute::GetFloat ( float fDefault) const
inline

Return a floating point value.


Calls String::GetFloat(float) on the value text and returns the result.

Parameters
fDefaultValue to return on error
See also
SetFloat(float)

◆ GetFloat() [2/2]

float Burger::FileXML::Attribute::GetFloat ( float fDefault,
float fMin,
float fMax ) const
inline

Return a floating point value.


Calls String::GetFloat(float,float,float) on the value text and returns the result.

Parameters
fDefaultValue to return on error
fMinMinimum acceptable value
fMaxMaximum acceptable value
See also
SetFloat(float)

◆ GetInt()

int_t Burger::FileXML::Attribute::GetInt ( int_t iDefault,
int_t iMin = (- 0x7FFFFFFF )-1,
int_t iMax = 0x7FFFFFFF ) const
inline

Return a signed integer value.


Calls String::GetInt(int_t,int_t,int_t) on the value text and returns the result.

Parameters
iDefaultValue to return on error
iMinMinimum acceptable value
iMaxMaximum acceptable value
See also
SetInt(int_t)

◆ GetKey()

const char * Burger::FileXML::Attribute::GetKey ( void ) const
inline

Return a pointer to the key string for the attribute.


See also
SetKey(const char *) or SetKey(const String *)

◆ GetValue()

const char * Burger::FileXML::Attribute::GetValue ( void ) const
inline

Return a pointer to the value string for the attribute.


See also
SetValue(const char *) or SetValue(const String *)

◆ GetWord()

uint_t Burger::FileXML::Attribute::GetWord ( uint_t uDefault,
uint_t uMin = 0,
uint_t uMax = 0xFFFFFFFFU ) const
inline

Return an unsigned integer value.


Calls String::GetWord(uint_t,uint_t,uint_t) on the value text and returns the result.

Parameters
uDefaultValue to return on error
uMinMinimum acceptable value
uMaxMaximum acceptable value
See also
SetWord(uint_t)

◆ New() [1/2]

Burger::FileXML::Attribute *BURGER_API Burger::FileXML::Attribute::New ( const char * pInput,
const char * pValue = 0 )
static

Create a new Attribute structure and initialize it with a key value.


Initialize a new Attribute with an empty value.

Will return NULL if it's out of memory

Parameters
pInputPointer to a "C" string with the key value.
pValuePointer to a "C" string with the value. Can be NULL for no value.
Returns
NULL on error or a valid Attribute record on a successful parse

◆ New() [2/2]

Burger::FileXML::Attribute *BURGER_API Burger::FileXML::Attribute::New ( InputMemoryStream * pInput)
static

Create a new Attribute structure and initialize it from an input file.


Parse the input file starting at a key, followed by an '=' and then the quoted value Will return NULL on a parsing error or if it's out of memory

Parameters
pInputPointer to an input stream at the start of the key string
Returns
NULL on error or a valid Attribute record on a successful parse

◆ Parse()

uint_t Burger::FileXML::Attribute::Parse ( InputMemoryStream * pInput)
virtual

Parse an XML Attribute object.


Parameters
pInputPointer to the input text stream
Returns
Zero if no error, non-zero on error
See also
Save(OutputMemoryStream *)

Reimplemented from Burger::FileXML::Generic.

◆ Save()

uint_t Burger::FileXML::Attribute::Save ( OutputMemoryStream * pOutput,
uint_t uDepth ) const
virtual

Write out an XML Attribute object.


Parameters
pOutputPointer to the output text stream
uDepthNumber of tabs to output for formatting before writing out the comment
Returns
Zero if no error, non-zero on error
See also
Parse(InputMemoryStream *)

Reimplemented from Burger::FileXML::Generic.

◆ SetBoolean()

void Burger::FileXML::Attribute::SetBoolean ( uint_t bValue)
inline

Return a boolean.


Calls String::SetYesNo(uint_t) on the value text and returns the result.

Parameters
bValueValue to pass to String::SetYesNo(uint_t)
See also
SetBoolean(uint_t)

◆ SetDouble()

void Burger::FileXML::Attribute::SetDouble ( double dValue)
inline

Set a 64 bit floating point value.


Calls String::SetDouble(double) on the value text

Parameters
dValueValue to store as an integer string
See also
GetDouble(double,double,double) const

◆ SetFloat()

void Burger::FileXML::Attribute::SetFloat ( float fValue)
inline

Set a 32 bit floating point value.


Calls String::SetFloat(float) on the value text

Parameters
fValueValue to store as an integer string
See also
GetFloat(float,float,float) const

◆ SetInt()

void Burger::FileXML::Attribute::SetInt ( int_t iValue)
inline

Set a signed integer value.


Calls String::SetInt(int_t) on the value text

Parameters
iValueValue to store as an integer string
See also
GetInt(int_t,int_t,int_t) const

◆ SetKey() [1/2]

void Burger::FileXML::Attribute::SetKey ( const char * pInput)
inline

Set a new attribute key.


Replace the contained attribute key string with a new one

Parameters
pInputPointer to a "C" string
See also
GetKey(void) const or SetKey(const String *)

◆ SetKey() [2/2]

void Burger::FileXML::Attribute::SetKey ( const String * pInput)
inline

Set a new attribute key.


Replace the contained attribute key with a new one

Parameters
pInputPointer to a String class instance
See also
GetKey(void) const or SetKey(const char *)

◆ SetValue() [1/2]

void Burger::FileXML::Attribute::SetValue ( const char * pInput)
inline

Set a new attribute value.


Replace the contained attribute value string with a new one

Parameters
pInputPointer to a "C" string
See also
GetValue(void) const or SetValue(const String *)

◆ SetValue() [2/2]

void Burger::FileXML::Attribute::SetValue ( const String * pInput)
inline

Set a new attribute value.


Replace the contained attribute value with a new one

Parameters
pInputPointer to a String class instance
See also
GetValue(void) const or SetValue(const char *)

◆ SetWord()

void Burger::FileXML::Attribute::SetWord ( uint_t uValue)
inline

Set an unsigned integer value.


Calls String::SetWord(uint_t) on the value text

Parameters
uValueValue to store as an unsigned integer string
See also
SetWordHex(uint_t) or GetWord(uint_t,uint_t,uint_t) const

◆ SetWordHex()

void Burger::FileXML::Attribute::SetWordHex ( uint_t uValue)
inline

Set an unsigned integer value as hex.


Calls String::SetWordHex(uint_t) on the value text

Parameters
uValueValue to store as an unsigned integer hex string
See also
SetWord(uint_t) or GetWord(uint_t,uint_t,uint_t) const

◆ Update()

Burger::FileXML::Attribute *BURGER_API Burger::FileXML::Attribute::Update ( Root * pRoot,
const char * pKey,
const char * pValue )

Create or dispose of an attribute record.


If a pointer to an attribute is maintained, use this function to create / delete / modify an existing attribute. If the key is NULL or an empty string or the data is NULL, the attribute will be disposed of.

If the key / value is valid and the attribute pointer is NULL, a new attribute will be created and appended to the end of the pRoot linked list. Otherwise, the current attribute will have the key/value pair updated to the new value.

Will return NULL if the attribute was disposed on, the "this" pointer on update or a new pointer if an attribute was created.

static Attribute *g_pAttribute = NULL;
Element *pElement;
g_pAttribute = g_pAttribute->Update(pElement->GetRoot(),"key","newvalue");
g_pAttribute = g_pAttribute->Update(pElement->GetRoot(),"keytoremove",NULL);
#define NULL
Define of the number 0 for pointer invalidation.
Definition burger.h:57
XML Attribute key / value pair.
Definition burger.h:23287
Attribute * Update(Root *pRoot, const char *pKey, const char *pValue)
Create or dispose of an attribute record.
Definition brfilexml.cpp:1714
XML Element object.
Definition burger.h:23368
Root * GetRoot(void)
Return the root object.
Definition burger.h:23378
Parameters
pRootPointer to parent's Generic linked list in the event of attribute creation. If NULL, a new item will not be added to any linked list.
pKeyPointer to a "C" string with the key.
pValuePointer to a "C" string with the value.
Returns
NULL on error or a valid Attribute record on a valid key/value pair

Member Data Documentation

◆ m_Key

String Burger::FileXML::Attribute::m_Key
private

Attribute keyword.

◆ m_Value

String Burger::FileXML::Attribute::m_Value
private

Value attached to the attribute.