00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __ABSTRACTDOCUMENT_H
00013 #define __ABSTRACTDOCUMENT_H
00014
00015 #ifdef HAVE_CONFIG_H
00016 #include <config.h>
00017 #endif
00018
00019 #include <string>
00020 #include <vector>
00021
00022 #include <Common.h>
00023 #include <Error.h>
00024 #include <HashUtils.h>
00025 #include <XMLReader.h>
00026 #include <XMLWriter.h>
00027
00028
00029 using namespace std;
00030
00034 class AbstractDocument
00035 {
00036 public:
00040 AbstractDocument();
00041
00045 vector<string> getFieldNames() const;
00046
00052 DocumentError getField( string name, string &value ) const;
00053
00060 DocumentError setField( string name, string value, bool exists = false );
00061
00065 virtual string toXML() const = 0;
00066
00071 virtual DocumentError fromXML( const string &xml ) = 0;
00072
00073 protected:
00077 void fieldsToXML( XMLWriter &xml, const char *prefix ) const;
00078
00082 void fieldsFromXML( XMLReader &xml, const char *prefix,
00083 const hash_set<string,_hash_string> &ns_set ) throw (ParseException);
00084
00085 private:
00086 hash_map<string,string,_hash_string> fields;
00087 };
00088
00089 #endif