1 #ifndef PARAMETER_LIST_BASE_H
2 #define PARAMETER_LIST_BASE_H
74 template<
class CharSeq>
84 new std::vector<std::string>(*other.
_params) : nullptr),
103 return str() == other.
str();
108 return !(*
this == other);
136 operator bool ()
const {
141 std::string
str()
const;
150 std::vector<std::string>::iterator
begin() {
152 return null() ? vector<string>::iterator() :
_params->begin();
155 std::vector<std::string>::const_iterator
begin()
const {
167 std::vector<std::string>::iterator
end() {
169 return null() ? vector<string>::iterator() :
_params->end();
172 std::vector<std::string>::const_iterator
end()
const {
174 return null() ? vector<string>::const_iterator() :
_params->
end();
185 std::string
const &
at(
size_t n)
const {
188 throw out_of_range(
"Out of range in parameter_list_base::at(size_t)");
193 std::string &
at(
size_t n) {
196 throw out_of_range(
"Out of range in parameter_list_base::at(size_t)");
219 size_t which(std::string
const &
str)
const;
231 template<
class CharSeq>
243 template<
typename BiIter>
244 static std::string
make(BiIter first, BiIter last) {
245 std::string s(1,
'(');
247 auto last_but_one = last;
248 std::advance(last_but_one,-1);
249 for ( ;first != last_but_one; ++first) {
250 s += std::string(*first) +
',';
252 s += std::string(first);
273 std::shared_ptr<std::vector<std::string>>
_params;
bool well_formed() const
Say whether the parameter_list_base is well-formed.
std::string const & at(size_t n) const
Get a range-checked [const] reference to the nth parameter.
bool operator!=(parameter_list_base const &other) const
Inequality.
std::string str() const
Cast the parameter list to its canonical string representation.
size_t size() const
Get the number of parameters in the parameter_list_base
void read(chewer< CharSeq > &chew)
Read the parameter_list_base from chewer<CharSeq>
parameter_list_base(parameter_list_base const &other)
Copy constructor.
template struct innards::parameter_list_base<Tag> generically defines a common interface of types rep...
static std::string make(BiIter first, BiIter last)
Make a parameter list from a range of objects that are convertible to std::string.
defect
Enumeration of possible defects in a parameter_list_base
std::vector< std::string >::iterator begin()
Get a [const] iterator to the start of the parameter list.
parameter_list_base & operator=(parameter_list_base other)
Assignment.
parameter_list_base(size_t n=0)
Constructor for n parameters.
bool operator==(parameter_list_base const &other) const
Equality.
Non-identifier where parameter expected.
void swap(parameter_list_base &other)
Swap with another parameter_list_base
std::vector< std::string >::iterator end()
Get a [const] iterator to the end of the parameter list.
std::shared_ptr< std::vector< std::string > > _params
The list of parameters.
parameter_list_base(chewer< CharSeq > &chew)
Explicitly construct a given a chewer<CharSeq>.
defect _defect
Is the parameter_list_base well-formed?
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
bool variadic() const
Say whether the parameter_list_base is variadic.
std::string const & operator[](size_t n) const
Get an un-range-checked [const] reference to the nth parameter.
struct symbol encapsulates a preprocessor symbol's state
size_t which(std::string const &str) const
Get the index of the parameter that matches a string, if any, else -1.
bool null() const
Say whether the parameter_list_base is null, i.e. is not even "()".
bool _variadic
Is the parameter_list_base variadic?