2026-07-18 18:48:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
#include <tuple>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "katom.h"
|
|
|
|
|
#include "argument.h"
|
|
|
|
|
#include "locator.h"
|
|
|
|
|
|
2026-07-30 23:50:07 +02:00
|
|
|
class Argtype_registry;
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
std::tuple<std::vector<std::vector<Katom>>,std::vector<std::vector<Katom>>,std::vector<Katom>>
|
|
|
|
|
argument_split(std::vector<Katom>::const_iterator kbegin, std::vector<Katom>::const_iterator kend,
|
|
|
|
|
long unsigned int positional_limit = std::numeric_limits<int>::max());
|
|
|
|
|
|
2026-08-06 13:11:37 +02:00
|
|
|
// The katoms of a parameter list, split into one list per parameter:
|
|
|
|
|
// positional first, then optional (each beginning with its option-name
|
|
|
|
|
// katom). An option set keeps the katoms of its members this way, because
|
|
|
|
|
// those katoms are what a declaration using the set ends up declaring.
|
|
|
|
|
std::tuple<std::vector<std::vector<Katom>>,std::vector<std::vector<Katom>>>
|
|
|
|
|
parameter_split(std::vector<Katom>::const_iterator kbegin, std::vector<Katom>::const_iterator kend);
|
|
|
|
|
|
2026-07-18 18:48:23 +02:00
|
|
|
class Parameter_set
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Parameter_set() {};
|
|
|
|
|
~Parameter_set() = default;
|
|
|
|
|
Parameter_set(const std::string parameter_string);
|
|
|
|
|
Parameter_set(const std::vector<Katom>& katoms);
|
2026-07-30 23:50:07 +02:00
|
|
|
Parameter_set(const std::vector<Katom>& katoms, const Argtype_registry& argtypes);
|
2026-07-18 18:48:23 +02:00
|
|
|
|
2026-07-30 23:50:07 +02:00
|
|
|
void parse_parameters(const std::vector<Katom>& katoms, const Argtype_registry& argtypes);
|
2026-07-18 18:48:23 +02:00
|
|
|
void describe_parameters();
|
|
|
|
|
|
|
|
|
|
void check_positional(
|
|
|
|
|
const std::vector<std::vector<Katom>>& positional_arguments, const Locator& loc);
|
|
|
|
|
std::map<std::string, std::string> check_optional(
|
|
|
|
|
const std::vector<std::vector<Katom>>& optional_arguments, const Locator& loc);
|
|
|
|
|
const std::map<std::string, std::string> value_map(
|
|
|
|
|
const std::vector<std::vector<Katom>>& positional,
|
|
|
|
|
const std::vector<std::vector<Katom>>& optional,
|
|
|
|
|
const std::vector<Katom>& rest,
|
|
|
|
|
const Locator& loc);
|
2026-07-22 18:17:43 +02:00
|
|
|
const Parameter* find(const std::string& name) const;
|
|
|
|
|
static void validate(
|
|
|
|
|
const Parameter& parameter, const std::string& value, const Locator& loc);
|
2026-07-18 18:48:23 +02:00
|
|
|
bool empty() const { return m_katoms.size() == 0; };
|
|
|
|
|
|
|
|
|
|
std::vector<Katom> m_katoms {};
|
2026-07-30 23:50:07 +02:00
|
|
|
//Argtype_registry m_argtypes {};
|
2026-07-18 18:48:23 +02:00
|
|
|
std::vector<Parameter> m_positional {};
|
|
|
|
|
std::vector<Parameter> m_optional {};
|
|
|
|
|
std::vector<std::string> m_optional_names {};
|
|
|
|
|
std::vector<Parameter> m_rest {};
|
|
|
|
|
size_t m_positional_count = std::numeric_limits<int>::max();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool operator==(Parameter_set lhs, Parameter_set rhs);
|
|
|
|
|
|
|
|
|
|
// The Argument_set alias is used at application sites, where the set
|
|
|
|
|
// describes arguments rather than parameters. See argument.h.
|
|
|
|
|
using Argument_set = Parameter_set;
|
|
|
|
|
|
|
|
|
|
void describe_arguments(
|
2026-07-30 23:50:07 +02:00
|
|
|
const std::string& label,
|
|
|
|
|
const std::vector<std::vector<Katom>>& positional,
|
|
|
|
|
const std::vector<std::vector<Katom>>& optional,
|
|
|
|
|
const std::vector<Katom>& rest);
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
std::string replace_arguments(
|
|
|
|
|
const std::map<std::string, std::string>& values,
|
|
|
|
|
const std::string& parameterized_text, const Locator& loc);
|