|
ROSE 2.1.0
|
Filter strings by exact matches, substring matches, and regex matches.
StringFilter provides flexible string filtering with three types of matching criteria:
Filters are specified using FilterSpecification objects which provide type-safe construction with explicit semantics. Multiple filters can be added to the same StringFilter instance, and a string matches if it satisfies any filter (OR logic).
Regex Support: Regular expressions use boost::regex with ECMAScript syntax. For regex filters, case sensitivity must be explicitly specified via FilterSpecification::CaseSensitivity. Both case-sensitive and case-insensitive regex patterns can coexist in the same StringFilter instance, allowing mixed matching strategies.
Performance: Regex patterns are compiled lazily on first match() call and cached for subsequent matches. Case-sensitive and case-insensitive patterns are compiled into separate regex objects for efficient matching.
Thread Safety: Not thread-safe. Each thread should use its own StringFilter instance.
Usage Examples:
#include <Rose/BinaryAnalysis/String.h>
Public Member Functions | |
| void | addFilter (const FilterSpecification &spec) |
| Add a filter specification. | |
| bool | match (const std::string &str) const |
| Test if a string matches any filter. | |
| void Rose::BinaryAnalysis::Strings::StringFilter::addFilter | ( | const FilterSpecification & | spec | ) |
Add a filter specification.
Adds a filter criterion to this StringFilter. The filter can be an exact match, substring match, or regex match with explicit case sensitivity.
| spec | The filter specification to add |
| bool Rose::BinaryAnalysis::Strings::StringFilter::match | ( | const std::string & | str | ) | const |
Test if a string matches any filter.
| str | The string to test |