LibreOffice: rtl/uri.hxx Source File

LibreOffice LibreOffice 7.3 SDK C/C++ API Reference

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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_RTL_URI_HXX
25#define INCLUDED_RTL_URI_HXX
26
27#include "rtl/malformeduriexception.hxx"
28#include "rtl/uri.h"
29#include "rtl/textenc.h"
30#include "rtl/ustring.hxx"
31#include "sal/types.h"
32
33namespace rtl {
34
37 class Uri
38{
39public:
43 static inline rtl::OUString encode(rtl::OUString const & rText,
44 sal_Bool const * pCharClass,
45 rtl_UriEncodeMechanism eMechanism,
46 rtl_TextEncoding eCharset);
47
51 static inline rtl::OUString encode(rtl::OUString const & rText,
52 rtl_UriCharClass eCharClass,
53 rtl_UriEncodeMechanism eMechanism,
54 rtl_TextEncoding eCharset);
55
58 static inline rtl::OUString decode(rtl::OUString const & rText,
59 rtl_UriDecodeMechanism eMechanism,
60 rtl_TextEncoding eCharset);
61
68 static inline rtl::OUString convertRelToAbs(
69 rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
70
71private:
72 Uri() SAL_DELETED_FUNCTION;
73
74 Uri(Uri &) SAL_DELETED_FUNCTION;
75
76 ~Uri() SAL_DELETED_FUNCTION;
77
78 void operator =(Uri) SAL_DELETED_FUNCTION;
79};
80
81 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
82 sal_Bool const * pCharClass,
83 rtl_UriEncodeMechanism eMechanism,
84 rtl_TextEncoding eCharset)
85{
86 rtl::OUString aResult;
87 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
88 pCharClass,
89 eMechanism,
90 eCharset,
91 &aResult.pData);
92 return aResult;
93}
94
95 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
96 rtl_UriCharClass eCharClass,
97 rtl_UriEncodeMechanism eMechanism,
98 rtl_TextEncoding eCharset)
99{
100 rtl::OUString aResult;
101 rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
102 rtl_getUriCharClass(eCharClass),
103 eMechanism,
104 eCharset,
105 &aResult.pData);
106 return aResult;
107}
108
109 inline rtl::OUString Uri::decode(rtl::OUString const & rText,
110 rtl_UriDecodeMechanism eMechanism,
111 rtl_TextEncoding eCharset)
112{
113 rtl::OUString aResult;
114 rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
115 eMechanism,
116 eCharset,
117 &aResult.pData);
118 return aResult;
119}
120
121 inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
122 rtl::OUString const & rRelUriRef)
123{
124 rtl::OUString aResult;
125 rtl::OUString aException;
126 if (!rtl_uriConvertRelToAbs(
127 const_cast< rtl::OUString & >(rBaseUriRef).pData,
128 const_cast< rtl::OUString & >(rRelUriRef).pData, &aResult.pData,
129 &aException.pData))
130 throw MalformedUriException(aException);
131 return aResult;
132}
133
134}
135
136#endif // INCLUDED_RTL_URI_HXX
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
types.h
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
ustring.hxx
malformeduriexception.hxx
uri.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_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_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:189
rtl_UriEncodeMechanism
rtl_UriEncodeMechanism
The mechanism describing how escape sequences in the input of rtl_uriEncode() are handled.
Definition: uri.h:135
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_UriCharClass
rtl_UriCharClass
Various predefined URI 'char classes.
Definition: uri.h:50
textenc.h
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
rtl
Definition: unotype.hxx:47
rtl::MalformedUriException
An exception indicating a malformed URI.
Definition: malformeduriexception.hxx:36
rtl::Uri
A wrapper around the C functions from <rtl/uri.h>.
Definition: uri.hxx:38
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:121
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:109
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:81
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:204