MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / evalGrep

Method evalGrep

app/exiv2.cpp:500–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498} // Params::setLogLevel
499
500int Params::evalGrep(const std::string& optArg) {
501 // check that string ends in "/i"
502 bool bIgnoreCase = optArg.size() > 2 && optArg.back() == 'i' && optArg[optArg.size() - 2] == '/';
503 auto pattern = bIgnoreCase ? optArg.substr(0, optArg.size() - 2) : optArg;
504
505 try {
506 // use POSIX syntax, optimize for faster matching, treat all sub expressions as unnamed
507 auto flags = std::regex::basic | std::regex::optimize | std::regex::nosubs;
508 flags = bIgnoreCase ? flags | std::regex::icase : flags;
509 // try and emplace regex into vector
510 // might throw if invalid pattern
511 greps_.emplace_back(pattern, flags);
512 } catch (std::regex_error const&) {
513 // there was an error compiling the regexp
514 std::cerr << progname() << ": " << _("Option") << " -g: " << _("Invalid regexp") << " \"" << optArg << "\n";
515 return 1;
516 }
517
518 return 0;
519} // Params::evalGrep
520
521int Params::evalKey(const std::string& optArg) {
522 int result = 0;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected