ClearSilverNode.h

Go to the documentation of this file.
00001 /* -*- c++ -*-
00002  * $Id: ClearSilverNode.h,v 1.10 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 ClearSilverNode_h_
00044 #define ClearSilverNode_h_ 1
00045 
00046 #include <string>
00047 #include <boost/operators.hpp>
00048 #include "ClearSilverNodeComparator.h"
00049 
00050 class _hdf;                     // forward declarations
00051 class _attr;
00052 
00053 namespace ClearSilver
00054 {
00068   class ClearSilverNode : boost::equality_comparable<ClearSilverNode>
00069   {
00070   public:
00072     typedef _hdf HDF;
00073     typedef _attr HDF_ATTR;
00074 
00075   private:
00076     HDF* node_;
00077 
00078   public:
00080     //\{
00081                                 // Default constructor.
00082     ClearSilverNode ();
00095     explicit ClearSilverNode (HDF*);
00097     ClearSilverNode (const ClearSilverNode&);
00099     ~ClearSilverNode () throw();
00100 
00102     ClearSilverNode& operator = (const ClearSilverNode& n);
00108     ClearSilverNode& operator = (const char* value);
00118     ClearSilverNode& operator = (const std::string&);
00124     ClearSilverNode& operator = (int);
00132     ClearSilverNode& operator = (bool);
00133     //\}
00134 
00136     //\{
00138     bool empty () const;
00139     //\}
00140 
00142     //\{
00144     operator bool () const;
00145     //\}
00146 
00148     //\{
00150     std::string name () const;
00152     std::string value () const;
00153     //\}
00154 
00161     //\{
00163     HDF* get () const;
00165     ClearSilverNode top () const;
00167     ClearSilverNode next () const;
00169     ClearSilverNode child () const;
00171     HDF_ATTR* attr () const;
00172     //\}
00173 
00180     //\{
00181     std::string get_value (const std::string& key,
00182                            const std::string& default_value) const;
00183     void set_value (const std::string& key, const std::string& value);
00184     void set_value (const std::string& key, int value);
00185     void set_value (const std::string& key, unsigned int value);
00186     void set_value (const std::string& key, bool value);
00187 
00188     ClearSilverNode get_node (const std::string&);
00189     ClearSilverNode get_obj (const std::string&) const;
00190     ClearSilverNode get_child (const std::string&) const;
00191 
00192     void remove_tree ();
00193     void remove_tree (const std::string&);
00194 
00195     void read_file (const std::string&);
00196     void write_file (const std::string&) const;
00197     void dump (const std::string&) const;
00198 
00206     void copy (const std::string&, const ClearSilverNode&);
00207     //\}
00208 
00210     friend bool operator == (const ClearSilverNode&, const ClearSilverNode&);
00211 
00218     static bool& debug ();
00219 
00228     //\{
00230     static std::string Boolean (bool);
00232     static std::string True ();
00234     static std::string False ();
00235     //\}
00236 
00238     void swap (ClearSilverNode&) throw();
00239 
00241     void sort (ClearSilverNodeComparator::Ptr);
00242   };
00243 };                              // namespace ClearSilver
00244 
00245 #endif

Generated on Tue May 16 14:50:52 2006 for ClearSilver C++ Library by  doxygen 1.4.5