23#include <rtl/malformeduriexception.hxx>
24#include <rtl/string.h>
25#include <rtl/textenc.h>
28#include <rtl/ustring.hxx>
29#include <rtl/character.hxx>
58 enum State { STATE_NAME0, STATE_NAME, STATE_KEY0, STATE_KEY, STATE_VALUE };
59 State eState = STATE_NAME0;
62 for (sal_Int32
i = 0;; ++
i)
64 bool bEnd =
i == rDescriptor.getLength();
69 if (bEnd || !rtl::isAsciiAlphanumeric(c))
70 throw rtl::MalformedUriException(
71 "UNO URL contains bad descriptor name");
77 if (bEnd || c == 0x2C)
80 = rDescriptor.copy(nStart,
i - nStart).toAsciiLowerCase();
83 else if (!rtl::isAsciiAlphanumeric(c))
84 throw rtl::MalformedUriException(
85 "UNO URL contains bad descriptor name");
89 if (bEnd || !rtl::isAsciiAlphanumeric(c))
90 throw rtl::MalformedUriException(
91 "UNO URL contains bad parameter key");
99 aKey = rDescriptor.copy(nStart,
i - nStart).toAsciiLowerCase();
101 eState = STATE_VALUE;
103 else if (bEnd || !rtl::isAsciiAlphanumeric(c))
104 throw rtl::MalformedUriException(
105 "UNO URL contains bad parameter key");
109 if (bEnd || c == 0x2C)
113 rtl::Uri::decode(rDescriptor.copy(nStart,
115 rtl_UriDecodeWithCharset,
116 RTL_TEXTENCODING_UTF8)).second)
117 throw rtl::MalformedUriException(
118 "UNO URL contains duplicated parameter");
128UnoUrlDescriptor::UnoUrlDescriptor(OUString
const & rDescriptor):
170 Impl::Parameters::const_iterator
186 static inline Impl *
create(OUString
const & rUrl);
189 Impl(OUString
const & rConnectionDescriptor,
190 OUString
const & rProtocolDescriptor,
191 OUString aObjectName):
200 if (!rUrl.startsWithIgnoreAsciiCase(
"uno:"))
201 throw rtl::MalformedUriException(
"UNO URL does not start with \"uno:\"");
202 sal_Int32
i = RTL_CONSTASCII_LENGTH(
"uno:");
203 sal_Int32 j = rUrl.indexOf(
';',
i);
205 throw rtl::MalformedUriException(
"UNO URL has too few semicolons");
206 OUString aConnection(rUrl.copy(
i, j -
i));
208 j = rUrl.indexOf(0x3B,
i);
210 throw rtl::MalformedUriException(
"UNO URL has too few semicolons");
211 OUString aProtocol(rUrl.copy(
i, j -
i));
213 if (
i == rUrl.getLength())
214 throw rtl::MalformedUriException(
"UNO URL contains empty ObjectName");
215 for (j =
i; j < rUrl.getLength(); ++j)
218 if (!rtl::isAsciiAlphanumeric(c) && c != 0x21 && c != 0x24
219 && c != 0x26 && c != 0x27 && c != 0x28
220 && c != 0x29 && c != 0x2A && c != 0x2B
221 && c != 0x2C && c != 0x2D && c != 0x2E
222 && c != 0x2F && c != 0x3A && c != 0x3D
223 && c != 0x3F && c != 0x40 && c != 0x5F
225 throw rtl::MalformedUriException(
"UNO URL contains invalid ObjectName");
227 return new Impl(aConnection, aProtocol, rUrl.copy(
i));
std::map< OUString, OUString > Parameters
Impl(OUString const &m_aDescriptor)
UnoUrlDescriptor m_aConnection
static Impl * create(OUString const &rUrl)
UnoUrlDescriptor m_aProtocol
Impl(OUString const &rConnectionDescriptor, OUString const &rProtocolDescriptor, OUString aObjectName)
A descriptor as part of a UNO URL (connection descriptor or protocol descriptor).
rtl::OUString const & getDescriptor() const
Return the string representation of the descriptor.
rtl::OUString const & getName() const
Return the name component of the descriptor.
bool hasParameter(rtl::OUString const &rKey) const
Test whether the parameters contain a key.
rtl::OUString getParameter(rtl::OUString const &rKey) const
Return the parameter value for a key.
UnoUrlDescriptor & operator=(UnoUrlDescriptor const &rOther)
Parse UNO URLs into their components.
UnoUrlDescriptor const & getConnection() const
Return the connection descriptor component of the URL.
rtl::OUString const & getObjectName() const
Return the object-name component of the URL.
UnoUrl & operator=(UnoUrl const &rOther)
UnoUrlDescriptor const & getProtocol() const
Return the protocol descriptor component of the URL.
T * clone(T *const other)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)