From: Christian P. <cp...@us...> - 2005-01-17 21:56:12
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22324/include/pclasses/IO Modified Files: BZip2.h IODevice.h IOError.h IOFilter.h IOStream.h StringDevice.h URL.h ZLib.h ZLibIOFilter.h Log Message: Added xxx_EXPORT macros for upcoming win32 and gcc visibility patch support. Index: URL.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/URL.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- URL.h 26 Dec 2004 16:26:01 -0000 1.1 +++ URL.h 17 Jan 2005 21:55:23 -0000 1.2 @@ -17,110 +17,144 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _purl_h_ -#define _purl_h_ +#ifndef P_IO_URL_h +#define P_IO_URL_h -// #include <pclasses/pexport.h> +#include <pclasses/Export.h> #include <pclasses/Exception.h> -// #include <pclasses/pnetdb.h> #include <iostream> +#include <map> #include <string> namespace P { + namespace IO { - //! Invalid url error - /*! - \ingroup net - \author Christian Prochnow <cp...@se...> - */ - class /* PNET_EXPORT*/ InvalidURL: public RuntimeError { - public: - inline InvalidURL(const char* _what, const SourceInfo& _si) throw() - : RuntimeError(_what,_si) {} - }; +//! Invalid url error +/*! + \author Christian Prochnow <cp...@se...> +*/ +class PIO_EXPORT InvalidURL: public RuntimeError { +public: + inline InvalidURL(const char* _what, const SourceInfo& _si) throw() + : RuntimeError(_what,_si) + { } +}; - //! Uniform resource locator - /*! - This class is used to parse and store uniform resource - locators. When storing a URL with password the password - will not be printed out by the operator<< but can - be retrieved via password(). - \ingroup net - \author Christian Prochnow <cp...@se...> - */ - class /*PNET_EXPORT*/ URL { +//! Uniform resource locator +/*! + This class is used to parse and store uniform resource + locators. When storing a URL with password the password + will not be printed out by the operator<< but can + be retrieved via password(). + \author Christian Prochnow <cp...@se...> +*/ +class PIO_EXPORT URL { public: + typedef std::map<std::string, std::string> ArgumentMap; + //! Default constructor /*! Initializes the URL to 'file:///' */ URL(); - + //! Parse URL constructor - URL(const std::string& url) throw(InvalidURL/*,NetDbError*/); - + URL(const std::string& url) throw(InvalidURL); + + //! Copy constructor URL(const URL& url); - - ~URL(); - inline const std::string& protocol() const - { return m_proto; } + ~URL() throw(); - /** - Achtung: setPort is currently ignored, and might go away, - due to a dep on network libs. - */ - void setProtocol(const std::string& proto, bool setPort = true); - - inline const std::string& host() const - { return m_host; } + const std::string& protocol() const throw(); + void setProtocol(const std::string& proto); + const std::string& host() const throw(); void setHost(const std::string& host); - inline const std::string& user() const - { return m_user; } - + const std::string& user() const throw(); void setUser(const std::string& user); - inline const std::string& password() const - { return m_passwd; } - + const std::string& password() const throw(); void setPassword(const std::string& passwd); - - inline unsigned short port() const - { return m_port; } + unsigned short port() const throw(); void setPort(unsigned short port); - - inline const std::string& path() const - { return m_path; } + const std::string& path() const throw(); void setPath(const std::string& path); + //! Returns the argument for the given key + const std::string& arg(const std::string& key) const throw(); + + //! Add argument to URL + void addArg(const std::string& name, const std::string& value); + + //! Set arguments + void setArgs(const ArgumentMap& args); + + //! Set arguments from URL-encoded string + void setArgs(const std::string& str); + + //! Returns arguments + const ArgumentMap& args() const throw(); + + //! Returns arguments as url encoded string + std::string args(std::string) const; + + //! Clear arguments + void clearArgs() throw(); + + //! Returns the anchor + const std::string& anchor() const throw(); + + //! Sets the anchor + void setAnchor(const std::string& anch); + + //! URL assignment operator URL& operator=(const URL& url); - URL& operator=(const std::string& url) throw(InvalidURL/*,NetDbError*/); - bool operator==(const URL& url) const; - + //! String assignment operator + URL& operator=(const std::string& url) throw(InvalidURL); + + //! Compare URLs + bool operator==(const URL& url) const throw(); + + //! Returns the URL as URL-encoded string std::string str() const; - - /* PNET_EXPORT*/ friend std::ostream& operator<<(std::ostream& os, const URL& url); - /*PNET_EXPORT*/ friend std::istream& operator>>(std::istream& is, URL& url) throw(InvalidURL); - + + //! URL-encodes the given string + static std::string encode(const std::string& str); + + //! URL-decodes the given string + static std::string decode(const std::string& str); + + friend PIO_EXPORT std::ostream& operator<<(std::ostream& os, + const URL& url); + + friend PIO_EXPORT std::istream& operator>>(std::istream& is, URL& url) + throw(InvalidURL); + + //! Returns a ArgumentMap for given URL-encoded argument-string + static ArgumentMap fromString(const std::string& args); + + //! Returns the URL-encoded string representation of the given ArgumentMap + static std::string toString(const ArgumentMap& args); + private: - /** - currently always returns 0. - */ - static unsigned short lookupPort(const std::string& service, const std::string& proto = "tcp"); // const? - std::string m_proto; - std::string m_host; - std::string m_user; - std::string m_passwd; - unsigned short m_port; - std::string m_path; - }; + std::string _proto; + std::string _host; + std::string _user; + std::string _passwd; + unsigned short _port; + std::string _path; + ArgumentMap _args; + std::string _anchor; +}; -}} // P::IO +} // !namespace IO + +} // !namespace P #endif Index: IOFilter.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOFilter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- IOFilter.h 6 Jan 2005 17:24:20 -0000 1.3 +++ IOFilter.h 17 Jan 2005 21:55:23 -0000 1.4 @@ -21,6 +21,7 @@ #ifndef P_IO_IOFilter_h #define P_IO_IOFilter_h +#include <pclasses/Export.h> #include <pclasses/IO/IOError.h> #include <pclasses/IO/IODevice.h> @@ -28,7 +29,7 @@ namespace IO { -class IOFilter { +class PIO_EXPORT IOFilter { public: IOFilter(); virtual ~IOFilter(); Index: ZLib.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/ZLib.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ZLib.h 6 Jan 2005 17:24:20 -0000 1.3 +++ ZLib.h 17 Jan 2005 21:55:23 -0000 1.4 @@ -21,6 +21,7 @@ #ifndef P_IO_ZLib_h #define P_IO_ZLib_h +#include <pclasses/Export.h> #include <pclasses/Exception.h> #include <pclasses/IntTypes.h> #include <string> @@ -33,7 +34,7 @@ namespace IO { //! ZLib error -class ZLibError: public RuntimeError { +class PIO_EXPORT ZLibError: public RuntimeError { public: ZLibError(int err, const char* msg, const char* what, const SourceInfo& si); ~ZLibError(); @@ -47,7 +48,7 @@ }; //! ZLib stream base -class ZLibStream { +class PIO_EXPORT ZLibStream { public: ZLibStream(size_t bufferSize); virtual ~ZLibStream(); @@ -74,7 +75,7 @@ }; //! ZLib output (deflate) stream -class ZLibOutputStream: public ZLibStream { +class PIO_EXPORT ZLibOutputStream: public ZLibStream { public: ZLibOutputStream(int level = 6, size_t bufferSize = 1024) throw(ZLibError); ~ZLibOutputStream() throw(); @@ -95,7 +96,7 @@ }; //! ZLib input (inflate) stream -class ZLibInputStream: public ZLibStream { +class PIO_EXPORT ZLibInputStream: public ZLibStream { public: ZLibInputStream(size_t bufferSize = 1024) throw(ZLibError); ~ZLibInputStream() throw(); Index: ZLibIOFilter.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/ZLibIOFilter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ZLibIOFilter.h 6 Jan 2005 17:24:20 -0000 1.2 +++ ZLibIOFilter.h 17 Jan 2005 21:55:23 -0000 1.3 @@ -21,6 +21,7 @@ #ifndef P_IO_ZLibIOFilter_h #define P_IO_ZLibIOFilter_h +#include <pclasses/Export.h> #include <pclasses/IO/IOFilter.h> #include <pclasses/IO/ZLib.h> @@ -32,7 +33,7 @@ /*! ZLib stream based I/O Filter. This is not a gzip filter! */ -class ZLibIOFilter: public IOFilter { +class PIO_EXPORT ZLibIOFilter: public IOFilter { public: ZLibIOFilter(); ~ZLibIOFilter(); Index: IODevice.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IODevice.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- IODevice.h 7 Jan 2005 13:33:15 -0000 1.5 +++ IODevice.h 17 Jan 2005 21:55:22 -0000 1.6 @@ -21,6 +21,7 @@ #ifndef P_IO_IODevice_h #define P_IO_IODevice_h +#include <pclasses/Export.h> #include <pclasses/BasicTypes.h> #include <pclasses/IO/IOError.h> @@ -32,7 +33,7 @@ class IOListener; //! I/O Device base class -class IODevice { +class PIO_EXPORT IODevice { public: friend class IOListener; friend class IOFilter; @@ -138,7 +139,7 @@ char* _readBuffNext; }; -class IOListener { +class PIO_EXPORT IOListener { public: enum EventFlags { None = 0x0, Index: IOStream.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOStream.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IOStream.h 30 Dec 2004 19:46:52 -0000 1.2 +++ IOStream.h 17 Jan 2005 21:55:23 -0000 1.3 @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include <pclasses/Export.h> #include <pclasses/IO/IODevice.h> #include <iostream> @@ -26,7 +27,7 @@ namespace IO { //! I/O Stream buffering class -class IOStreamBuffer: public std::streambuf { +class PIO_EXPORT IOStreamBuffer: public std::streambuf { public: IOStreamBuffer(IODevice& dev, size_t outBufferSize = 1024, size_t inBufferSize = 1024); @@ -47,7 +48,7 @@ //! I/O Stream that works with IODevice's -class IOStream: public std::iostream { +class PIO_EXPORT IOStream: public std::iostream { public: IOStream(IODevice& dev, size_t outBufferSize = 1024, size_t inBufferSize = 1024); Index: StringDevice.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/StringDevice.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StringDevice.h 1 Jan 2005 19:24:26 -0000 1.1 +++ StringDevice.h 17 Jan 2005 21:55:23 -0000 1.2 @@ -11,6 +11,8 @@ StringDevice is an experiment to get to know the IO layer better. It implements an IODevice interface into a Unicode::String buffer of arbitrary size. + + @@fixme .. implementation is out of sync!! */ class StringDevice : public IODevice { Index: BZip2.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/BZip2.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- BZip2.h 6 Jan 2005 18:30:33 -0000 1.1 +++ BZip2.h 17 Jan 2005 21:55:21 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_IO_BZip2_h #define P_IO_BZip2_h +#include <pclasses/Export.h> #include <pclasses/Exception.h> #include <pclasses/IntTypes.h> #include <string> @@ -30,7 +31,7 @@ namespace IO { //! BZip2 error -class BZip2Error: public RuntimeError { +class PIO_EXPORT BZip2Error: public RuntimeError { public: BZip2Error(int err, const char* what, const SourceInfo& si); ~BZip2Error(); @@ -43,7 +44,7 @@ }; //! Bzip2 stream base -class BZip2Stream { +class PIO_EXPORT BZip2Stream { public: BZip2Stream(size_t bufferSize); virtual ~BZip2Stream(); @@ -67,7 +68,7 @@ }; //! BZip2 output (deflate) stream -class BZip2OutputStream: public BZip2Stream { +class PIO_EXPORT BZip2OutputStream: public BZip2Stream { public: BZip2OutputStream(int level = 6, size_t bufferSize = 1024) throw(BZip2Error); ~BZip2OutputStream() throw(); @@ -88,7 +89,7 @@ }; //! BZip2 input (inflate) stream -class BZip2InputStream: public BZip2Stream { +class PIO_EXPORT BZip2InputStream: public BZip2Stream { public: BZip2InputStream(size_t bufferSize = 1024) throw(BZip2Error); ~BZip2InputStream() throw(); Index: IOError.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOError.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IOError.h 23 Dec 2004 05:23:31 -0000 1.2 +++ IOError.h 17 Jan 2005 21:55:23 -0000 1.3 @@ -21,6 +21,7 @@ #ifndef P_IO_IOError_h #define P_IO_IOError_h +#include <pclasses/Export.h> #include <pclasses/Exception.h> #include <pclasses/Unicode/String.h> @@ -29,7 +30,7 @@ namespace IO { //! I/O Error class -class IOError: public RuntimeError { +class PIO_EXPORT IOError: public RuntimeError { public: IOError(long errorNo, const char* what, const SourceInfo& si) throw(); IOError(const IOError& err) throw(); |