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

156 lines
4.1 KiB
C++
Raw Normal View History

#pragma once
#include "../acl_cpp_define.hpp"
#include "noncopyable.hpp"
#include "string.hpp"
#include <list>
struct ACL_TOKEN;
struct ACL_ITER;
namespace acl {
class token_tree;
/**
* 256
*/
class ACL_CPP_API token_node : public noncopyable
{
public:
/**
*
* @return {const char*}
*/
const char* get_key(void) const;
/**
*
* @return {void*}
*/
void* get_ctx(void) const;
/**
*
* @return {token_tree*}
*/
token_tree* get_tree(void) const
{
return tree_;
}
/**
* C
* @return {ACL_TOKEN*}
*/
ACL_TOKEN* get_token(void) const
{
return me_;
}
private:
friend class token_tree; // 仅允许 token_tree 构造/析构本类对象
token_node(void);
~token_node(void);
void set_node(ACL_TOKEN* token, token_tree* tree);
private:
ACL_TOKEN* me_;
token_tree* tree_;
string key_;
bool dirty_;
};
/**
* 256 ()
* 256
*/
class ACL_CPP_API token_tree : public noncopyable
{
public:
token_tree(void);
~token_tree(void);
/**
*
* @param key {const char*}
* @param ctx {void*} key
* @return {bool} false key
*/
bool insert(const char* key, void* ctx = NULL);
/**
* key
* @param key {const char*}
* @return {void*}
*/
void* remove(const char* key);
/**
*
* @param key {const char*}
* @return {const token_node*} NULL
*/
const token_node* find(const char* key);
/**
*
*
* @param text {const char**}
*
* @param delimiters {const char*} NULL
*
* @param delimiters_tab {const char*} NULL
*
* create_delimiters_tab free_delimiters_tab
* @return {token_node*} NULL
* *text '\0'
* delimiters 使 delimiters
* delimiters_tab 使
*/
const token_node* search(const char** text, const char* delimiters = NULL,
const char* delimiters_tab = NULL);
/**
*
* @param delimiters {const char*}
* @return {char*}
*/
static char* create_delimiters_tab(const char* delimiters);
/**
* create_delimiters_tab
* @param delimiters_tab {char*}
*/
static void free_delimiters_tab(char* delimiters_tab);
/**
* 256
* @return {token_node*}
*/
const token_node* first_node(void);
/**
* 256
* @return {token_node*}
*/
const token_node* next_node(void);
/**
* C 256
* @return {ACL_TOKEN*}
*/
ACL_TOKEN* get_tree(void) const
{
return tree_;
}
private:
ACL_TOKEN* tree_;
ACL_ITER* iter_;
token_node node_;
};
} // namespace acl