KiCad PCB EDA Suite
Loading...
Searching...
No Matches
OPTIONAL_XML_ATTRIBUTE< T > Class Template Reference

Model an optional XML attribute. More...

#include <eagle_parser.h>

Public Member Functions

 OPTIONAL_XML_ATTRIBUTE ()
 Construct a default OPTIONAL_XML_ATTRIBUTE, whose data is not available.
 
 OPTIONAL_XML_ATTRIBUTE (const wxString &aData)
 
template<typename V = T>
 OPTIONAL_XML_ATTRIBUTE (T aData)
 
 operator bool () const
 
OPTIONAL_XML_ATTRIBUTE< T > & operator= (const wxString &aData)
 Assign to a string (optionally) containing the data.
 
OPTIONAL_XML_ATTRIBUTE< T > & operator= (T aData)
 Assign to an object of the base type containing the data.
 
bool operator== (const T &aOther) const
 
void Set (const wxString &aString)
 Attempt to convert a string to the base type.
 
TGet ()
 Return a reference to the value of the attribute assuming it is available.
 
const TCGet () const
 Return a constant reference to the value of the attribute assuming it is available.
 
Toperator* ()
 Return a reference to the value of the attribute assuming it is available.
 
const Toperator* () const
 Return a constant reference to the value of the attribute assuming it is available.
 
Toperator-> ()
 Return a pointer to the value of the attribute assuming it is available.
 
const Toperator-> () const
 Return a constant pointer to the value of the attribute assuming it is available.
 
 OPTIONAL_XML_ATTRIBUTE (wxString aData)
 

Private Attributes

bool m_isAvailable
 A boolean indicating if the data is present or not.
 
T m_data
 The actual data if m_isAvailable is true; otherwise, garbage.
 

Detailed Description

template<typename T>
class OPTIONAL_XML_ATTRIBUTE< T >

Model an optional XML attribute.

This was implemented as an alternative to std::optional. This class should be replaced with a simple typedef per type using std::optional when C++17 is published.

Definition at line 197 of file eagle_parser.h.

Constructor & Destructor Documentation

◆ OPTIONAL_XML_ATTRIBUTE() [1/4]

template<typename T>
OPTIONAL_XML_ATTRIBUTE< T >::OPTIONAL_XML_ATTRIBUTE ( )
inline

Construct a default OPTIONAL_XML_ATTRIBUTE, whose data is not available.

Definition at line 210 of file eagle_parser.h.

◆ OPTIONAL_XML_ATTRIBUTE() [2/4]

template<typename T>
OPTIONAL_XML_ATTRIBUTE< T >::OPTIONAL_XML_ATTRIBUTE ( const wxString & aData)
inline
Parameters
aDatais a wxString containing the value that should be converted to type T. If aData is empty, the attribute is understood as unavailable; otherwise, the conversion to T is tried.

Definition at line 220 of file eagle_parser.h.

◆ OPTIONAL_XML_ATTRIBUTE() [3/4]

template<typename T>
template<typename V = T>
OPTIONAL_XML_ATTRIBUTE< T >::OPTIONAL_XML_ATTRIBUTE ( T aData)
inline
Parameters
aDatais the value of the XML attribute. If this constructor is called, the attribute is available.

Definition at line 234 of file eagle_parser.h.

◆ OPTIONAL_XML_ATTRIBUTE() [4/4]

OPTIONAL_XML_ATTRIBUTE< wxString >::OPTIONAL_XML_ATTRIBUTE ( wxString aData)

Definition at line 215 of file eagle_parser.cpp.

Member Function Documentation

◆ CGet()

template<typename T>
const T & OPTIONAL_XML_ATTRIBUTE< T >::CGet ( ) const
inline

Return a constant reference to the value of the attribute assuming it is available.

Returns
const T& - the value of the attribute.

Definition at line 312 of file eagle_parser.h.

Referenced by ConvertEagleTextSize(), OPTIONAL_XML_ATTRIBUTE< wxString >::operator*(), and OPTIONAL_XML_ATTRIBUTE< wxString >::operator->().

