LibreOffice Module ucb (master) 1
CurlUri.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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#pragma once
21
22#include <curl/curl.h>
23
24#include <memory>
25
26#include <rtl/ustring.hxx>
27
28#include "DAVException.hxx"
29
30namespace http_dav_ucp
31{
32template <typename T, auto fn> struct deleter_from_fn
33{
34 void operator()(T* p) const { fn(p); }
35};
36template <typename T> using CurlUniquePtr = ::std::unique_ptr<T, deleter_from_fn<T, curl_free>>;
37
39{
40private:
42 ::std::unique_ptr<CURLU, deleter_from_fn<CURLU, curl_url_cleanup>> m_pUrl;
44 OUString m_URI;
45 OUString m_Scheme;
46 OUString m_User;
47 OUString m_Password;
48 OUString m_Host;
49 sal_uInt16 m_nPort = 0;
50 OUString m_Path;
52
53 void Init();
54
55public:
56 CurlUri(CurlUri const& rUri);
57 CurlUri(CURLU /*const*/& rUrl);
58 void operator=(CurlUri const& rOther);
59
61 explicit CurlUri(::std::u16string_view rURI);
62
63 bool operator==(CurlUri const& rOther) const;
64
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; }
74
75 OUString GetPathBaseName() const;
76
77 OUString GetPathBaseNameUnescaped() const;
78
80 void SetScheme(::std::u16string_view rScheme);
82 void AppendPath(::std::u16string_view rPath);
85 CurlUri CloneWithRelativeRefPathAbsolute(std::u16string_view rRelativeRef) const;
86};
87
88OUString EncodeSegment(OUString const& rSegment);
89OUString DecodeURI(OUString const& rURI);
90OUString ConnectionEndPointString(std::u16string_view rHost, sal_uInt16 nPort);
91
92} // namespace http_dav_ucp
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
CurlUri CloneWithRelativeRefPathAbsolute(std::u16string_view rRelativeRef) const
Definition: CurlUri.cxx:243
OUString GetPathBaseName() const
Definition: CurlUri.cxx:182
OUString GetRelativeReference() const
Definition: CurlUri.hxx:73
sal_uInt16 GetPort() const
Definition: CurlUri.hxx:71
OUString const & GetPath() const
Definition: CurlUri.hxx:72
void SetScheme(::std::u16string_view rScheme)
Definition: CurlUri.cxx:201
CurlUri(CurlUri const &rUri)
Definition: CurlUri.cxx:144
::std::unique_ptr< CURLU, deleter_from_fn< CURLU, curl_url_cleanup > > m_pUrl
native curl representation of parsed URI
Definition: CurlUri.hxx:42
OUString const & GetHost() const
Definition: CurlUri.hxx:70
OUString const & GetPassword() const
Definition: CurlUri.hxx:69
OUString m_QueryAndFragment
Definition: CurlUri.hxx:51
OUString const & GetUser() const
Definition: CurlUri.hxx:68
OUString m_URI
duplicate state for quick access to some components
Definition: CurlUri.hxx:44
bool operator==(CurlUri const &rOther) const
Definition: CurlUri.cxx:180
void operator=(CurlUri const &rOther)
Definition: CurlUri.cxx:162
OUString GetPathBaseNameUnescaped() const
Definition: CurlUri.cxx:199
OUString const & GetURI() const
Definition: CurlUri.hxx:66
CURLU const * GetCURLU() const
Definition: CurlUri.hxx:65
sal_uInt16 m_nPort
Definition: CurlUri.hxx:49
void AppendPath(::std::u16string_view rPath)
Definition: CurlUri.cxx:220
OUString const & GetScheme() const
Definition: CurlUri.hxx:67
void * p
OUString DecodeURI(OUString const &rURI)
Definition: CurlUri.cxx:302
::std::unique_ptr< T, deleter_from_fn< T, curl_free > > CurlUniquePtr
Definition: CurlUri.hxx:36
OUString EncodeSegment(OUString const &rSegment)
Definition: CurlUri.cxx:296
OUString ConnectionEndPointString(std::u16string_view rHostName, sal_uInt16 const nPort)
Definition: CurlUri.cxx:307
void operator()(T *p) const
Definition: CurlUri.hxx:34