Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component ball_severityutil
[Package ball]

Provide a suite of utility functions on ball::Severity levels. More...

Namespaces

namespace  ball

Detailed Description

Outline
Purpose:
Provide a suite of utility functions on ball::Severity levels.
Classes:
ball::SeverityUtil namespace for functions on ball::Severity::Level
See also:
Component ball_severity
Description:
This component provides a suite of pure procedures that apply to the ball::Severity::Level enumeration. In particular, the ball::SeverityUtil struct provides a fromAsciiCaseless function that returns the ball::Severity::Level enumerator value corresponding to a given ASCII string (without regard to the case of the characters in the string) and an isValidNameCaseless function that confirms that a given string corresponds to one of the enumerators in the ball::Severity::Level enumeration (similarly, without regard to the case of the characters in the string).
Synopsis:
The following is a list of functions available in this component:
    static int  ball::SeverityUtil::fromAsciiCaseless(
                                              ball::Severity::Level *level,
                                              const char            *name);

    static bool ball::SeverityUtil::isValidNameCaseless(const char *name);
Usage:
In this example, we show how to validate that a set of C-style strings correspond to ball::Severity::Level enumerators, and then use those strings to generate enumerator values that, in turn, may be used to administer a logger manager. Here, for convenience, we define our strings in an array, much as how we might receive them from a command line:
    const char *argv[] = {
        "INFO",   // record
        "WARN",   // pass
        "ERROR",  // trigger
        "FATAL"   // trigger-all
    };

    assert(ball::SeverityUtil::isValidNameCaseless(argv[0]));
    assert(ball::SeverityUtil::isValidNameCaseless(argv[1]));
    assert(ball::SeverityUtil::isValidNameCaseless(argv[2]));
    assert(ball::SeverityUtil::isValidNameCaseless(argv[3]));

    ball::Severity::Level record;
    ball::Severity::Level pass;
    ball::Severity::Level trigger;
    ball::Severity::Level triggerAll;

    assert(0 == ball::SeverityUtil::fromAsciiCaseless(&record,     argv[0]));
    assert(0 == ball::SeverityUtil::fromAsciiCaseless(&pass,       argv[1]));
    assert(0 == ball::SeverityUtil::fromAsciiCaseless(&trigger,    argv[2]));
    assert(0 == ball::SeverityUtil::fromAsciiCaseless(&triggerAll, argv[3]));

    assert(ball::Severity::e_INFO  == record);
    assert(ball::Severity::e_WARN  == pass);
    assert(ball::Severity::e_ERROR == trigger);
    assert(ball::Severity::e_FATAL == triggerAll);