ConstHDFNode.h

Go to the documentation of this file.
00001 /* -*- c++ -*-
00002  * $Id: ConstHDFNode.h,v 1.7 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 ConstHDFNode_h_
00044 #define ConstHDFNode_h_ 1
00045 
00046 #include <string>
00047 #include <boost/shared_ptr.hpp>
00048 #include "ClearSilverNode.h"
00049 #include "Nodes.h"
00050 
00051 namespace ClearSilver
00052 {
00062   class ConstHDFNode
00063   {
00064   public:
00065     typedef std::string Name;
00066 
00067   private:
00068     bool is_iterator_;          // is this an iterator?
00069 
00070   private:
00071                                 // unimplemented assignment
00072     ConstHDFNode& operator = (const ConstHDFNode& n);
00073 
00074   protected:
00075     virtual Nodes nodes () const = 0;
00076     virtual Nodes& nodes () = 0;
00077     virtual void push (const Name&, const ClearSilverNode&) = 0;
00078     virtual void pop () = 0;
00079     virtual ClearSilverNode top () const = 0;
00080 
00081   protected:
00083     void swap (ConstHDFNode&) throw();
00084 
00086     Nodes find_node (const std::string&) const;
00096     bool& is_iterator ();
00097 
00098   public:
00100     //\{
00101                                 // constructors
00102     ConstHDFNode ();
00103     ConstHDFNode (const ConstHDFNode& n);
00104     ~ConstHDFNode () throw();
00105     //\}
00106 
00108     //\{
00109     bool empty () const;
00110     //\}
00111 
00113     //\{
00115     operator bool () const;
00117     operator std::string () const;
00118     //\}
00119 
00121     //\{
00123     std::string name () const;
00125     std::string value () const;
00126     //\}
00127 
00136     //\{
00137     std::string get_value () const;
00138     std::string get_value (const char* key) const;
00139     std::string get_value (const std::string& key) const;
00140     std::string get_value (const char* key, const char* default_value) const;
00141     std::string get_value (const std::string& key,
00142                            const std::string& default_value) const;
00143     
00144     void write_file (const char * filename) const;
00145     void write_file (const std::string& filename) const;
00146 
00147     void dump () const;
00148     void dump (const char* prefix) const;
00149     void dump (const std::string& prefix) const;
00150     //\}
00151 
00153     virtual ClearSilverNode node () const = 0;
00154 
00163     //\{
00164     static std::string Boolean (bool b);
00165     static std::string True ();
00166     static std::string False ();
00167     //\}
00168 
00170     bool is_dataset () const;
00172     bool is_reference () const;
00174     bool is_iterator () const;
00175 
00182    static bool& debug ();
00183   };
00184 };                              // namespace ClearSilver
00185 
00186 #endif

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