Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / uri.h
1 /**
2  * \file
3  * \brief Classes for representing and manipulating URIs as per RFC 2396.
4  *
5  * Authors:
6  *   MenTaLguY <mental@rydia.net>
7  *   Jon A. Cruz <jon@joncruz.org>
8  *
9  * Copyright (C) 2003 MenTaLguY
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
14 #ifndef INKSCAPE_URI_H
15 #define INKSCAPE_URI_H
17 #include <glib/gtypes.h>
18 #include <exception>
19 #include <libxml/uri.h>
20 #include "bad-uri-exception.h"
22 namespace Inkscape {
24 /** \brief Represents an URI as per RFC 2396. */
25 class URI {
26 public:
27     URI(URI const &uri);
28     explicit URI(gchar const *preformed) throw(BadURIException);
29     ~URI();
31     bool isOpaque() const { return _impl->isOpaque(); }
32     bool isRelative() const { return _impl->isRelative(); }
33     bool isNetPath() const { return _impl->isNetPath(); }
34     bool isRelativePath() const { return _impl->isRelativePath(); }
35     bool isAbsolutePath() const { return _impl->isAbsolutePath(); }
36     const gchar *getScheme() const { return _impl->getScheme(); }
37     const gchar *getPath() const { return _impl->getPath(); }
38     const gchar *getQuery() const { return _impl->getQuery(); }
39     const gchar *getFragment() const { return _impl->getFragment(); }
40     const gchar *getOpaque() const { return _impl->getOpaque(); }
42     static URI fromUtf8( gchar const* path ) throw (BadURIException);
43     static URI from_native_filename(gchar const *path) throw(BadURIException);
44     static gchar *to_native_filename(gchar const* uri) throw(BadURIException);
46     gchar *toNativeFilename() const throw(BadURIException);
47     gchar *toString() const { return _impl->toString(); }
49     URI &operator=(URI const &uri);
51 private:
52     class Impl {
53     public:
54         static Impl *create(xmlURIPtr uri);
55         void reference();
56         void unreference();
58         bool isOpaque() const;
59         bool isRelative() const;
60         bool isNetPath() const;
61         bool isRelativePath() const;
62         bool isAbsolutePath() const;
63         const gchar *getScheme() const;
64         const gchar *getPath() const;
65         const gchar *getQuery() const;
66         const gchar *getFragment() const;
67         const gchar *getOpaque() const;
68         gchar *toString() const;
69     private:
70         Impl(xmlURIPtr uri);
71         ~Impl();
72         int _refcount;
73         xmlURIPtr _uri;
74     };
75     Impl *_impl;
76 };
78 }  /* namespace Inkscape */
80 #endif
82 /*
83   Local Variables:
84   mode:c++
85   c-file-style:"stroustrup"
86   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
87   indent-tabs-mode:nil
88   fill-column:99
89   End:
90 */
91 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :