HydraExpress™ C++ API Reference Guide

 
Loading...
Searching...
No Matches
rwsf::Attribute Class Reference

Provides a wrapper around any type to hold attribute values. More...

#include <rwsf/core/Attribute.h>

Inheritance diagram for rwsf::Attribute:
rwsf::HandleBase

Public Member Functions

 Attribute ()
 Attribute (const Attribute &rhs)
virtual ~Attribute ()
Attributeoperator= (const Attribute &rhs)
Public Member Functions inherited from rwsf::HandleBase
bool isValid (void) const
bool operator!= (const HandleBase &second) const
bool operator== (const HandleBase &second) const

Static Public Member Functions

template<class T>
static T & value (Attribute &attr)
template<class T>
static const T & value (const Attribute &attr)

(Note that these are not member symbols.)

template<class T>
void operator<< (Attribute &attr, const T &value)
template<class T>
void operator>> (const Attribute &attr, T &value)

Additional Inherited Members

Protected Member Functions inherited from rwsf::HandleBase
 HandleBase (BodyBase *body)
 HandleBase (const HandleBase &second)
 HandleBase (StaticCtor)
 HandleBase (void)
virtual ~HandleBase (void)
BodyBase & body (void) const
HandleBaseoperator= (const HandleBase &second)

Detailed Description

rwsf::Attribute provides a wrapper around objects of any type. rwsf::Attribute contains a single object by value. The contained object must provide a default constructor, a copy constructor, and an assignment operator. The copy constructor must not invalidate the original object. The class provides an inserter template to copy values into an instance and an extractor template to copy values out of an instance.

An instance of rwsf::Attribute is the value of the key/value pair in several Core and Web Services classes, such as rwsf::CallInfo and rwsf::NamedObject.

Templatized insertion and extraction operators are provided for moving typed objects into and out of an rwsf::Attribute instance.

Note
This class uses reference semantics wherein copies and assignments always point to the same object instance.

Constructor & Destructor Documentation

◆ Attribute() [1/2]

rwsf::Attribute::Attribute ( )

Constructs an invalid Attribute instance. A typed object needs to be inserted into this object before it is usable.

◆ Attribute() [2/2]

rwsf::Attribute::Attribute ( const Attribute & rhs)

Copy constructor. This instance becomes a handle to the same value as rhs. Attaches to and increments the reference count on the body of rhs.

◆ ~Attribute()

virtual rwsf::Attribute::~Attribute ( )
virtual

Destructor. Detaches from the current body (if any), decrements its reference count, and deletes it if there are no other references.

Member Function Documentation

◆ operator=()

Attribute & rwsf::Attribute::operator= ( const Attribute & rhs)

Assignment operator. Results in this instance referencing the same value as rhs.

◆ value() [1/2]

template<class T>
T & rwsf::Attribute::value ( Attribute & attr)
static

Returns a reference to the typed value held in self. If this attribute does not hold an object of type T, throws an exception.

◆ value() [2/2]

template<class T>
const T & rwsf::Attribute::value ( const Attribute & attr)
static

Returns a const reference to the typed value held in self. If this attribute does not hold an object of type T, throws an exception.

◆ operator<<()

template<class T>
void operator<< ( Attribute & attr,
const T & value )
related

Insertion operator. Inserts a copy of value into attr. Note that T must be a single object rather than an array, and that the operator uses the exact type of T. In particular, an attribute cannot hold an array of char. Instead, use an std::string:

Attribute attr;
attr << std::string("Inserts an std::string.");

◆ operator>>()

template<class T>
void operator>> ( const Attribute & attr,
T & value )
related

Extraction operator. Extracts the value stored in attr and copies it into value. If attr does not contain a value, value is unchanged. Note that the type of value must exactly match the type inserted into attr. Otherwise, the operator throws an exception of type rwsf::Exception.

Copyright © 2026 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.