Main Page | Class Hierarchy | Class List | File List | Class Members

xmlsimplestruct.h

00001 /* libIXAml - IXA Taldea. */
00002 
00003 #ifndef _XMLSIMPLESTRUCT_H
00004 #define _XMLSIMPLESTRUCT_H
00005 
00006 #include "xmlsimpleprolog.h"
00007 #include "xmlsimplenode.h"
00008 #include "xmlsimpledefs.h"
00009 #include <map>
00010 #include <string>
00011 #include <list>
00012 #include <fstream>
00013 #include <iconv.h>
00014 
00017 typedef enum EncodingType {
00018   
00019   UTF_8       = 0,              
00020   ISO_8859_15 = 1,              
00021   IXAENC_OTHER = 2              
00023 };
00024 
00027 typedef enum ValidationMode {
00028   
00029   NO_VALIDATION   = 0,         
00030   CUSTOM_DTD      = 1,         
00031   DOCUMENT_DTD    = 2          
00033 };
00034 
00035 /*
00036 
00037 validationMode ---------->  dokumentua irakurtzen edo idazten denean
00038                             balioztatu behar al da? hiru aukera:
00039                             
00040                             NO_VALIDATION ----> ez balioztatu
00041                             CUSTOM_DTD -------> gure DTDa erabili
00042                             DOCUMENT:DTD -----> dokumentuaren goiburuko DTDa erabili
00043 
00044 workingEncoding --------->  Zein kodeketa erabili behar du liburutegiko _funtzioen_ sarrera/irteera
00045 
00046 outputEncoding ---------->  Dokumentua idazterakoan zein kodeketa erabili
00047   
00048 */
00049 
00052 class XMLSimpleStruct {
00053   
00054   static ValidationMode defaultValidationMode;
00055   static EncodingType defaultWorkingEncoding;
00056   static EncodingType defaultOutputEncoding;  
00057 
00058   static std::map<EncodingType,const char*> enc2enc;            // EncodingType -> libxml++ formatura
00059   static std::map<EncodingType,const char*> enc2encInit();
00060   static iconv_t * converters;
00061   static iconv_t * initConverters();
00062 
00063  protected:
00064   
00065   XMLSimpleProlog prolog;                   
00066   bool prologWrite;                         
00067   XMLSimpleNode* root;                      
00068   std::list<XMLSimpleNode*> addresses;      
00069   ValidationMode validationMode;            
00070   EncodingType workingEncoding;             
00071   EncodingType outputEncoding;              
00072   std::string dtdFilePath;                  
00074  public:
00075 
00077   XMLSimpleStruct();
00078   
00082   XMLSimpleStruct(const XMLSimpleStruct & xss);
00083 
00094   XMLSimpleStruct(const XMLSimpleProlog & xsp, bool wp, XMLSimpleNode* xsn, const std::list<XMLSimpleNode*> & xsnLis, ValidationMode val, EncodingType enc, EncodingType enc2, const std::string & dtd);
00095 
00099   void putProlog(const XMLSimpleProlog & p);
00100 
00104   void putPrologWrite(bool w);
00105 
00109   void putRoot(XMLSimpleNode* n);
00110 
00114   void putValidationMode(ValidationMode val);
00115 
00119   void putWorkingEncoding(EncodingType enc);
00120 
00124   void putOutputEncoding(EncodingType enc);
00125   
00129   XMLSimpleProlog getProlog() const;
00130 
00134   bool getPrologWrite() const;
00135 
00139   XMLSimpleNode* getRoot() const;
00140 
00144   ValidationMode getValidationMode() const;                                     
00145 
00149   EncodingType getWorkingEncoding() const;
00150    
00154   EncodingType getOutputEncoding() const;
00155 
00159   XMLSimpleNode* createNode();
00160   
00165   XMLSimpleNode* createNode(const std::string & name);
00166 
00172   XMLSimpleNode* createNode(const std::string & name, const std::string & text);
00173   
00177   virtual void readFile(const std::string & fname) throw (char*) = 0;
00178 
00182   virtual void readFile(std::istream & file) throw (char*) = 0;
00183   
00187   virtual void readString(const std::string & inputstr) throw (char*) = 0;
00188   
00192   virtual void writeFile(const std::string & fname) const throw (char*) = 0;
00193   
00197   virtual void writeFile(std::ostream & file) const  throw (char*) = 0;
00198 
00202   virtual void writeCompressedFile(const std::string & fname) const throw (char*) = 0;
00203 
00207   virtual std::string writeString() const throw (char*) = 0;
00208 
00210   virtual ~XMLSimpleStruct();
00211   
00215   static ValidationMode getDefaultValidationMode();
00216  
00220   static void putDefaultValidationMode(ValidationMode vm);
00221 
00225   static EncodingType getDefaultWorkingEncoding();
00226   
00230   static void putDefaultWorkingEncoding(EncodingType enc);
00231   
00235   static EncodingType getDefaultOutputEncoding();
00236   
00240   static void putDefaultOutputEncoding(EncodingType enc);
00241  
00248   static std::string convert(const std::string & inputstr, EncodingType inputenc, EncodingType outputenc);
00249  
00250 };
00251 
00252 
00253 #endif // _XMLSIMPLESTRUCT_H

Generated on Tue Sep 11 12:07:45 2007 for libIXAml by doxygen 1.3.5