BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlat_attributeinfo

Detailed Description

Provide a container for attribute information.

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 {
// Print the attribute along with its name and annotation.
// PRIVATE DATA MEMBERS
bsl::ostream *d_stream_p;
public:
// CREATORS
PrintAttributeWithInfo(bsl::ostream *stream)
: d_stream_p(stream)
{
}
// OPERATIONS
template <typename TYPE>
int operator()(const TYPE& attribute,
const bdlat_AttributeInfo& info)
{
(*d_stream_p) << attribute << " ("
<< bsl::string(info.name(),
info.nameLength())
<< ", "
<< info.annotation() << ")\n";
}
};
const char *& name()
Definition bdlat_attributeinfo.h:267
int & nameLength()
Definition bdlat_attributeinfo.h:273
const char *& annotation()
Definition bdlat_attributeinfo.h:249
basic_string< char > string
Definition bslstl_string.h:844
Definition bdlat_attributeinfo.h:139

Classes

struct  bdlat_AttributeInfo
 

Functions

bool operator== (const bdlat_AttributeInfo &lhs, const bdlat_AttributeInfo &rhs)
 
bool operator!= (const bdlat_AttributeInfo &lhs, const bdlat_AttributeInfo &rhs)
 
bsl::ostream & operator<< (bsl::ostream &stream, const bdlat_AttributeInfo &attributeInfo)
 
const char *& bdlat_AttributeInfo::annotation ()
 
int & bdlat_AttributeInfo::formattingMode ()
 
int & bdlat_AttributeInfo::id ()
 
const char *& bdlat_AttributeInfo::name ()
 
int & bdlat_AttributeInfo::nameLength ()
 
BSLS_KEYWORD_CONSTEXPR const char * bdlat_AttributeInfo::annotation () const
 
BSLS_KEYWORD_CONSTEXPR int bdlat_AttributeInfo::formattingMode () const
 
BSLS_KEYWORD_CONSTEXPR int bdlat_AttributeInfo::id () const
 
BSLS_KEYWORD_CONSTEXPR const char * bdlat_AttributeInfo::name () const
 
BSLS_KEYWORD_CONSTEXPR int bdlat_AttributeInfo::nameLength () const
 

Function Documentation

◆ annotation() [1/2]

const char *& bdlat_AttributeInfo::annotation ( )
inline

Return a reference to the modifiable annotation of this attribute info object.

◆ annotation() [2/2]

BSLS_KEYWORD_CONSTEXPR const char * bdlat_AttributeInfo::annotation ( ) const
inline

Return the non-modifiable annotation of this attribute info object.

◆ formattingMode() [1/2]

int & bdlat_AttributeInfo::formattingMode ( )
inline

Return a reference to the modifiable formatting mode of this attribute info object.

◆ formattingMode() [2/2]

BSLS_KEYWORD_CONSTEXPR int bdlat_AttributeInfo::formattingMode ( ) const
inline

Return the formatting mode of this attribute info object.

◆ id() [1/2]

int & bdlat_AttributeInfo::id ( )
inline

Return a reference to the modifiable id of this attribute info object.

◆ id() [2/2]

BSLS_KEYWORD_CONSTEXPR int bdlat_AttributeInfo::id ( ) const
inline

Return the id of this attribute info object.

◆ name() [1/2]

const char *& bdlat_AttributeInfo::name ( )
inline

Return a reference to the modifiable name of this attribute info object.

◆ name() [2/2]

BSLS_KEYWORD_CONSTEXPR const char * bdlat_AttributeInfo::name ( ) const
inline

Return the non-modifiable name of this attribute info object.

◆ nameLength() [1/2]

int & bdlat_AttributeInfo::nameLength ( )
inline

Return a reference to the modifiable length of the name of this attribute info object.

Note
Note that the 0-terminator is not included in the length.

◆ nameLength() [2/2]

BSLS_KEYWORD_CONSTEXPR int bdlat_AttributeInfo::nameLength ( ) const
inline

Return the length of the name of this attribute info object.

Note
Note that the 0-terminator is not included in the length.

◆ operator!=()

bool operator!= ( const bdlat_AttributeInfo lhs,
const bdlat_AttributeInfo rhs 
)
inline

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<<()

bsl::ostream & operator<< ( bsl::ostream &  stream,
const bdlat_AttributeInfo attributeInfo 
)

Write the value of the specified attributeInfo to the specified stream.

◆ operator==()

bool operator== ( const bdlat_AttributeInfo lhs,
const bdlat_AttributeInfo rhs 
)
inline

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.