Schema Validator: minor cleanup

This commit is contained in:
Charles Dang 2020-12-21 14:57:07 +11:00
parent fe431d6056
commit 2bb69baf2b
2 changed files with 11 additions and 10 deletions

View file

@ -342,11 +342,6 @@ void schema_validator::validate_key(
}
}
void schema_validator::queue_message(const config& cfg, message_type t, const std::string& file, int line, int n, const std::string& tag, const std::string& key, const std::string& value)
{
cache_.top()[&cfg].emplace_back(t, file, line, n, tag, key, value);
}
const wml_tag& schema_validator::active_tag() const
{
assert(have_active_tag() && "Tried to get active tag name when there was none");
@ -583,7 +578,7 @@ void schema_self_validator::validate_key(const config& cfg, const std::string& n
} else if(tag_name == "tag" && name == "super") {
for(auto super : utils::split(cfg["super"])) {
referenced_tag_paths_.emplace_back(super, file, start_line, tag_name);
derivations_.emplace(std::make_pair(current_path(), super));
derivations_.emplace(current_path(), super);
}
} else if(condition_nesting_ == 0 && tag_name == "tag" && name == "name") {
tag_stack_.top() = value;
@ -608,7 +603,7 @@ std::string schema_self_validator::current_path() const
bool schema_self_validator::reference::operator<(const reference& other) const
{
return std::make_tuple(file_, line_) < std::make_tuple(other.file_, other.line_);
return std::tie(file_, line_) < std::tie(other.file_, other.line_);
}
bool schema_self_validator::reference::match(const std::set<std::string>& with)

View file

@ -113,7 +113,7 @@ protected:
/** Controls the way to print errors. */
bool create_exceptions_;
virtual void print(message_info&);
private:
@ -141,8 +141,14 @@ private:
wml_type::map types_;
bool validate_schema_;
protected:
void queue_message(const config& cfg, message_type t, const std::string& file, int line = 0, int n = 0, const std::string& tag = "", const std::string& key = "", const std::string& value = "");
template<typename... T>
void queue_message(const config& cfg, T&&... args)
{
cache_.top()[&cfg].emplace_back(std::forward<T>(args)...);
}
const wml_tag& active_tag() const;
std::string active_tag_path() const;
bool have_active_tag() const;
@ -184,7 +190,7 @@ private:
bool tag_path_exists(const config& cfg, const reference& ref);
void check_for_duplicates(const std::string& name, std::vector<std::string>& seen, const config& cfg, message_type type, const std::string& file, int line, const std::string& tag);
static bool name_matches(const std::string& pattern, const std::string& name);
void print(message_info& message) override;
enum { WRONG_TYPE = NEXT_ERROR, WRONG_PATH, DUPLICATE_TAG, DUPLICATE_KEY, NEXT_ERROR };
};