1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_URI_HXX
21 #define INCLUDED_RTL_URI_HXX
23 #include <rtl/malformeduriexception.hxx>
25 #include <rtl/textenc.h>
26 #include <rtl/ustring.hxx>
27 #include <sal/types.h>
31 /** A wrapper around the C functions from <rtl/uri.h>.
36 /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
37 an array of 128 booleans as char class.
39 static inline rtl::OUString
encode(rtl::OUString
const & rText
,
40 sal_Bool
const * pCharClass
,
41 rtl_UriEncodeMechanism eMechanism
,
42 rtl_TextEncoding eCharset
)
45 /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
46 a predefined rtl_UriCharClass enumeration member.
48 static inline rtl::OUString
encode(rtl::OUString
const & rText
,
49 rtl_UriCharClass eCharClass
,
50 rtl_UriEncodeMechanism eMechanism
,
51 rtl_TextEncoding eCharset
)
54 /** A wrapper around rtl_uriDecode() from <rtl/uri.h> (see there).
56 static inline rtl::OUString
decode(rtl::OUString
const & rText
,
57 rtl_UriDecodeMechanism eMechanism
,
58 rtl_TextEncoding eCharset
)
61 /** A wrapper around rtl_uriConvertRelToAbs() from <rtl/uri.h> (see there).
63 @exception MalformedUriException
64 Thrown in case rtl_uriConvertRelToAbs() signals an exception due to a
67 static inline rtl::OUString
convertRelToAbs(
68 rtl::OUString
const & rBaseUriRef
, rtl::OUString
const & rRelUriRef
);
71 /** not implemented */
74 /** not implemented */
77 /** not implemented */
80 /** not implemented */
84 inline rtl::OUString
Uri::encode(rtl::OUString
const & rText
,
85 sal_Bool
const * pCharClass
,
86 rtl_UriEncodeMechanism eMechanism
,
87 rtl_TextEncoding eCharset
)
90 rtl::OUString aResult
;
91 rtl_uriEncode(const_cast< rtl::OUString
& >(rText
).pData
,
99 inline rtl::OUString
Uri::encode(rtl::OUString
const & rText
,
100 rtl_UriCharClass eCharClass
,
101 rtl_UriEncodeMechanism eMechanism
,
102 rtl_TextEncoding eCharset
)
105 rtl::OUString aResult
;
106 rtl_uriEncode(const_cast< rtl::OUString
& >(rText
).pData
,
107 rtl_getUriCharClass(eCharClass
),
114 inline rtl::OUString
Uri::decode(rtl::OUString
const & rText
,
115 rtl_UriDecodeMechanism eMechanism
,
116 rtl_TextEncoding eCharset
)
119 rtl::OUString aResult
;
120 rtl_uriDecode(const_cast< rtl::OUString
& >(rText
).pData
,
127 inline rtl::OUString
Uri::convertRelToAbs(rtl::OUString
const & rBaseUriRef
,
128 rtl::OUString
const & rRelUriRef
)
130 rtl::OUString aResult
;
131 rtl::OUString aException
;
132 if (!rtl_uriConvertRelToAbs(
133 const_cast< rtl::OUString
& >(rBaseUriRef
).pData
,
134 const_cast< rtl::OUString
& >(rRelUriRef
).pData
, &aResult
.pData
,
136 throw MalformedUriException(aException
);
142 #endif // INCLUDED_RTL_URI_HXX
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */