|
#include <cstdio>
#include "matcher.hpp"
int main(int argc, char** argv)
{
const wchar_t query[] = L"foo AND ( bar OR quux )";
// Parse search query
ExpressionParser parser(query, wcslen(query), false);
// Initialize matcher
BooleanMatcher matcher(parser, false);
// Input text
const wchar_t text[] = L"jdfhgusdhfgjksdghrfjhiodfjgbkldfhfootuxcklnvsdh sduibarrgysiudfhguisdhrt iv";
// For each character of input text call feedCharacter
const wchar_t* ptr = text;
while (*ptr++)
{
matcher.feedCharacter(*ptr);
}
// Check if text matches our search query
if (matcher.evaluate())
{
printf("evaluate() == true\n");
// Get positions where search terms were found
MatchType res;
matcher.match(res);
printf("Match positions:\n");
for(int i = 0; i < res.size(); i++)
{
printf("offset - %I64d, size - %d\n", res[i]._pos, res[i]._size);
}
}
else
{
printf("evaluate() == false\n");
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
ApriorIT is a software research and development company specializing in cybersecurity and data management technology engineering. We work for a broad range of clients from Fortune 500 technology leaders to small innovative startups building unique solutions.
As Apriorit offers integrated research&development services for the software projects in such areas as endpoint security, network security, data security, embedded Systems, and virtualization, we have strong kernel and driver development skills, huge system programming expertise, and are reals fans of research projects.
Our specialty is reverse engineering, we apply it for security testing and security-related projects.
A separate department of Apriorit works on large-scale business SaaS solutions, handling tasks from business analysis, data architecture design, and web development to performance optimization and DevOps.
Official site: https://www.apriorit.com
Clutch profile: https://clutch.co/profile/apriorit