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::core::string_view const &;
|
|
|
|
virtual boost::core::string_view *matches() = 0;
|
|
virtual const boost::core::string_view *matches() const = 0;
|
|
|
|
virtual boost::core::string_view *ids() = 0;
|
|
virtual const boost::core::string_view *ids() const = 0;
|
|
virtual std::size_t size() const = 0;
|
|
virtual void resize(std::size_t) = 0;
|
|
|
|
const_reference at(boost::core::string_view id) const;
|
|
|
|
const_reference operator[](boost::core::string_view id) const;
|
|
};
|
|
|
|
template <std::size_t N = 20>
|
|
class TemplateMatchStorage : public TemplateMatchStorageBase {
|
|
public:
|
|
boost::core::string_view *matches() final {
|
|
return m_matches;
|
|
}
|
|
|
|
virtual const boost::core::string_view *matches() const final {
|
|
return m_matches;
|
|
}
|
|
|
|
boost::core::string_view *ids() final {
|
|
return m_ids;
|
|
}
|
|
|
|
const boost::core::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::core::string_view m_matches[N];
|
|
boost::core::string_view m_ids[N];
|
|
std::size_t m_size;
|
|
};
|
|
|
|
using TemplateMatches = TemplateMatchStorage<20>;
|
|
|
|
#endif // __TEMPLATEMATCHS_H__
|