LibreOffice: rtl/uri.hxx Source File

LibreOffice LibreOffice 5.0 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

uri.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #ifndef INCLUDED_RTL_URI_HXX
21 #define INCLUDED_RTL_URI_HXX
22
23 #include <rtl/malformeduriexception.hxx>
24 #include <rtl/uri.h>
25 #include <rtl/textenc.h>
26 #include <rtl/ustring.hxx>
27 #include <sal/types.h>
28
29 namespace rtl {
30
33 class Uri
34 {
35 public:
39 static inline rtl::OUString encode(rtl::OUString const & rText,
40 sal_Bool const * pCharClass,
41 rtl_UriEncodeMechanism eMechanism,
42 rtl_TextEncoding eCharset);
43
47 static inline rtl::OUString encode(rtl::OUString const & rText,
48 rtl_UriCharClass eCharClass,
49 rtl_UriEncodeMechanism eMechanism,
50 rtl_TextEncoding eCharset);
51
54 static inline rtl::OUString decode(rtl::OUString const & rText,
55 rtl_UriDecodeMechanism eMechanism,
56 rtl_TextEncoding eCharset);
57
64 static inline rtl::OUString convertRelToAbs(
65 rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
66
67 private:
68 Uri() SAL_DELETED_FUNCTION;
69
70 Uri(Uri &) SAL_DELETED_FUNCTION;
71
72 ~Uri() SAL_DELETED_FUNCTION;
73
74 void operator =(Uri) SAL_DELETED_FUNCTION;
75 };
76
77 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
78 sal_Bool const * pCharClass,
79 rtl_UriEncodeMechanism eMechanism,
80 rtl_TextEncoding eCharset)
81 {
82 rtl::OUString aResult;
83 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
84 pCharClass,
85 eMechanism,
86 eCharset,
87 &aResult.pData);
88 return aResult;
89 }
90
91 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
92 rtl_UriCharClass eCharClass,
93 rtl_UriEncodeMechanism eMechanism,
94 rtl_TextEncoding eCharset)
95 {
96 rtl::OUString aResult;
97 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
98 rtl_getUriCharClass(eCharClass),
99 eMechanism,
100 eCharset,
101 &aResult.pData);
102 return aResult;
103 }
104
105 inline rtl::OUString Uri::decode(rtl::OUString const & rText,
106 rtl_UriDecodeMechanism eMechanism,
107 rtl_TextEncoding eCharset)
108 {
109 rtl::OUString aResult;
110 rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
111 eMechanism,
112 eCharset,
113 &aResult.pData);
114 return aResult;
115 }
116
117 inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
118 rtl::OUString const & rRelUriRef)
119 {
120 rtl::OUString aResult;
121 rtl::OUString aException;
122 if (!rtl_uriConvertRelToAbs(
123 const_cast< rtl::OUString & >(rBaseUriRef).pData,
124 const_cast< rtl::OUString & >(rRelUriRef).pData, &aResult.pData,
125 &aException.pData))
126 throw MalformedUriException(aException);
127 return aResult;
128 }
129
130 }
131
132 #endif // INCLUDED_RTL_URI_HXX
133
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Uri::encode
static rtl::OUString encode(rtl::OUString const &rText, sal_Bool const *pCharClass, rtl_UriEncodeMechanism eMechanism, rtl_TextEncoding eCharset)
A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using an array of 128 booleans as char...
Definition: uri.hxx:77
uri.h
textenc.h
rtl::MalformedUriException
An exception indicating a malformed URI.
Definition: malformeduriexception.hxx:31
rtl_UriDecodeMechanism
rtl_UriDecodeMechanism
The mechanism describing how rtl_uriDecode() translates (part of) a URI into a Unicode string...
Definition: uri.h:171
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:404
malformeduriexception.hxx
sal_Bool
unsigned char sal_Bool
Definition: types.h:48
rtl::Uri::decode
static rtl::OUString decode(rtl::OUString const &rText, rtl_UriDecodeMechanism eMechanism, rtl_TextEncoding eCharset)
A wrapper around rtl_uriDecode() from <rtl/uri.h> (see there).
Definition: uri.hxx:105
rtl_getUriCharClass
SAL_DLLPUBLIC sal_Bool const * rtl_getUriCharClass(rtl_UriCharClass eCharClass) SAL_THROW_EXTERN_C()
Map a predefined rtl_UriCharClass to a form usable by rtl_uriEncode().
rtl_uriConvertRelToAbs
SAL_DLLPUBLIC sal_Bool rtl_uriConvertRelToAbs(rtl_uString *pBaseUriRef, rtl_uString *pRelUriRef, rtl_uString **pResult, rtl_uString **pException) SAL_THROW_EXTERN_C()
Convert a relative URI reference into an absolute URI.
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
rtl
Definition: bootstrap.hxx:24
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:115
ustring.hxx
types.h
rtl_uriEncode
SAL_DLLPUBLIC void rtl_uriEncode(rtl_uString *pText, sal_Bool const *pCharClass, rtl_UriEncodeMechanism eMechanism, rtl_TextEncoding eCharset, rtl_uString **pResult) SAL_THROW_EXTERN_C()
Encode a text as (part of) a URI.
rtl_UriCharClass
rtl_UriCharClass
Various predefined URI &#39;char classes.
Definition: uri.h:45
rtl_UriEncodeMechanism
rtl_UriEncodeMechanism
The mechanism describing how escape sequences in the input of rtl_uriEncode() are handled...
Definition: uri.h:117
rtl::Uri::convertRelToAbs
static rtl::OUString convertRelToAbs(rtl::OUString const &rBaseUriRef, rtl::OUString const &rRelUriRef)
A wrapper around rtl_uriConvertRelToAbs() from <rtl/uri.h> (see there).
Definition: uri.hxx:117
rtl_uriDecode
SAL_DLLPUBLIC void rtl_uriDecode(rtl_uString *pText, rtl_UriDecodeMechanism eMechanism, rtl_TextEncoding eCharset, rtl_uString **pResult) SAL_THROW_EXTERN_C()
Decode (a part of) a URI.
rtl::Uri
A wrapper around the C functions from <rtl/uri.h>.
Definition: uri.hxx:33