00001 /* -*- c++ -*- 00002 * $Id: HDF.h,v 1.46 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 HDF_h_ 00044 #define HDF_h_ 1 00045 00046 #include <iterator> 00047 #include <string> 00048 #include <boost/operators.hpp> 00049 #include <boost/shared_ptr.hpp> 00050 #include "ConstHDFNode.h" 00051 #include "HDFAttributes.h" 00052 #include "HDFNode.h" 00053 #include "Nodes.h" 00054 #include "RootNode.h" 00055 #include "SymlinkTarget.h" 00056 #include "TraceObject.h" 00057 00058 namespace ClearSilver 00059 { 00060 class ConstHDF; // forward declarations 00061 00076 class HDF : TraceObject, public ConstHDFNode, public HDFNode, 00077 boost::equality_comparable<HDF> 00078 { 00079 friend class ConstHDF; 00080 00081 public: 00083 //\{ 00084 typedef size_t size_type; 00085 struct input_iterator_tag {}; 00086 struct forward_iterator_tag : public input_iterator_tag {}; 00087 typedef forward_iterator_tag iterator_category; 00088 typedef HDF value_type; 00089 typedef ptrdiff_t difference_type; 00090 typedef HDF* pointer; 00091 typedef HDF reference; 00092 typedef HDF iterator; 00093 typedef HDF const_reference; 00094 typedef HDF const_iterator; 00095 //\} 00096 00097 protected: 00098 virtual Nodes nodes () const; 00099 virtual Nodes& nodes (); 00100 virtual void push (const ConstHDFNode::Name&, const ClearSilverNode&); 00101 virtual void pop (); 00102 virtual ClearSilverNode top () const; 00103 00104 public: 00106 //\{ 00108 HDF (); 00110 explicit HDF (const char * path); 00112 explicit HDF (const std::string& path); 00114 explicit HDF (const RootNode&); 00116 HDF (const HDF&); 00118 ~HDF () throw(); 00119 //\} 00120 00145 //\{ 00147 HDF& operator = (const HDF&); 00153 HDF& operator = (const char* value); 00163 HDF& operator = (const std::string& value); 00169 HDF& operator = (int value); 00177 HDF& operator = (bool value); 00184 HDF& operator = (const SymlinkTarget&); 00185 //\} 00186 00188 //\{ 00190 size_type depth () const; 00192 std::string path () const; 00193 //\} 00194 00196 //\{ 00197 const_reference operator [] (const char* key) const; 00198 const_reference operator [] (const std::string& key) const; 00199 reference operator [] (const char* key); 00200 reference operator [] (const std::string& key); 00201 //\} 00202 00204 //\{ 00205 const_iterator begin () const; 00206 const_iterator end () const; 00207 iterator begin (); 00208 iterator end (); 00209 00210 const_iterator find (const char* key) const; 00211 const_iterator find (const std::string& key) const; 00212 iterator find (const char* key); 00213 iterator find (const std::string& key); 00214 //\} 00215 00221 //\{ 00222 iterator& operator ++ (); 00223 iterator operator ++ (int); 00231 value_type operator * (); 00238 pointer operator -> (); 00239 //\} 00240 00242 //\{ 00243 HDF& copy (const HDF& dataset); 00244 HDF& copy (const char* key, const HDF& dataset); 00245 HDF& copy (const std::string& key, const HDF& dataset); 00246 //\} 00247 00249 virtual ClearSilverNode node () const; 00250 00252 ClearSilverNode HDF::root () const; 00253 00255 HDFAttributes attributes (); 00256 00258 void swap (HDF&) throw(); 00259 00261 friend bool operator == (const reference&, const reference&); 00262 00269 static bool& debug (); 00270 00271 private: 00272 RootNode root_; 00273 Nodes nodes_; 00274 }; 00275 00276 }; // namespace ClearSilver 00277 00278 #endif
1.4.5