#ifndef _CONFIGFACTORY_H #define _CONFIGFACTORY_H #include <qstring.h> #include <qsize.h> #include <qdom.h> #include <exception> #include <string> class ConfigFile { public: class Exception : public std::exception { public: Exception ( ); Exception ( const QString & message ); Exception ( const std::string & message ); Exception ( const Exception & source ); Exception ( const std::exception & source ); virtual ~Exception ( ) throw ( ); const char * what ( ) const throw ( ); private: QString m_message; }; ~ConfigFile ( ); bool IsValid ( ) const; bool NewImageSmooth ( ) const; const QSize & NewImageSize ( ) const; int NewImageJpegQuality ( ) const; int NewImageRatioIndex ( ) const; friend ConfigFile & TheConfigFile ( const QString & sourcefile = "" ); private: bool m_valid, m_smooth; QSize m_newimageSize; int m_jpegQuality, m_ratioIndex; ConfigFile ( const QString & sourcefile ); bool ParseFile ( const QString & sourcefile ); QDomNode FindNode ( const QDomNode & element, const QString & type, const QString & name ) const; QString GetFieldValue ( const QDomDocument & document, const QString & section, const QString & field ) const; int GetFieldValueAsInt ( int defaultValue, const QDomDocument & document, const QString & section, const QString & field ) const; bool GetFieldValueAsBool ( bool defaultValue, const QDomDocument & document, const QString & section, const QString & field ) const; int GetFieldValueAsIndex ( int defaultValue, const char * list [], const QDomDocument & document, const QString & section, const QString & field ) const; }; ConfigFile & TheConfigFile ( const QString & sourcefile ); #endif