52 lines
1.5 KiB
C
52 lines
1.5 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
#include <variant>
|
||
|
|
#include <functional>
|
||
|
|
#include <regex>
|
||
|
|
|
||
|
|
#include "locator.h"
|
||
|
|
|
||
|
|
using argtype_t = std::variant<bool,double,std::string,std::vector<std::string>>;
|
||
|
|
|
||
|
|
using modify_string_f = std::function<std::string(std::vector<std::string>)>;
|
||
|
|
|
||
|
|
class Argtype
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
Argtype()
|
||
|
|
: m_name("default")
|
||
|
|
, m_desc("default argument type")
|
||
|
|
, m_symbolic_pattern(".+")
|
||
|
|
, m_pattern(".+")
|
||
|
|
, m_python_cast("str")
|
||
|
|
, m_python_format()
|
||
|
|
, m_loc()
|
||
|
|
{};
|
||
|
|
|
||
|
|
Argtype(std::string name, std::string desc, std::string symbolic_pattern, std::string pattern,
|
||
|
|
std::string python_cast, modify_string_f python_format,
|
||
|
|
const Locator& loc);
|
||
|
|
|
||
|
|
std::string python_value(const std::string& var_name, std::vector<std::string> value, size_t name_size);
|
||
|
|
|
||
|
|
std::string m_name {};
|
||
|
|
std::string m_desc {};
|
||
|
|
std::string m_symbolic_pattern {};
|
||
|
|
std::string m_pattern {};
|
||
|
|
std::string m_python_cast {};
|
||
|
|
modify_string_f m_python_format {};
|
||
|
|
std::regex m_regex {};
|
||
|
|
int m_count {1};
|
||
|
|
int m_mincount {1};
|
||
|
|
int m_maxcount {1};
|
||
|
|
Locator m_loc;
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
std::string pyformat_string(const std::vector<std::string>& value);
|
||
|
|
std::string pyformat_bool(const std::vector<std::string>& value);
|
||
|
|
std::string pyformat_number(const std::vector<std::string>& value);
|
||
|
|
std::string pyformat_list(const std::vector<std::string>& value);
|
||
|
|
std::string pyformat_dlist(const std::vector<std::string>& value);
|