Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
pugi::xpath_variable Class Reference

#include <pugixml.hpp>

Public Member Functions

const char_tname () const
xpath_value_type type () const
bool get_boolean () const
double get_number () const
const char_tget_string () const
const xpath_node_setget_node_set () const
bool set (bool value)
bool set (double value)
bool set (const char_t *value)
bool set (const xpath_node_set &value)

Protected Member Functions

 xpath_variable (xpath_value_type type)
 xpath_variable (const xpath_variable &)
xpath_variableoperator= (const xpath_variable &)

Protected Attributes

xpath_value_type _type
xpath_variable_next

Friends

class xpath_variable_set

Detailed Description

Definition at line 1138 of file pugixml.hpp.

Constructor & Destructor Documentation

◆ xpath_variable() [1/2]

PUGI__FN xpath_variable::xpath_variable ( xpath_value_type type)
protected

Definition at line 12533 of file pugixml.cc.

12533 : _type(type_), _next(0)
12534 {
12535 }
xpath_variable * _next
Definition pugixml.hpp:1144
xpath_value_type _type
Definition pugixml.hpp:1143

Referenced by operator=(), and xpath_variable().

◆ xpath_variable() [2/2]

pugi::xpath_variable::xpath_variable ( const xpath_variable & )
protected

Member Function Documentation

◆ get_boolean()

PUGI__FN bool xpath_variable::get_boolean ( ) const

Definition at line 12564 of file pugixml.cc.

12565 {
12566 return (_type == xpath_type_boolean) ? static_cast<const impl::xpath_variable_boolean*>(this)->value : false;
12567 }
@ xpath_type_boolean
Definition pugixml.hpp:1115

Referenced by operator=().

◆ get_node_set()

PUGI__FN const xpath_node_set & xpath_variable::get_node_set ( ) const

Definition at line 12580 of file pugixml.cc.

12581 {
12582 return (_type == xpath_type_node_set) ? static_cast<const impl::xpath_variable_node_set*>(this)->value : impl::dummy_node_set;
12583 }
@ xpath_type_node_set
Definition pugixml.hpp:1112

Referenced by operator=().

◆ get_number()

PUGI__FN double xpath_variable::get_number ( ) const

Definition at line 12569 of file pugixml.cc.

12570 {
12571 return (_type == xpath_type_number) ? static_cast<const impl::xpath_variable_number*>(this)->value : impl::gen_nan();
12572 }
@ xpath_type_number
Definition pugixml.hpp:1113
PUGI__FN double gen_nan()
Definition pugixml.cc:8331

Referenced by operator=().

◆ get_string()

PUGI__FN const char_t * xpath_variable::get_string ( ) const

Definition at line 12574 of file pugixml.cc.

12575 {
12576 const char_t* value = (_type == xpath_type_string) ? static_cast<const impl::xpath_variable_string*>(this)->value : 0;
12577 return value ? value : PUGIXML_TEXT("");
12578 }
@ xpath_type_string
Definition pugixml.hpp:1114
PUGIXML_CHAR char_t
Definition pugixml.hpp:137
#define PUGIXML_TEXT(t)
Definition pugixml.hpp:130

Referenced by operator=().

◆ name()

PUGI__FN const char_t * xpath_variable::name ( ) const

Definition at line 12537 of file pugixml.cc.

12538 {
12539 switch (_type)
12540 {
12542 return static_cast<const impl::xpath_variable_node_set*>(this)->name;
12543
12544 case xpath_type_number:
12545 return static_cast<const impl::xpath_variable_number*>(this)->name;
12546
12547 case xpath_type_string:
12548 return static_cast<const impl::xpath_variable_string*>(this)->name;
12549
12550 case xpath_type_boolean:
12551 return static_cast<const impl::xpath_variable_boolean*>(this)->name;
12552
12553 default:
12554 assert(false && "Invalid variable type"); // unreachable
12555 return 0;
12556 }
12557 }
const char_t * name() const
Definition pugixml.cc:12537

Referenced by name(), and operator=().

◆ operator=()

xpath_variable & pugi::xpath_variable::operator= ( const xpath_variable & )
protected

◆ set() [1/4]

PUGI__FN bool xpath_variable::set ( bool value)

Definition at line 12585 of file pugixml.cc.

12586 {
12587 if (_type != xpath_type_boolean) return false;
12588
12589 static_cast<impl::xpath_variable_boolean*>(this)->value = value;
12590 return true;
12591 }

Referenced by operator=(), pugi::xpath_variable_set::set(), pugi::xpath_variable_set::set(), pugi::xpath_variable_set::set(), and pugi::xpath_variable_set::set().

◆ set() [2/4]

PUGI__FN bool xpath_variable::set ( const char_t * value)

Definition at line 12601 of file pugixml.cc.

12602 {
12603 if (_type != xpath_type_string) return false;
12604
12605 impl::xpath_variable_string* var = static_cast<impl::xpath_variable_string*>(this);
12606
12607 // duplicate string
12608 size_t size = (impl::strlength(value) + 1) * sizeof(char_t);
12609
12610 char_t* copy = static_cast<char_t*>(impl::xml_memory::allocate(size));
12611 if (!copy) return false;
12612
12613 memcpy(copy, value, size);
12614
12615 // replace old string
12616 if (var->value) impl::xml_memory::deallocate(var->value);
12617 var->value = copy;
12618
12619 return true;
12620 }
void copy(G4double dst[], const G4double src[], std::size_t size=G4FieldTrack::ncompSVEC)

◆ set() [3/4]

PUGI__FN bool xpath_variable::set ( const xpath_node_set & value)

Definition at line 12622 of file pugixml.cc.

12623 {
12624 if (_type != xpath_type_node_set) return false;
12625
12626 static_cast<impl::xpath_variable_node_set*>(this)->value = value;
12627 return true;
12628 }

◆ set() [4/4]

PUGI__FN bool xpath_variable::set ( double value)

Definition at line 12593 of file pugixml.cc.

12594 {
12595 if (_type != xpath_type_number) return false;
12596
12597 static_cast<impl::xpath_variable_number*>(this)->value = value;
12598 return true;
12599 }

◆ type()

PUGI__FN xpath_value_type xpath_variable::type ( ) const

Definition at line 12559 of file pugixml.cc.

12560 {
12561 return _type;
12562 }

Referenced by operator=().

◆ xpath_variable_set

friend class xpath_variable_set
friend

Definition at line 1140 of file pugixml.hpp.

Referenced by xpath_variable_set.

Member Data Documentation

◆ _next

xpath_variable* pugi::xpath_variable::_next
protected

Definition at line 1144 of file pugixml.hpp.

Referenced by pugi::xpath_variable_set::add(), and xpath_variable().

◆ _type

xpath_value_type pugi::xpath_variable::_type
protected

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