BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::Attribute Class Reference

#include <ball_attribute.h>

Public Types

typedef bdlb::Variant< int, long, long long, unsigned int, unsigned long, unsigned long long, bsl::string, const void *, bdlb::GuidValue
 Value is an alias for the attribute type variant.
 
typedef bsl::allocator< char > allocator_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (Attribute, bslma::UsesBslmaAllocator)
 
 Attribute (const char *name, const bsl::string_view &value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, const char *value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, int value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, long value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, long long value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, unsigned int value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, unsigned long value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, unsigned long long value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, bdlb::Guid value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, const void *value, const allocator_type &allocator=allocator_type())
 
 Attribute (const char *name, const Value &value, const allocator_type &allocator=allocator_type())
 
 Attribute (const Attribute &original, const allocator_type &allocator=allocator_type())
 
 ~Attribute ()=default
 Destroy this object.
 
Attributeoperator= (const Attribute &rhs)
 Assign the value of the specified rhs object to this object.
 
void setName (const char *name)
 
void setValue (const Value &value)
 
void setValue (int value)
 
void setValue (long value)
 
void setValue (long long value)
 
void setValue (unsigned int value)
 
void setValue (unsigned long value)
 
void setValue (unsigned long long value)
 
void setValue (bdlb::Guid value)
 
void setValue (const bsl::string_view &value)
 
void setValue (const char *value)
 
void setValue (const void *value)
 Set the attribute value of this object to the specified value.
 
const char * name () const
 Return the name of this object.
 
const Valuevalue () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 
allocator_type get_allocator () const
 

Static Public Member Functions

static int hash (const Attribute &attribute, int size)
 

Friends

bool operator== (const Attribute &, const Attribute &)
 
bool operator!= (const Attribute &, const Attribute &)
 
bsl::ostream & operator<< (bsl::ostream &, const Attribute &)
 

Detailed Description

An Attribute object contains an attribute name which is not managed and an attribute value which is managed.

See ball_attribute

Member Typedef Documentation

◆ allocator_type

◆ Value

typedef bdlb::Variant<int, long, long long, unsigned int, unsigned long, unsigned long long, bsl::string, const void *, bdlb::Guid> ball::Attribute::Value

Constructor & Destructor Documentation

◆ Attribute() [1/12]

ball::Attribute::Attribute ( const char *  name,
const bsl::string_view value,
const allocator_type allocator = allocator_type() 
)
inline

Create an Attribute object having the specified (literal) name and (character string) value. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. Note that name is not managed by this object and therefore must remain valid while in use by any Attribute object.

◆ Attribute() [2/12]

ball::Attribute::Attribute ( const char *  name,
const char *  value,
const allocator_type allocator = allocator_type() 
)
inline

Create an Attribute object having the specified (literal) name and (character string) value. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. Note that name is not managed by this object and therefore must remain valid while in use by any Attribute object.

◆ Attribute() [3/12]

ball::Attribute::Attribute ( const char *  name,
int  value,
const allocator_type allocator = allocator_type() 
)
inline

◆ Attribute() [4/12]

ball::Attribute::Attribute ( const char *  name,
long  value,
const allocator_type allocator = allocator_type() 
)
inline

◆ Attribute() [5/12]

ball::Attribute::Attribute ( const char *  name,
long long  value,
const allocator_type allocator = allocator_type() 
)
inline

◆ Attribute() [6/12]

ball::Attribute::Attribute ( const char *  name,
unsigned int  value,
const allocator_type allocator = allocator_type() 
)
inline

◆ Attribute() [7/12]

ball::Attribute::Attribute ( const char *  name,
unsigned long  value,
const allocator_type allocator = allocator_type() 
)
inline

◆ Attribute() [8/12]

ball::Attribute::Attribute ( const char *  name,
unsigned long long  value,
const allocator_type allocator = allocator_type() 
)
inline

◆ Attribute() [9/12]

ball::Attribute::Attribute ( const char *  name,
bdlb::Guid  value,
const allocator_type allocator = allocator_type() 
)
inline

Create an Attribute object having the specified (literal) name and value. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. Note that name is not managed by this object and therefore must remain valid while in use by any Attribute object.

◆ Attribute() [10/12]

ball::Attribute::Attribute ( const char *  name,
const void *  value,
const allocator_type allocator = allocator_type() 
)
inline

Create an Attribute object having the specified (literal) name and (const-qualified void pointer) value. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used.

◆ Attribute() [11/12]

ball::Attribute::Attribute ( const char *  name,
const Value value,
const allocator_type allocator = allocator_type() 
)
inline

Create an Attribute object having the specified (literal) name and value. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. Note that name is not managed by this object and therefore must remain valid while in use by any Attribute object.

◆ Attribute() [12/12]

ball::Attribute::Attribute ( const Attribute original,
const allocator_type allocator = allocator_type() 
)
inline

Create an Attribute object having the same (literal) name and attribute value as the specified original object. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used.

◆ ~Attribute()

ball::Attribute::~Attribute ( )
default

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::Attribute::BSLMF_NESTED_TRAIT_DECLARATION ( Attribute  ,
bslma::UsesBslmaAllocator   
)

◆ get_allocator()

Attribute::allocator_type ball::Attribute::get_allocator ( ) const
inline

Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.

◆ hash()

static int ball::Attribute::hash ( const Attribute attribute,
int  size 
)
static

Return a hash value calculated from the specified attribute using the specified size as the number of slots. The hash value is guaranteed to be in the range [0 .. size - 1]. The behavior is undefined unless 0 < size.

◆ name()

const char * ball::Attribute::name ( ) const
inline

◆ operator=()

Attribute & ball::Attribute::operator= ( const Attribute rhs)
inline

◆ print()

bsl::ostream & ball::Attribute::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ setName()

void ball::Attribute::setName ( const char *  name)
inline

Set the attribute name of this object to the specified (literal) name. Note that name is not managed by this object and therefore must remain valid while in use by any Attribute object.

◆ setValue() [1/11]

void ball::Attribute::setValue ( bdlb::Guid  value)
inline

◆ setValue() [2/11]

void ball::Attribute::setValue ( const bsl::string_view value)
inline

◆ setValue() [3/11]

void ball::Attribute::setValue ( const char *  value)
inline

◆ setValue() [4/11]

void ball::Attribute::setValue ( const Value value)
inline

◆ setValue() [5/11]

void ball::Attribute::setValue ( const void *  value)
inline

◆ setValue() [6/11]

void ball::Attribute::setValue ( int  value)
inline

◆ setValue() [7/11]

void ball::Attribute::setValue ( long long  value)
inline

◆ setValue() [8/11]

void ball::Attribute::setValue ( long  value)
inline

◆ setValue() [9/11]

void ball::Attribute::setValue ( unsigned int  value)
inline

◆ setValue() [10/11]

void ball::Attribute::setValue ( unsigned long long  value)
inline

◆ setValue() [11/11]

void ball::Attribute::setValue ( unsigned long  value)
inline

◆ value()

const Attribute::Value & ball::Attribute::value ( ) const
inline

Return a reference to the non-modifiable attribute value of this object.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const Attribute ,
const Attribute  
)
friend

Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. Two Attribute objects do not have the same value if any of their respective names (value, not address), attribute value types, or attribute values differ.

◆ operator<<

bsl::ostream & operator<< ( bsl::ostream &  ,
const Attribute  
)
friend

Write the value of the specified attribute to the specified output stream. Return the specified output stream.

◆ operator==

bool operator== ( const Attribute ,
const Attribute  
)
friend

Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two Attribute objects have the same value if they have the same name (but not necessarily the identical representation in memory), the same attribute value type, and the same attribute value.


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