Quick Links:

bal | bbl | bdl | bsl

Classes

Component bdlat_selectioninfo
[Package bdlat]

Provide a container for selection information. More...

Classes

struct  bdlat_SelectionInfo
 container for selection information More...

Detailed Description

Outline
Purpose:
Provide a container for selection information.
Classes:
bdlat_SelectionInfo container for selection information
See also:
Component 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:
The following snippets of code illustrate the usage of this component. Suppose you create an accessor for choice selections that prints the selection to an output stream:
  #include <bdlat_selectioninfo.h>
  #include <ostream>

  using namespace BloombergLP;

  class PrintSelectionWithInfo {
      // Print the selection along with its name and annotation.

      // PRIVATE DATA MEMBERS
      bsl::ostream *d_stream_p;

    public:
      // CREATORS
      PrintSelectionWithInfo(bsl::ostream *stream)
      : d_stream_p(stream)
      {
      }

      // OPERATIONS
      template <typename TYPE>
      int operator()(const TYPE&                selection,
                     const bdlat_SelectionInfo& info)
      {
          (*d_stream_p) << selection << " ("
                        << bsl::string(info.name(),
                                       info.nameLength())
                        << ", "
                        << info.annotation() << ")\n";
      }
  };