Quick Links:

bal | bbl | bdl | bsl

Classes

Component bdlat_attributeinfo
[Package bdlat]

Provide a container for attribute information. More...

Classes

struct  bdlat_AttributeInfo
 container for attribute information More...

Detailed Description

Outline
Purpose:
Provide a container for attribute information.
Classes:
bdlat_AttributeInfo container for attribute information
See also:
Component 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:
The following snippets of code illustrate the usage of this component. Suppose you create an accessor for sequence attributes that prints each attribute to an output stream:
  #include <bdlat_attributeinfo.h>
  #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";
      }
  };