MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / _validate_results

Method _validate_results

simcore/framework/src/cli/cli.hpp:4418–4451  ·  view source on GitHub ↗

Run the results through the Validators

Source from the content-addressed store, hash-verified

4416 private:
4417 /// Run the results through the Validators
4418 void _validate_results(results_t &res) const {
4419 // Run the Validators (can change the string)
4420 if (!validators_.empty()) {
4421 if (type_size_max_ > 1) { // in this context index refers to the index in the type
4422 int index = 0;
4423 if (get_items_expected_max() < static_cast<int>(res.size()) &&
4424 multi_option_policy_ == CLI::MultiOptionPolicy::TakeLast) {
4425 // create a negative index for the earliest ones
4426 index = get_items_expected_max() - static_cast<int>(res.size());
4427 }
4428
4429 for (std::string &result : res) {
4430 if (result.empty() && type_size_max_ != type_size_min_ && index >= 0) {
4431 index = 0; // reset index for variable size chunks
4432 continue;
4433 }
4434 auto err_msg = _validate(result, (index >= 0) ? (index % type_size_max_) : index);
4435 if (!err_msg.empty()) throw ValidationError(get_name(), err_msg);
4436 ++index;
4437 }
4438 } else {
4439 int index = 0;
4440 if (expected_max_ < static_cast<int>(res.size()) && multi_option_policy_ == CLI::MultiOptionPolicy::TakeLast) {
4441 // create a negative index for the earliest ones
4442 index = expected_max_ - static_cast<int>(res.size());
4443 }
4444 for (std::string &result : res) {
4445 auto err_msg = _validate(result, index);
4446 ++index;
4447 if (!err_msg.empty()) throw ValidationError(get_name(), err_msg);
4448 }
4449 }
4450 }
4451 }
4452
4453 /** reduce the results in accordance with the MultiOptionPolicy
4454 @param[out] res results are assigned to res if there if they are different

Callers

nothing calls this directly

Calls 3

ValidationErrorClass · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected