You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
862 B
33 lines
862 B
#ifndef _TOKEN_
|
|
#define _TOKEN_
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
#include <string>
|
|
#include <iostream>
|
|
|
|
namespace protocol::token {
|
|
using string_t = std::string;
|
|
using list_t = std::vector<string_t>;
|
|
|
|
std::string compose(const list_t& tokens);
|
|
list_t decompose(const std::string& input, size_t max_tokens = -1);
|
|
|
|
class pattern_t : public std::map<size_t, string_t> {
|
|
private:
|
|
bool wildcard;
|
|
|
|
public:
|
|
pattern_t();
|
|
pattern_t(list_t tokens, bool wildcard = false);
|
|
pattern_t(std::string input, bool wildcard = true);
|
|
|
|
list_t token_list() const;
|
|
|
|
friend std::ostream& operator<<(typeof(std::cout)& out, const pattern_t& pattern);
|
|
friend bool operator<(const pattern_t& l, const pattern_t& r);
|
|
friend bool operator==(const pattern_t& l, const pattern_t& r);
|
|
};
|
|
}
|
|
|
|
#endif |