[#BloombergLP-ball-Rule]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::Rule
:relfileprefix: ../../
:mrdocs:

This class defines a value&hyphen;semantic object that holds a pattern, four threshold levels, and an attribute set&period; For each of these fields there is an accessor for obtaining the field value and a manipulator for changing that value&period; There are a few methods as well for directly adding&sol;removing&sol;searching attributes&period;

== Synopsis

Declared in `&lt;ball&lowbar;rule&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Rule;
----

== Description

Additionally, this class supports a complete set of _value_ _semantic_ operations, including copy construction, assignment and equality comparison, and `ostream` printing&period; A precise operational definition of when two instances have the same value can be found in the description of `operator&equals;&equals;` for the class&period; This class is _exception_ _neutral_ with no guarantee of rollback&colon; If an exception is thrown during the invocation of a method on a pre&hyphen;existing instance, the object is left in a valid state, but its value is undefined&period; In no event is memory leaked&period; Finally, _aliasing_ (e&period;g&period;, using all or part of an object as both source and destination) is supported in all cases&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/Rule/2constructor-0e36.adoc[`Rule`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/ball/Rule/operator_assign.adoc[`operator&equals;`] 
| Assign to this object the value of the specified `rhs` object&period;
| xref:BloombergLP/ball/Rule/addAttribute.adoc[`addAttribute`] 
| Add an attribute having the specified `value` to this object&period; Return 1 on success and 0 if an attribute having the same value already exists in this object&period;
| xref:BloombergLP/ball/Rule/addPredicate.adoc[`addPredicate`] 
| DEPRECATED&colon; Use `addAttribute` instead&period;
| xref:BloombergLP/ball/Rule/begin.adoc[`begin`] 
| Return an iterator referring to the first member of the attribute set maintained by this object&period;
| xref:BloombergLP/ball/Rule/end.adoc[`end`] 
| Return an iterator referring to one past the last member of the attribute set maintained by this object&period;
| xref:BloombergLP/ball/Rule/evaluate.adoc[`evaluate`] 
| Return `true` if for every attribute maintained by this object, an attribute with the same name and value exists in the specified `containerList`&semi; and `false` otherwise&period;
| xref:BloombergLP/ball/Rule/hasAttribute.adoc[`hasAttribute`] 
| Return `true` if an attribute having specified `value` exists in this object, and `false` otherwise&period;
| xref:BloombergLP/ball/Rule/hasPredicate.adoc[`hasPredicate`] 
| DEPRECATED&colon; Use `hasAttribute` instead&period;
| xref:BloombergLP/ball/Rule/isMatch.adoc[`isMatch`] 
| Return `true` if the specified `inputString` matches the pattern of this rule, and `false` otherwise&period; (For the definition of a string matching the pattern of a rule, please refer to the function&hyphen;level documentation associated with the `PatternUtil&colon;&colon;isMatch` function)&period;
| xref:BloombergLP/ball/Rule/numAttributes.adoc[`numAttributes`] 
| Return the number of attributes managed by this object&period;
| xref:BloombergLP/ball/Rule/numPredicates.adoc[`numPredicates`] 
| DEPRECATED&colon; Use `numAttributes` instead&period;
| xref:BloombergLP/ball/Rule/passLevel.adoc[`passLevel`] 
| Return the pass level of this object&period;
| xref:BloombergLP/ball/Rule/pattern.adoc[`pattern`] 
| Return the pattern of this object&period;
| xref:BloombergLP/ball/Rule/print.adoc[`print`] 
| Format this object to the specified output `stream` at the (absolute value of) the optionally specified indentation `level` and return a reference to `stream`&period; If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period;
| xref:BloombergLP/ball/Rule/recordLevel.adoc[`recordLevel`] 
| Return the record level of this object&period;
| xref:BloombergLP/ball/Rule/removeAll.adoc[`removeAll`] 
| Remove all attributes from this rule&period;
| xref:BloombergLP/ball/Rule/removeAllPredicates.adoc[`removeAllPredicates`] 
| DEPRECATED&colon; Use `removeAll` instead&period;
| xref:BloombergLP/ball/Rule/removeAttribute.adoc[`removeAttribute`] 
| Remove the attribute having the specified `value` from this object&period; Return the number of attributes being removed (i&period;e&period;, 1 on success and 0 if no attribute having `value` exists in this object)&period;
| xref:BloombergLP/ball/Rule/removePredicate.adoc[`removePredicate`] 
| DEPRECATED&colon; Use `removeAttribute` instead&period;
| xref:BloombergLP/ball/Rule/setLevels.adoc[`setLevels`] 
| 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 &lsqb;0 &period;&period; 255&rsqb;&period; Return 0 on success, and a non&hyphen;zero value otherwise (with no effect on the threshold levels of this object)&period;
| xref:BloombergLP/ball/Rule/setPattern.adoc[`setPattern`] 
| Set the pattern of this object to the specified `value`&period;
| xref:BloombergLP/ball/Rule/triggerAllLevel.adoc[`triggerAllLevel`] 
| Return the trigger&hyphen;all level of this object&period;
| xref:BloombergLP/ball/Rule/triggerLevel.adoc[`triggerLevel`] 
| Return the trigger level of this object&period;
| xref:BloombergLP/ball/Rule/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Rule, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/Rule/hash.adoc[`hash`] 
| Return a hash value calculated from the specified `rule` using the specified `size` as the number of slots&period; The value returned is guaranteed to be in the range `&lsqb;0 &period;&period; size &hyphen; 1&rsqb;`&period; The behavior is undefined unless `0 &lt; size`&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/ball/operator_lshift-0cf3.adoc[BloombergLP::ball::operator&lt;&lt;]`
| Write the value of the specified `rule` to the specified `output` stream&period; Return the specified `output` stream&period;
| `xref:BloombergLP/ball/operator_not_eq-0ac.adoc[BloombergLP::ball::operator!&equals;]`
| Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise&period; 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&period;
| `xref:BloombergLP/ball/operator_eq-0a.adoc[BloombergLP::ball::operator&equals;&equals;]`
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `Rule` objects have the same value if they have the same attributes, the same four respective threshold levels, and the same pattern&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
