/*============================================================================= Copyright (c) 2001-2014 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_SPIRIT_X3_TST_JUNE_03_2007_1031AM) #define BOOST_SPIRIT_X3_TST_JUNE_03_2007_1031AM #if defined(_MSC_VER) #pragma once #endif #include namespace boost { namespace spirit { namespace x3 { struct tst_pass_through { template Char operator()(Char ch) const { return ch; } }; template struct tst { typedef Char char_type; // the character type typedef T value_type; // the value associated with each entry typedef detail::tst_node node; tst() : root(0) { } ~tst() { clear(); } tst(tst const& rhs) : root(0) { copy(rhs); } tst& operator=(tst const& rhs) { return assign(rhs); } template T* find(Iterator& first, Iterator last, Filter filter) const { return node::find(root, first, last, filter); } template T* find(Iterator& first, Iterator last) const { return find(first, last, tst_pass_through()); } template T* add( Iterator first , Iterator last , typename boost::call_traits::param_type val) { return node::add(root, first, last, val, this); } template void remove(Iterator first, Iterator last) { node::remove(root, first, last, this); } void clear() { node::destruct_node(root, this); root = 0; } template void for_each(F f) const { node::for_each(root, std::basic_string(), f); } private: friend struct detail::tst_node; void copy(tst const& rhs) { root = node::clone_node(rhs.root, this); } tst& assign(tst const& rhs) { if (this != &rhs) { clear(); copy(rhs); } return *this; } node* root; node* new_node(Char id) { return new node(id); } T* new_data(typename boost::call_traits::param_type val) { return new T(val); } void delete_node(node* p) { delete p; } void delete_data(T* p) { delete p; } }; }}} #endif