MCPcopy Create free account
hub / github.com/DFHack/dfhack / parseRegexParam

Function parseRegexParam

plugins/debug.cpp:511–528  ·  view source on GitHub ↗

\brief Helper to parse optional regex string safely

Source from the content-addressed store, hash-verified

509
510//! \brief Helper to parse optional regex string safely
511static command_result parseRegexParam(std::regex& target,
512 color_ostream& out,
513 std::vector<std::string>& parameters,
514 size_t pos)
515{
516 if (parameters.size() <= pos)
517 return CR_OK;
518 try {
519 std::regex temp{parameters[pos], defaultRegex};
520 target = std::move(temp);
521 } catch(std::regex_error & e) {
522 ERR(command,out) << "Failed to parse regular expression '"
523 << parameters[pos] << "'\n";
524 ERR(command,out) << "Parser message: " << e.what() << std::endl;
525 return CR_WRONG_USAGE;
526 }
527 return CR_OK;
528}
529
530/*!
531 * "Algorithm" to apply category filters based on optional regex parameters.

Callers 1

applyCategoryFiltersFunction · 0.85

Calls 2

sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected