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.
 
T & Get ()
 Return a reference to the value of the attribute assuming it is available.
 
const T & CGet () const
 Return a constant reference to the value of the attribute assuming it is available.
 
T & operator* ()
 Return a reference to the value of the attribute assuming it is available.
 
const T & operator* () const
 Return a constant reference to the value of the attribute assuming it is available.
 
T * operator-> ()
 Return a pointer to the value of the attribute assuming it is available.
 
const T * operator-> () const
 Return a constant pointer to the value of the attribute assuming it is available.
 

Private Attributes

bool m_isAvailable
 A boolean indicating if the data is present or not.
 
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 201 of file eagle_parser.h.

Constructor & Destructor Documentation

◆ OPTIONAL_XML_ATTRIBUTE() [1/3]

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 214 of file eagle_parser.h.

◆ OPTIONAL_XML_ATTRIBUTE() [2/3]

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 224 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_data, OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable, and OPTIONAL_XML_ATTRIBUTE< T >::Set().

◆ OPTIONAL_XML_ATTRIBUTE() [3/3]

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

Definition at line 238 of file eagle_parser.h.

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 316 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_data, and OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable.

Referenced by ETEXT::ConvertSize(), OPTIONAL_XML_ATTRIBUTE< T >::operator*(), and OPTIONAL_XML_ATTRIBUTE< T >::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 305 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_data, and OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable.

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

◆ operator bool()

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

Definition at line 246 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable.

◆ 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 327 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::Get().

◆ 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 337 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::CGet().

◆ 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 347 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::Get().

◆ 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 357 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::CGet().

◆ 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 257 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable, and OPTIONAL_XML_ATTRIBUTE< T >::Set().

◆ operator=() [2/2]

template<typename T >
OPTIONAL_XML_ATTRIBUTE< T > & OPTIONAL_XML_ATTRIBUTE< T >::operator= ( 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 273 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_data, and OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable.

◆ 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 284 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_data, and OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable.

◆ 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 294 of file eagle_parser.h.

References OPTIONAL_XML_ATTRIBUTE< T >::m_data, and OPTIONAL_XML_ATTRIBUTE< T >::m_isAvailable.

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

Member Data Documentation

◆ m_data

◆ m_isAvailable


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