Outline
Purpose
Provide a container for selection information.
Classes
- See also
- bdlat_choicefunctions
Description
This component provides the bdlat_SelectionInfo
struct
, which is a container for holding information (properties) about a choice selection. The properties of a selection 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 selection property is publicly accessible, a manipulator and accessor is also supplied for each.
When accessing or manipulating a selection of a "choice" type (using one of the functions from the bdlat_ChoiceFunctions
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 choice selections that prints the selection to an output stream:
#include <ostream>
using namespace BloombergLP;
class PrintSelectionWithInfo {
bsl::ostream *d_stream_p;
public:
PrintSelectionWithInfo(bsl::ostream *stream)
: d_stream_p(stream)
{
}
template <typename TYPE>
int operator()(const TYPE& selection,
{
(*d_stream_p) << selection << " ("
<< ", "
}
};
int & nameLength()
Definition bdlat_selectioninfo.h:268
const char *& name()
Definition bdlat_selectioninfo.h:262
const char *& annotation()
Definition bdlat_selectioninfo.h:244
basic_string< char > string
Definition bslstl_string.h:782
Definition bdlat_selectioninfo.h:136
◆ annotation() [1/2]
const char *& bdlat_SelectionInfo::annotation |
( |
| ) |
|
|
inline |
Return a reference to the modifiable annotation of this selection info object.
◆ annotation() [2/2]
◆ formattingMode() [1/2]
int & bdlat_SelectionInfo::formattingMode |
( |
| ) |
|
|
inline |
Return a reference to the modifiable formatting mode of this selection info object.
◆ formattingMode() [2/2]
◆ id() [1/2]
int & bdlat_SelectionInfo::id |
( |
| ) |
|
|
inline |
Return a reference to the modifiable id of this selection info object.
◆ id() [2/2]
◆ name() [1/2]
const char *& bdlat_SelectionInfo::name |
( |
| ) |
|
|
inline |
Return a reference to the modifiable name of this selection info object.
◆ name() [2/2]
◆ nameLength() [1/2]
int & bdlat_SelectionInfo::nameLength |
( |
| ) |
|
|
inline |
Return a reference to the modifiable length of the name of this selection info object. Note that the 0-terminator is not included in the length.
◆ nameLength() [2/2]
Return the length of the name of this selection info object. Note that the 0-terminator is not included in the length.
◆ operator!=()
Return true
if the specified lhs
and rhs
selection info objects do not have the same value, and false
otherwise. Two selection 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 selectionInfo
to the specified stream
.
◆ operator==()
Return true
if the specified lhs
and rhs
selection info objects have the same value, and false
otherwise. Two selection info objects have the same value if each of their respective properties are identical.