1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 .
22 #include <curl/curl.h>
26 #include <rtl/ustring.hxx>
28 #include "DAVException.hxx"
30 namespace http_dav_ucp
32 template <typename T
, auto fn
> struct deleter_from_fn
34 void operator()(T
* p
) const { fn(p
); }
36 template <typename T
> using CurlUniquePtr
= ::std::unique_ptr
<T
, deleter_from_fn
<T
, curl_free
>>;
41 /// native curl representation of parsed URI
42 ::std::unique_ptr
<CURLU
, deleter_from_fn
<CURLU
, curl_url_cleanup
>> m_pUrl
;
43 /// duplicate state for quick access to some components
49 sal_uInt16 m_nPort
= 0;
51 OUString m_QueryAndFragment
;
56 CurlUri(CurlUri
const& rUri
);
57 CurlUri(CURLU
/*const*/& rUrl
);
58 void operator=(CurlUri
const& rOther
);
60 /// @throws DAVException
61 explicit CurlUri(::std::u16string_view rURI
);
63 bool operator==(CurlUri
const& rOther
) const;
65 CURLU
const* GetCURLU() const { return m_pUrl
.get(); }
66 OUString
const& GetURI() const { return m_URI
; }
67 OUString
const& GetScheme() const { return m_Scheme
; }
68 OUString
const& GetUser() const { return m_User
; }
69 OUString
const& GetPassword() const { return m_Password
; }
70 OUString
const& GetHost() const { return m_Host
; }
71 sal_uInt16
GetPort() const { return m_nPort
; }
72 OUString
const& GetPath() const { return m_Path
; }
73 OUString
GetRelativeReference() const { return m_Path
+ m_QueryAndFragment
; }
75 OUString
GetPathBaseName() const;
77 OUString
GetPathBaseNameUnescaped() const;
79 /// @throws DAVException
80 void SetScheme(::std::u16string_view rScheme
);
81 /// @throws DAVException
82 void AppendPath(::std::u16string_view rPath
);
83 /// @param matches: relative-ref = path-absolute [ "?" query ] [ "#" fragment ]
84 /// @throws DAVException
85 CurlUri
CloneWithRelativeRefPathAbsolute(std::u16string_view rRelativeRef
) const;
88 OUString
EncodeSegment(OUString
const& rSegment
);
89 OUString
DecodeURI(OUString
const& rURI
);
90 OUString
ConnectionEndPointString(std::u16string_view rHost
, sal_uInt16 nPort
);
92 } // namespace http_dav_ucp
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */