LibreOffice LibreOffice 4.2 SDK C/C++ API Reference

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 SAL_THROW(());
44
48 static inline rtl::OUString encode(rtl::OUString const & rText,
49 rtl_UriCharClass eCharClass,
50 rtl_UriEncodeMechanism eMechanism,
51 rtl_TextEncoding eCharset)
52 SAL_THROW(());
53
56 static inline rtl::OUString decode(rtl::OUString const & rText,
57 rtl_UriDecodeMechanism eMechanism,
58 rtl_TextEncoding eCharset)
59 SAL_THROW(());
60
67 static inline rtl::OUString convertRelToAbs(
68 rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
69
70 private:
72 Uri();
73
75 Uri(Uri &);
76
78 ~Uri();
79
81 void operator =(Uri);
82 };
83
84 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
85 sal_Bool const * pCharClass,
86 rtl_UriEncodeMechanism eMechanism,
87 rtl_TextEncoding eCharset)
88 SAL_THROW(())
89 {
90 rtl::OUString aResult;
91 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
92 pCharClass,
93 eMechanism,
94 eCharset,
95 &aResult.pData);
96 return aResult;
97 }
98
99 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
100 rtl_UriCharClass eCharClass,
101 rtl_UriEncodeMechanism eMechanism,
102 rtl_TextEncoding eCharset)
103 SAL_THROW(())
104 {
105 rtl::OUString aResult;
106 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
107 rtl_getUriCharClass(eCharClass),
108 eMechanism,
109 eCharset,
110 &aResult.pData);
111 return aResult;
112 }
113
114 inline rtl::OUString Uri::decode(rtl::OUString const & rText,
115 rtl_UriDecodeMechanism eMechanism,
116 rtl_TextEncoding eCharset)
117 SAL_THROW(())
118 {
119 rtl::OUString aResult;
120 rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
121 eMechanism,
122 eCharset,
123 &aResult.pData);
124 return aResult;
125 }
126
127 inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
128 rtl::OUString const & rRelUriRef)
129 {
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,
135 &aException.pData))
136 throw MalformedUriException(aException);
137 return aResult;
138 }
139
140 }
141
142 #endif // INCLUDED_RTL_URI_HXX
143
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Uri
A wrapper around the C functions from <rtl/uri.h>.
Definition: uri.hxx:33
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:114
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:82
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:127
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.
types.h
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:84
rtl_UriCharClass
rtl_UriCharClass
Various predefined URI 'char classes.
Definition: uri.h:45
textenc.h
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_UriEncodeMechanism
rtl_UriEncodeMechanism
The mechanism describing how escape sequences in the input of rtl_uriEncode() are handled...
Definition: uri.h:117
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 one.
sal_Bool
unsigned char sal_Bool
Definition: types.h:46
rtl::MalformedUriException
An exception indicating a malformed URI.
Definition: malformeduriexception.hxx:31
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_UriDecodeMechanism
rtl_UriDecodeMechanism
The mechanism describing how rtl_uriDecode() translates (part of) a URI into a Unicode string...
Definition: uri.h:171
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
uri.h
malformeduriexception.hxx
SAL_THROW
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:358
ustring.hxx