◆ Get()

template<typename T>
T & OPTIONAL_XML_ATTRIBUTE< T >::Get ( )
inline

Return a reference to the value of the attribute assuming it is available.

Returns
T& - the value of the attribute.

Definition at line 301 of file eagle_parser.h.

Referenced by PCB_IO_EAGLE::loadPolygon(), OPTIONAL_XML_ATTRIBUTE< wxString >::operator*(), and OPTIONAL_XML_ATTRIBUTE< wxString >::operator->().

◆ operator bool()

template<typename T>
OPTIONAL_XML_ATTRIBUTE< T >::operator bool ( ) const
inline
Returns
bool the availability of the attribute.

Definition at line 242 of file eagle_parser.h.

◆ operator*() [1/2]

template<typename T>
T & OPTIONAL_XML_ATTRIBUTE< T >::operator* ( )
inline

Return a reference to the value of the attribute assuming it is available.

Returns
T& - the value of the attribute.

Definition at line 323 of file eagle_parser.h.

◆ operator*() [2/2]

template<typename T>
const T & OPTIONAL_XML_ATTRIBUTE< T >::operator* ( ) const
inline

Return a constant reference to the value of the attribute assuming it is available.

Returns
const T& - the value of the attribute.

Definition at line 333 of file eagle_parser.h.

◆ operator->() [1/2]

template<typename T>
T * OPTIONAL_XML_ATTRIBUTE< T >::operator-> ( )
inline

Return a pointer to the value of the attribute assuming it is available.

Returns
T* - the value of the attribute.

Definition at line 343 of file eagle_parser.h.

◆ operator->() [2/2]

template<typename T>
const T * OPTIONAL_XML_ATTRIBUTE< T >::operator-> ( ) const
inline

Return a constant pointer to the value of the attribute assuming it is available.

Returns
const T* - the value of the attribute.

Definition at line 353 of file eagle_parser.h.

◆ operator=() [1/2]

template<typename T>
OPTIONAL_XML_ATTRIBUTE< T > & OPTIONAL_XML_ATTRIBUTE< T >::operator= ( const wxString & aData)
inline

Assign to a string (optionally) containing the data.

Parameters
aDatais a wxString that should be converted to T. If the string is empty, the attribute is set to unavailable.

Definition at line 253 of file eagle_parser.h.

◆ operator=() [2/2]

template<typename T>
OPTIONAL_XML_ATTRIBUTE< T > & OPTIONAL_XML_ATTRIBUTE< T >::operator= ( T aData)
inline

Assign to an object of the base type containing the data.

Parameters
aDatais the actual value of the attribute. Calling this assignment, the attribute is automatically made available.

Definition at line 269 of file eagle_parser.h.

◆ operator==()

template<typename T>
bool OPTIONAL_XML_ATTRIBUTE< T >::operator== ( const T & aOther) const
inline
Parameters
aOtheris the object of the base type that should be compared with this one.

Definition at line 280 of file eagle_parser.h.

◆ Set()

template<typename T>
void OPTIONAL_XML_ATTRIBUTE< T >::Set ( const wxString & aString)
inline

Attempt to convert a string to the base type.

Parameters
aStringis the string that will be converted to the base type.

Definition at line 290 of file eagle_parser.h.

Referenced by OPTIONAL_XML_ATTRIBUTE< wxString >::operator=(), and OPTIONAL_XML_ATTRIBUTE< wxString >::OPTIONAL_XML_ATTRIBUTE().

Member Data Documentation

◆ m_data

template<typename T>
T OPTIONAL_XML_ATTRIBUTE< T >::m_data
private

The actual data if m_isAvailable is true; otherwise, garbage.

Definition at line 204 of file eagle_parser.h.

◆ m_isAvailable

template<typename T>
bool OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable
private

A boolean indicating if the data is present or not.

Definition at line 201 of file eagle_parser.h.


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