Quick Links: |
#include <ball_rule.h>
Public Member Functions | |
BSLMF_NESTED_TRAIT_DECLARATION (Rule, bslma::UsesBslmaAllocator) | |
Rule (bslma::Allocator *basicAllocator=0) | |
Rule (const bsl::string_view &pattern, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel, bslma::Allocator *basicAllocator=0) | |
Rule (const Rule &original, bslma::Allocator *basicAllocator=0) | |
~Rule () | |
Rule & | operator= (const Rule &rhs) |
int | addAttribute (const ManagedAttribute &value) |
int | addPredicate (const ManagedAttribute &value) |
int | removeAttribute (const ManagedAttribute &value) |
int | removePredicate (const ManagedAttribute &value) |
void | removeAll () |
void | removeAllPredicates () |
int | setLevels (int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel) |
void | setPattern (const bsl::string_view &value) |
bool | evaluate (const AttributeContainerList &containerList) const |
int | numAttributes () const |
int | numPredicates () const |
bool | hasAttribute (const ManagedAttribute &value) const |
bool | hasPredicate (const Predicate &value) const |
ManagedAttributeSet::const_iterator | begin () const |
ManagedAttributeSet::const_iterator | end () const |
int | recordLevel () const |
int | passLevel () const |
int | triggerLevel () const |
int | triggerAllLevel () const |
const char * | pattern () const |
bool | isMatch (const char *inputString) const |
bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
Static Public Member Functions | |
static int | hash (const Rule &rule, int size) |
Friends | |
bool | operator== (const Rule &, const Rule &) |
bool | operator!= (const Rule &, const Rule &) |
bsl::ostream & | operator<< (bsl::ostream &, const Rule &) |
This class defines a value-semantic object that holds a pattern, four threshold levels, and an attribute set. For each of these fields there is an accessor for obtaining the field value and a manipulator for changing that value. There are a few methods as well for directly adding/removing/searching attributes.
Additionally, this class supports a complete set of value semantic operations, including copy construction, assignment and equality comparison, and ostream
printing. A precise operational definition of when two instances have the same value can be found in the description of operator==
for the class. This class is exception neutral with no guarantee of rollback: If an exception is thrown during the invocation of a method on a pre-existing instance, the object is left in a valid state, but its value is undefined. In no event is memory leaked. Finally, aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases.
ball::Rule::Rule | ( | bslma::Allocator * | basicAllocator = 0 |
) | [explicit] |
ball::Rule::Rule | ( | const bsl::string_view & | pattern, | |
int | recordLevel, | |||
int | passLevel, | |||
int | triggerLevel, | |||
int | triggerAllLevel, | |||
bslma::Allocator * | basicAllocator = 0 | |||
) |
Create a Rule
object whose pattern is the specified pattern
and whose thresholds levels are the specified recordLevel
, passLevel
, triggerLevel
, and triggerAllLevel
respectively. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator will be used. The behavior is undefined unless each of the four threshold level values is not in the range [0 .. 255]. Note that a newly created Rule
object does not have any attributes.
ball::Rule::Rule | ( | const Rule & | original, | |
bslma::Allocator * | basicAllocator = 0 | |||
) |
Create a Rule
object that has the same value as that of the specified original
object. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator will be used.
ball::Rule::~Rule | ( | ) |
Destroy this object.
static int ball::Rule::hash | ( | const Rule & | rule, | |
int | size | |||
) | [static] |
Return a hash value calculated from the specified rule
using the specified size
as the number of slots. The value returned is guaranteed to be in the range [0 .. size - 1]
. The behavior is undefined unless 0 < size
.
ball::Rule::BSLMF_NESTED_TRAIT_DECLARATION | ( | Rule | , | |
bslma::UsesBslmaAllocator | ||||
) |
Assign to this object the value of the specified rhs
object.
int ball::Rule::addAttribute | ( | const ManagedAttribute & | value | ) |
Add an attribute having the specified value
to this object. Return 1 on success and 0 if an attribute having the same value already exists in this object.
int ball::Rule::addPredicate | ( | const ManagedAttribute & | value | ) |
DEPRECATED: Use addAttribute
instead.
int ball::Rule::removeAttribute | ( | const ManagedAttribute & | value | ) |
Remove the attribute having the specified value
from this object. Return the number of attributes being removed (i.e., 1 on success and 0 if no attribute having value
exists in this object).
int ball::Rule::removePredicate | ( | const ManagedAttribute & | value | ) |
DEPRECATED: Use removeAttribute
instead.
void ball::Rule::removeAll | ( | ) |
Remove all attributes from this rule.
void ball::Rule::removeAllPredicates | ( | ) |
DEPRECATED: Use removeAll
instead.
int ball::Rule::setLevels | ( | int | recordLevel, | |
int | passLevel, | |||
int | triggerLevel, | |||
int | triggerAllLevel | |||
) |
Set the threshold levels of this object to the specified recordLevel
, passLevel
, triggerLevel
, and triggerAllLevel
values, respectively, if each of the specified values is in the range [0 .. 255]. Return 0 on success, and a non-zero value otherwise (with no effect on the threshold levels of this object).
void ball::Rule::setPattern | ( | const bsl::string_view & | value | ) |
Set the pattern of this object to the specified value
.
bool ball::Rule::evaluate | ( | const AttributeContainerList & | containerList | ) | const |
Return true
if for every attribute maintained by this object, an attribute with the same name and value exists in the specified containerList
; and false
otherwise.
int ball::Rule::numAttributes | ( | ) | const |
Return the number of attributes managed by this object.
int ball::Rule::numPredicates | ( | ) | const |
DEPRECATED: Use numAttributes
instead.
bool ball::Rule::hasAttribute | ( | const ManagedAttribute & | value | ) | const |
Return true
if an attribute having specified value
exists in this object, and false
otherwise.
bool ball::Rule::hasPredicate | ( | const Predicate & | value | ) | const |
DEPRECATED: Use hasAttribute
instead.
ManagedAttributeSet::const_iterator ball::Rule::begin | ( | ) | const |
Return an iterator referring to the first member of the attribute set maintained by this object.
ManagedAttributeSet::const_iterator ball::Rule::end | ( | ) | const |
Return an iterator referring to one past the last member of the attribute set maintained by this object.
int ball::Rule::recordLevel | ( | ) | const |
Return the record level of this object.
int ball::Rule::passLevel | ( | ) | const |
Return the pass level of this object.
int ball::Rule::triggerLevel | ( | ) | const |
Return the trigger level of this object.
int ball::Rule::triggerAllLevel | ( | ) | const |
Return the trigger-all level of this object.
const char* ball::Rule::pattern | ( | ) | const |
Return the pattern of this object.
bool ball::Rule::isMatch | ( | const char * | inputString | ) | const |
Return true
if the specified inputString
matches the pattern of this rule, and false
otherwise. (For the definition of a string matching the pattern of a rule, please refer to the function-level documentation associated with the PatternUtil::isMatch
function).
bsl::ostream& ball::Rule::print | ( | bsl::ostream & | stream, | |
int | level = 0 , |
|||
int | spacesPerLevel = 4 | |||
) | const |
Format this object to the specified output stream
at the (absolute value of) the optionally specified indentation level
and return a reference to stream
. If level
is specified, optionally specify spacesPerLevel
, the number of spaces per indentation level for this and all of its nested objects. If level
is negative, suppress indentation of the first line. If spacesPerLevel
is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level
). If stream
is not valid on entry, this operation has no effect.
Return true
if the specified lhs
and rhs
objects have the same value, and false
otherwise. Two Rule
objects have the same value if they have the same attributes, the same four respective threshold levels, and the same pattern.
Return true
if the specified lhs
and rhs
objects do not have the same value, and false
otherwise. Two Rule
objects do not have the same value if they have different attributes, different values for any of the four respective threshold levels, or different patterns.
bsl::ostream& operator<< | ( | bsl::ostream & | , | |
const Rule & | ||||
) | [friend] |
Write the value of the specified rule
to the specified output
stream. Return the specified output
stream.