Outline
Purpose
Provide a container for attribute information.
Classes
- See also
- bdlat_sequencefunctions
Description
This component provides the bdlat_AttributeInfo
struct
, which is a container for holding information (properties) about a sequence attribute. The properties of an attribute include its name and the length of its name, its distinct id within its containing type, its formatting mode, and a brief annotation. Although each attribute property is publicly accessible, a manipulator and accessor is also supplied for each.
When accessing or manipulating an attribute of a "sequence" type (using one of the functions from the bdlat_SequenceFunctions
namespace), an instance of this struct
will be passed as the second argument to the accessor or manipulator.
Note that this struct
needs to be a POD type.
Usage
This section illustrates intended use of this component.
Example 1: Basic Usage
Suppose you create an accessor for sequence attributes that prints each attribute to an output stream:
#include <ostream>
using namespace BloombergLP;
class PrintAttributeWithInfo {
bsl::ostream *d_stream_p;
public:
PrintAttributeWithInfo(bsl::ostream *stream)
: d_stream_p(stream)
{
}
template <typename TYPE>
int operator()(const TYPE& attribute,
{
(*d_stream_p) << attribute << " ("
<< ", "
}
};
const char *& name()
Definition bdlat_attributeinfo.h:263
int & nameLength()
Definition bdlat_attributeinfo.h:269
const char *& annotation()
Definition bdlat_attributeinfo.h:245
basic_string< char > string
Definition bslstl_string.h:782
Definition bdlat_attributeinfo.h:137
◆ annotation() [1/2]
const char *& bdlat_AttributeInfo::annotation |
( |
| ) |
|
|
inline |
Return a reference to the modifiable annotation of this attribute info object.
◆ annotation() [2/2]
◆ formattingMode() [1/2]
int & bdlat_AttributeInfo::formattingMode |
( |
| ) |
|
|
inline |
Return a reference to the modifiable formatting mode of this attribute info object.
◆ formattingMode() [2/2]
◆ id() [1/2]
int & bdlat_AttributeInfo::id |
( |
| ) |
|
|
inline |
Return a reference to the modifiable id of this attribute info object.
◆ id() [2/2]
◆ name() [1/2]
const char *& bdlat_AttributeInfo::name |
( |
| ) |
|
|
inline |
Return a reference to the modifiable name of this attribute info object.
◆ name() [2/2]
◆ nameLength() [1/2]
int & bdlat_AttributeInfo::nameLength |
( |
| ) |
|
|
inline |
Return a reference to the modifiable length of the name of this attribute info object. Note that the 0-terminator is not included in the length.
◆ nameLength() [2/2]
Return the length of the name of this attribute info object. Note that the 0-terminator is not included in the length.
◆ operator!=()
Return true
if the specified lhs
and rhs
attribute info objects do not have the same value, and false
otherwise. Two attribute info objects do not have the same value if at least one of their respective properties is not identical.
◆ operator<<()
Write the value of the specified attributeInfo
to the specified stream
.
◆ operator==()
Return true
if the specified lhs
and rhs
attribute info objects have the same value, and false
otherwise. Two attribute info objects have the same value if each of their respective properties are identical.