00001
00002
00003 #if !defined(XmlStream_H)
00004 #define XmlStream_H
00005
00006 #include "XmlParser.h"
00007 #include "XmlNotify.h"
00008
00009 #include <string>
00010 #include <iostream>
00011 using namespace std;
00012
00013
00014
00016
00017
00018
00019
00020
00021 class XmlStream :
00022 public string
00023 {
00024 XmlNotify * _subscriber;
00025 public:
00026
00027 XmlStream () :
00028
00029 string (),
00030 _subscriber(NULL)
00031
00032 {}
00033
00034 virtual ~XmlStream ()
00035 {
00036 release();
00037 }
00038
00039
00040 bool create ()
00041 {
00042 return true;
00043 }
00044
00045 bool create ( char * buffer, long len )
00046 {
00047 if ( buffer && len > 0 )
00048 {
00049 assign( buffer, len );
00050 return true;
00051 }
00052 else
00053 return false;
00054 }
00055
00056 void release ()
00057 {
00058 erase( begin(), end() );
00059 }
00060
00061
00062 void foundNode ( string & name, string & attributes );
00063 void foundElement ( string & name, string & value, string & attributes );
00064
00065 void startElement ( string & name, string & value, string & attributes );
00066 void endElement ( string & name, string & value, string & attributes );
00067
00068
00069 bool save ( char * buffer );
00070 bool load ( char * buffer );
00071
00072
00073 bool parse ();
00074 bool parse ( char * buffer, long parseLength );
00075 bool parseNodes ( XmlParser & parser, char * buffer, long parseLength );
00076
00077
00078 bool hasSubscriber ()
00079 {
00080 if ( _subscriber )
00081 return true;
00082 else
00083 return false;
00084 }
00085
00086 XmlNotify * getSubscriber ()
00087 {
00088 return _subscriber;
00089 }
00090
00091 void setSubscriber ( XmlNotify & set )
00092 {
00093 _subscriber = &set;
00094 }
00095
00096
00097
00098 XmlStream & getTagStream ()
00099 { return *this; }
00100
00101
00102
00103 string & str()
00104 { return (string &) *this; }
00105 };
00106
00107
00108
00109 #endif