#pragma once

#include "klammer.h"
#include "target_registry.h"

class Klammer_registry
{
public:
    Klammer_registry() = default;
    void add(const Argtype_registry& argtypes, const Target_registry& targets,
             Option_set_registry& option_sets,
             std::vector<Katom>::iterator begin, std::vector<Katom>::iterator end, std::vector<Katom>& katoms);
    void rationalize(const Target_registry& targets);
    void check_klammer(const std::string& name, const std::string& target, const Locator& loc) const;
    const std::vector<Katom>* constant_body(const std::string& name) const;
    std::string instance_list(int margin) const;
    // With a search string, only the klammers whose NAME or DESCRIPTION
    // contains it, case-insensitively and with whitespace collapsed on both
    // sides (a description written across several lines in a ".k" file must
    // still match a phrase typed on one).  Empty when nothing matched, which
    // is how the caller knows to say so.
    // `defined_outside` restricts the listing to klammers with at least one
    // definition from a file not in the list -- the input's own klammers,
    // with the loaded klammersets' left out.
    std::string describe(int margin=0, const std::string& search="",
                         const strings_t& defined_outside={}) const;

    std::map<std::string, Klammer> m_klammers {};
};
