LibreOffice
LibreOffice 4.2 SDK C/C++ API Reference
 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 
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 
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 
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 
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 
128  rtl::OUString const & rRelUriRef)
129 {
130  rtl::OUString aResult;
131  rtl::OUString aException;
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: */
A wrapper around the C functions from <rtl/uri.h>.
Definition: uri.hxx:33
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
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:82
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
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.
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
Various predefined URI 'char classes.
Definition: uri.h:45
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
The mechanism describing how escape sequences in the input of rtl_uriEncode() are handled...
Definition: uri.h:117
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.
unsigned char sal_Bool
Definition: types.h:46
An exception indicating a malformed URI.
Definition: malformeduriexception.hxx:31
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
The mechanism describing how rtl_uriDecode() translates (part of) a URI into a Unicode string...
Definition: uri.h:171
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:358