bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / cppuhelper / unourl.hxx
blob8771c0c4439656ecc9d50060d5c8a70fd7617a71
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_CPPUHELPER_UNOURL_HXX
21 #define INCLUDED_CPPUHELPER_UNOURL_HXX
23 #include "sal/config.h"
25 #include "cppuhelper/cppuhelperdllapi.h"
27 namespace rtl { class OUString; }
29 namespace cppu {
31 /** A descriptor as part of a UNO URL (connection descriptor or protocol
32 descriptor).
34 Such a descriptor can also be useful outside the context of a full UNO URL.
35 For example, some functions take a string representing a connection or
36 protocol descriptor as input, and can use this class to parse the string.
38 class SAL_WARN_UNUSED CPPUHELPER_DLLPUBLIC UnoUrlDescriptor
40 public:
41 class Impl;
43 /** Construct a descriptor from a string representation.
45 @param rDescriptor
46 The string representation of a descriptor.
48 @exception rtl::MalformedUriException
49 Thrown when the given string representation is invalid.
51 explicit UnoUrlDescriptor(rtl::OUString const & rDescriptor);
53 UnoUrlDescriptor(UnoUrlDescriptor const & rOther);
55 ~UnoUrlDescriptor();
57 UnoUrlDescriptor & operator =(UnoUrlDescriptor const & rOther);
59 /** Return the string representation of the descriptor.
61 @return
62 A reference to the string representation used to construct this
63 descriptor, without any modifications. The reference is valid for the
64 lifetime of this URL object.
66 rtl::OUString const & getDescriptor() const;
68 /** Return the name component of the descriptor.
70 @return
71 A reference to the (case insensitive) name, in lower case form. The
72 reference is valid for the lifetime of this URL object.
74 rtl::OUString const & getName() const;
76 /** Test whether the parameters contain a key.
78 @param
79 rKey A (case insensitive) key.
81 @return
82 True if the parameters contain a matching key/value pair.
84 bool hasParameter(rtl::OUString const & rKey) const;
86 /** Return the parameter value for a key.
88 @param
89 rKey A (case insensitive) key.
91 @return
92 The (case sensitive) value associated with the given key, or an empty
93 string if there is no matching key/value pair.
95 rtl::OUString getParameter(rtl::OUString const & rKey) const;
97 private:
98 Impl * m_pImpl;
101 /** Parse UNO URLs into their components.
103 The ABNF for UNO URLs is as follows (see RFCs 2234, 2396, also see
104 <http://udk.openoffice.org/common/man/spec/uno-url.html>):
106 uno-url = "UNO:" connection ";" protocol ";" object-name
107 connection = descriptor
108 protocol = descriptor
109 descriptor = name *("," parameter)
110 name = 1*alphanum
111 parameter = key "=" value
112 key = 1*alphanum
113 value = *vchar
114 valchar = unreserved / escaped / "$" / "&" / "+" / "/" / ":" / "?" / "@"
115 object-name = 1*ochar
116 ochar = unreserved / "$" / "&" / "+" / "," / "/" / ":" / "=" / "?" / "@"
118 Within a descriptor, the name and the keys are case insensitive, and within
119 the parameter list all keys must be distinct.
121 Parameter values are encoded using UTF-8. Note that parsing of parameter
122 values as done by UnoUrl and UnoUrlDescriptor is not strict: Invalid UTF-16
123 entities in the input, as well as broken escape sequences ("%" not followed
124 by two hex digits) are copied verbatim to the output, invalid bytes in the
125 converted UTF-8 data are considered individual Unicode characters, and
126 invalid UTF-16 entities in the resulting output (e.g., a high surrogate not
127 followed by a low surrogate) are not detected.
129 class SAL_WARN_UNUSED CPPUHELPER_DLLPUBLIC UnoUrl
131 public:
132 /** Construct a UNO URL from a string representation.
134 @param rUrl
135 The string representation of a UNO URL.
137 @exception rtl::MalformedUriException
138 Thrown when the given string representation is invalid.
140 explicit UnoUrl(rtl::OUString const & rUrl);
142 UnoUrl(UnoUrl const & rOther);
144 ~UnoUrl();
146 UnoUrl & operator =(UnoUrl const & rOther);
148 /** Return the connection descriptor component of the URL.
150 @return
151 A reference to the connection descriptor. The reference is valid for
152 the lifetime of this URL object.
154 UnoUrlDescriptor const & getConnection() const;
156 /** Return the protocol descriptor component of the URL.
158 @return
159 A reference to the protocol descriptor. The reference is valid for the
160 lifetime of this URL object.
162 UnoUrlDescriptor const & getProtocol() const;
164 /** Return the object-name component of the URL.
166 @return
167 A reference to the (case sensitive) object-name. The reference is valid
168 for the lifetime of this URL object.
170 rtl::OUString const & getObjectName() const;
172 private:
173 class Impl;
175 Impl * m_pImpl;
180 #endif // INCLUDED_RTL_UNOURL_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */