00001 /* -*- c++ -*- 00002 * $Id: Nodes.h,v 1.8 2006/05/16 20:06:34 brook Exp $ 00003 */ 00004 00005 /* 00006 * ClearSilver++ Software License. 00007 * 00008 * Copyright (c) 2005,2006 Brook Milligan <brook@nmsu.edu> 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without 00012 * modification, are permitted provided that the following conditions 00013 * are met: 00014 * 00015 * 1. Redistributions of source code must retain the above copyright 00016 * notice, this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above 00018 * copyright notice, this list of conditions and the following 00019 * disclaimer in the documentation and/or other materials provided 00020 * with the distribution. 00021 * 3. The name of the author may not be used to endorse or promote 00022 * products derived from this software without specific prior 00023 * written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00026 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00027 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00028 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00029 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00031 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00032 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00033 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 */ 00037 00043 #ifndef Nodes_h_ 00044 #define Nodes_h_ 1 00045 00046 #include <list> 00047 #include <string> 00048 #include <boost/operators.hpp> 00049 #include "ClearSilverNode.h" 00050 00051 namespace ClearSilver 00052 { 00064 class Nodes : boost::equality_comparable<Nodes> 00065 { 00066 private: 00067 typedef std::list<std::string> NameContainer; 00068 typedef std::list<ClearSilverNode> NodeContainer; 00069 00070 public: 00071 typedef std::string Name; 00072 typedef NodeContainer::size_type size_type; 00073 00074 private: 00075 NodeContainer nodes_; 00076 NameContainer names_; 00077 00078 public: 00080 //\{ 00082 Nodes (); 00084 Nodes (const Nodes& n); 00086 ~Nodes (); 00088 Nodes& operator = (const Nodes& n); 00089 //\} 00090 00092 bool empty () const; 00094 size_type size () const; 00096 std::string path () const; 00098 size_type depth () const; 00099 00101 void push (const Name&, const ClearSilverNode&); 00103 void pop (); 00105 ClearSilverNode top () const; 00106 00108 void swap (Nodes&) throw(); 00109 00111 friend bool operator == (const Nodes&, const Nodes&); 00112 00119 static bool& debug (); 00120 00128 void print () const; 00129 }; 00130 }; // namespace ClearSilver 00131 00132 #endif
1.4.5