58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
|
#ifndef __TEMPLATEMATCHS_H__
|
||
|
#define __TEMPLATEMATCHS_H__
|
||
|
|
||
|
#include <boost/url/string_view.hpp>
|
||
|
|
||
|
class TemplateMatchStorageBase {
|
||
|
public:
|
||
|
using const_reference = boost::urls::string_view const &;
|
||
|
|
||
|
virtual boost::urls::string_view *matches() = 0;
|
||
|
virtual const boost::urls::string_view *matches() const = 0;
|
||
|
|
||
|
virtual boost::urls::string_view *ids() = 0;
|
||
|
virtual const boost::urls::string_view *ids() const = 0;
|
||
|
virtual std::size_t size() const = 0;
|
||
|
virtual void resize(std::size_t) = 0;
|
||
|
|
||
|
const_reference at(boost::urls::string_view id) const;
|
||
|
|
||
|
const_reference operator[](boost::urls::string_view id) const;
|
||
|
};
|
||
|
|
||
|
template <std::size_t N = 20>
|
||
|
class TemplateMatchStorage : public TemplateMatchStorageBase {
|
||
|
public:
|
||
|
boost::urls::string_view *matches() final {
|
||
|
return m_matches;
|
||
|
}
|
||
|
|
||
|
virtual const boost::urls::string_view *matches() const final {
|
||
|
return m_matches;
|
||
|
}
|
||
|
|
||
|
boost::urls::string_view *ids() final {
|
||
|
return m_ids;
|
||
|
}
|
||
|
|
||
|
const boost::urls::string_view *ids() const final {
|
||
|
return m_ids;
|
||
|
}
|
||
|
|
||
|
std::size_t size() const final {
|
||
|
return m_size;
|
||
|
}
|
||
|
void resize(std::size_t n) final {
|
||
|
m_size = n;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
boost::urls::string_view m_matches[N];
|
||
|
boost::urls::string_view m_ids[N];
|
||
|
std::size_t m_size;
|
||
|
};
|
||
|
|
||
|
using TemplateMatches = TemplateMatchStorage<20>;
|
||
|
|
||
|
#endif // __TEMPLATEMATCHS_H__
|