Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBxmlOStream.hxx

Go to the documentation of this file.
00001 #ifndef _CTBxmlOStream_HXX
00002 #define _CTBxmlOStream_HXX 1
00003 
00008 /*----------------------------------------------------------------------------*/
00009 /* C Tool Box: Designed and implemented by:                                   */
00010 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00011 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00012 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00013 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00014 /*----------------------------------------------------------------------------*/
00015 
00016 #include "CTBstring.hxx"
00017 #include "CTBtime.hxx"
00018 #include "CTBstack.hxx"
00019 
00020 class CTBxmlStartTag;
00021 class CTBxmlEmptyTag;
00022 class CTBxmlEndTag;
00023 
00024 class CTBxmlOStream {
00025   public:
00026                     CTBxmlOStream();
00027     explicit        CTBxmlOStream(ostream* p_os);
00028     explicit        CTBxmlOStream(const char* c_filename, int i_mode=ios::out, 
00029                                   int i_prot=0664);
00030 
00031     virtual         ~CTBxmlOStream();
00032 
00033     void            Attach(ostream* p_os);
00034     void            Open(const char* c_filename, int i_mode=ios::out, 
00035                          int i_prot=0664);
00036     void            Close();
00037 
00038     bool            Good() const;
00039     bool            Bad() const;
00040     bool            Fail() const;
00041     bool            Eof() const;
00042 
00043     void            PutStartTag(const char* c_name);
00044     void            PutEmptyTag(const char* c_name);
00045     void            PutEndTag();
00046 
00047     void            PutTaggedValue(const char* c_name, int i_value, 
00048                                    const char* c_format=0, int i_width=0);
00049     void            PutTaggedValue(const char* c_name, unsigned int i_value, 
00050                                    const char* c_format=0, int i_width=0);
00051 
00052     void            PutTaggedValue(const char* c_name, long i_value, 
00053                                    const char* c_format=0, int i_width=0);
00054     void            PutTaggedValue(const char* c_name, unsigned long i_value, 
00055                                    const char* c_format=0, int i_width=0);
00056 
00057     void            PutTaggedValue(const char* c_name, double d_value, 
00058                                    const char* c_format=0, int i_width=0,
00059                                    int i_precision=0);
00060 
00061     void            PutTaggedValue(const char* c_name,
00062                                    const char* c_value,
00063                                    bool b_dropempty=false);
00064     void            PutTaggedValue(const char* c_name,
00065                                    const CTBstring& value,
00066                                    bool b_dropempty=false);
00067     void            PutTaggedValue(const char* c_name,
00068                                    const CTBtime& value, 
00069                                    bool b_dropinvalid=false);
00070 
00071     ostream*        Stream() const;
00072     void            SetBad();
00073     void            SetFail();
00074 
00075     void            Dump(int i_indent=0, ostream& os=cout,
00076                          const char* p_text=0) const;
00077 
00078     bool            operator!() const;
00079 
00080                     operator void* () const;
00081 
00082     CTBxmlOStream&  operator<<(const char* c_text);
00083     CTBxmlOStream&  operator<<(char* c_text);
00084 
00085     CTBxmlOStream&  operator<<(const CTBxmlStartTag& tag);
00086     CTBxmlOStream&  operator<<(const CTBxmlEmptyTag& tag);
00087     CTBxmlOStream&  operator<<(const CTBxmlEndTag& tag);  
00088 
00089   private:
00090     void            PutEscapedString(const char* c_text, CTBint i_length = -1);
00091     void            PutEscapedString(const CTBstring& string);
00092 
00093   private:
00094     enum type { starttag,                   
00095                 endtag,                     
00096                 emptytag,                   
00097     };
00098 
00099     ostream*        mp_os;                  
00100     bool            mb_attached;            
00101     bool            mb_autonewline;         
00102     bool            mb_autoindent;          
00103     bool            mb_bad;                 
00104     bool            mb_fail;                
00105     int             mi_lasttag;             
00106     CTBstack<CTBstring> m_tagstack;         
00107 };
00108 
00109 template <class T>
00110 CTBxmlOStream&  operator<<(CTBxmlOStream& xos, const T& obj);
00111 
00112 //##############################################################################
00113 
00114 class CTBxmlStartTag {
00115   public:
00116     explicit        CTBxmlStartTag(const char* c_name = 0);
00117     const char*     Name() const;
00118   private:
00119     const char*     mc_name;
00120 };
00121 
00122 class CTBxmlEmptyTag {
00123   public:
00124     explicit        CTBxmlEmptyTag(const char* c_name = 0);
00125     const char*     Name() const;
00126   private:
00127     const char*     mc_name;
00128 };
00129 
00130 class CTBxmlEndTag {
00131   public:
00132                     CTBxmlEndTag();
00133   private:
00134 };
00135 
00136 #include "CTBxmlOStream.icc"
00137 
00138 #endif

Generated at Fri Oct 24 18:11:31 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001