MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / validateNewRule

Method validateNewRule

src/OpenColorIO/FileRules.cpp:605–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603}
604
605void FileRules::Impl::validateNewRule(size_t ruleIndex, const char * name) const
606{
607 if (!name || !*name)
608 {
609 throw Exception("File rules: rule should have a non-empty name.");
610 }
611 auto existingRule = std::find_if(m_rules.begin(), m_rules.end(),
612 [name](const FileRuleRcPtr & rule)
613 {
614 return 0==Platform::Strcasecmp(name, rule->getName());
615 });
616 if (existingRule != m_rules.end())
617 {
618 std::ostringstream oss;
619 oss << "File rules: A rule named '" << name << "' already exists.";
620 throw Exception(oss.str().c_str());
621 }
622 validatePosition(ruleIndex, DEFAULT_ALLOWED);
623 if (0==Platform::Strcasecmp(name, FileRules::DefaultRuleName))
624 {
625 std::ostringstream oss;
626 oss << "File rules: Default rule already exists at index "
627 << " '" << m_rules.size() - 1 << "'.";
628 throw Exception(oss.str().c_str());
629 }
630}
631
632const char * FileRules::Impl::getRuleFromFilepath(const Config & config, const char * filePath,
633 size_t & ruleIndex) const

Callers 1

insertRuleMethod · 0.45

Calls 5

StrcasecmpFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
getNameMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected