acl/lib_acl_cpp/include/acl_cpp/stdlib/token_tree.hpp

143 lines
3.1 KiB
C++
Raw Normal View History

#pragma once
#include "../acl_cpp_define.hpp"
#include "string.hpp"
#include <list>
struct ACL_TOKEN;
struct ACL_ITER;
namespace acl {
class token_tree;
/**
* 256 <EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĽڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
class ACL_CPP_API token_node
{
public:
/**
* <EFBFBD><EFBFBD><EFBFBD>øýڵ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
* @return {const char*}
*/
const char* get_key(void) const
{
return key_.c_str();
}
/**
* <EFBFBD><EFBFBD><EFBFBD>øýڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>󶨵Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @return {void*}
*/
void* get_ctx(void) const;
/**
* <EFBFBD><EFBFBD><EFBFBD>øýڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {token_tree*}
*/
token_tree* get_tree(void) const
{
return tree_;
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> C <EFBFBD><EFBFBD>Ľڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {ACL_TOKEN*}
*/
ACL_TOKEN* get_token(void) const
{
return me_;
}
private:
friend class token_tree; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> token_tree <20><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
token_node(void);
~token_node(void);
void set_node(ACL_TOKEN* token, token_tree* tree);
private:
ACL_TOKEN* me_;
token_tree* tree_;
string key_;
};
/**
* 256 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>dz<EFBFBD><EFBFBD>ߵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD>ȹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD>)<EFBFBD><EFBFBD>
* ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD> 256 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
class ACL_CPP_API token_tree
{
public:
token_tree(void);
~token_tree(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>
* @param key {const char*} <EFBFBD><EFBFBD>ֵ
* @param ctx {void*} <EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD>󶨵Ķ<EFBFBD><EFBFBD>󣬿<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ key <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD>
*/
bool insert(const char* key, void* ctx = NULL);
/**
* <EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD>
* @param key {const char*} <EFBFBD><EFBFBD>ֵ
* @return {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>󶨵Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
*/
void* remove(const char* key);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> haystack <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>Ľڵ<EFBFBD>
* @param haystack {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @return {const token_node*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD>ʾδ<EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
const token_node* search(const char* haystack);
/**
* <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EF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BD><EFBFBD><EFBFBD>ټ<EFBFBD><EFBFBD><EFBFBD>
* delimiters_tab <EFBFBD>Ƿ<EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD>
*/
const token_node* match(const char** text, const char* delimiters = NULL,
const char* delimiters_tab = NULL);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 256 ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {token_node*}
*/
const token_node* first_node(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 256 ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {token_node*}
*/
const token_node* next_node(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> C <EFBFBD><EFBFBD><EFBFBD> 256 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {ACL_TOKEN*}
*/
ACL_TOKEN* get_tree(void) const
{
return tree_;
}
private:
ACL_TOKEN* tree_;
ACL_ITER* iter_;
token_node node_;
};
} // namespace acl