update dev300-m58
[ooovba.git] / sal / inc / rtl / uri.hxx
blobe400f098c558fbfbfe1ce1e4aaecd28dddc4ec95
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: uri.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _RTL_URI_HXX_
32 #define _RTL_URI_HXX_
34 #include "rtl/malformeduriexception.hxx"
35 #include "rtl/uri.h"
36 #include "rtl/textenc.h"
37 #include "rtl/ustring.hxx"
38 #include "sal/types.h"
40 namespace rtl {
42 /** A wrapper around the C functions from <rtl/uri.h>.
44 class Uri
46 public:
47 /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
48 an array of 128 booleans as char class.
50 static inline rtl::OUString encode(rtl::OUString const & rText,
51 sal_Bool const * pCharClass,
52 rtl_UriEncodeMechanism eMechanism,
53 rtl_TextEncoding eCharset)
54 SAL_THROW(());
56 /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
57 a predefined rtl_UriCharClass enumeration member.
59 static inline rtl::OUString encode(rtl::OUString const & rText,
60 rtl_UriCharClass eCharClass,
61 rtl_UriEncodeMechanism eMechanism,
62 rtl_TextEncoding eCharset)
63 SAL_THROW(());
65 /** A wrapper around rtl_uriDecode() from <rtl/uri.h> (see there).
67 static inline rtl::OUString decode(rtl::OUString const & rText,
68 rtl_UriDecodeMechanism eMechanism,
69 rtl_TextEncoding eCharset)
70 SAL_THROW(());
72 /** A wrapper around rtl_uriConvertRelToAbs() from <rtl/uri.h> (see there).
74 @exception MalformedUriException
75 Thrown in case rtl_uriConvertRelToAbs() signals an exception due to a
76 malformed base URI.
78 static inline rtl::OUString convertRelToAbs(
79 rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
81 private:
82 /** not implemented
83 @internal */
84 Uri();
86 /** not implemented
87 @internal */
88 Uri(Uri &);
90 /** not implemented
91 @internal */
92 ~Uri();
94 /** not implemented
95 @internal */
96 void operator =(Uri);
99 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
100 sal_Bool const * pCharClass,
101 rtl_UriEncodeMechanism eMechanism,
102 rtl_TextEncoding eCharset)
103 SAL_THROW(())
105 rtl::OUString aResult;
106 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
107 pCharClass,
108 eMechanism,
109 eCharset,
110 &aResult.pData);
111 return aResult;
114 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
115 rtl_UriCharClass eCharClass,
116 rtl_UriEncodeMechanism eMechanism,
117 rtl_TextEncoding eCharset)
118 SAL_THROW(())
120 rtl::OUString aResult;
121 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
122 rtl_getUriCharClass(eCharClass),
123 eMechanism,
124 eCharset,
125 &aResult.pData);
126 return aResult;
129 inline rtl::OUString Uri::decode(rtl::OUString const & rText,
130 rtl_UriDecodeMechanism eMechanism,
131 rtl_TextEncoding eCharset)
132 SAL_THROW(())
134 rtl::OUString aResult;
135 rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
136 eMechanism,
137 eCharset,
138 &aResult.pData);
139 return aResult;
142 inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
143 rtl::OUString const & rRelUriRef)
145 rtl::OUString aResult;
146 rtl::OUString aException;
147 if (!rtl_uriConvertRelToAbs(
148 const_cast< rtl::OUString & >(rBaseUriRef).pData,
149 const_cast< rtl::OUString & >(rRelUriRef).pData, &aResult.pData,
150 &aException.pData))
151 throw MalformedUriException(aException);
152 return aResult;
157 #endif // _RTL_URI_HXX_