Quick Links: |
#include <ball_attribute.h>
Public Types | |
typedef bdlb::Variant< int, long, long long, unsigned int, unsigned long, unsigned long long, bsl::string, const void * > | Value |
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, 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 () | |
Attribute & | operator= (const Attribute &rhs) |
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 (const bsl::string_view &value) |
void | setValue (const char *value) |
void | setValue (const void *value) |
const char * | name () const |
const Value & | value () 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 &) |
An Attribute
object contains an attribute name which is not managed and an attribute value which is managed.
typedef bdlb::Variant<int, long, long long, unsigned int, unsigned long, unsigned long long, bsl::string, const void *> ball::Attribute::Value |
typedef bsl::allocator<char> ball::Attribute::allocator_type |
ball::Attribute::Attribute | ( | const char * | name, | |
const bsl::string_view & | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
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.
ball::Attribute::Attribute | ( | const char * | name, | |
const char * | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
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.
ball::Attribute::Attribute | ( | const char * | name, | |
int | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
ball::Attribute::Attribute | ( | const char * | name, | |
long | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
ball::Attribute::Attribute | ( | const char * | name, | |
long long | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
ball::Attribute::Attribute | ( | const char * | name, | |
unsigned int | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
ball::Attribute::Attribute | ( | const char * | name, | |
unsigned long | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
ball::Attribute::Attribute | ( | const char * | name, | |
unsigned long long | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
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.
ball::Attribute::Attribute | ( | const char * | name, | |
const void * | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
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.
ball::Attribute::Attribute | ( | const char * | name, | |
const Value & | value, | |||
const allocator_type & | allocator = allocator_type() | |||
) |
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.
ball::Attribute::Attribute | ( | const Attribute & | original, | |
const allocator_type & | allocator = allocator_type() | |||
) |
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.
ball::Attribute::~Attribute | ( | ) |
Destroy this attribute object.
ball::Attribute::BSLMF_NESTED_TRAIT_DECLARATION | ( | Attribute | , | |
bslma::UsesBslmaAllocator | ||||
) |
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
.
Assign the value of the specified rhs
object to this object.
void ball::Attribute::setName | ( | const char * | name | ) |
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.
void ball::Attribute::setValue | ( | const Value & | value | ) |
void ball::Attribute::setValue | ( | int | value | ) |
void ball::Attribute::setValue | ( | long | value | ) |
void ball::Attribute::setValue | ( | long long | value | ) |
void ball::Attribute::setValue | ( | unsigned int | value | ) |
void ball::Attribute::setValue | ( | unsigned long | value | ) |
void ball::Attribute::setValue | ( | unsigned long long | value | ) |
void ball::Attribute::setValue | ( | const bsl::string_view & | value | ) |
void ball::Attribute::setValue | ( | const char * | value | ) |
void ball::Attribute::setValue | ( | const void * | value | ) |
Set the attribute value of this object to the specified value
.
const char* ball::Attribute::name | ( | ) | const |
Return the name of this object.
const Value& ball::Attribute::value | ( | ) | const |
Return a reference to the non-modifiable attribute value of this object.
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.
allocator_type ball::Attribute::get_allocator | ( | ) | const |
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.
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.
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.
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.