LibreOffice Module ucb (master)  1
NeonUri.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONURI_HXX
29 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONURI_HXX
30 
31 #include <sal/config.h>
32 
33 #include <string_view>
34 
35 #include <config_lgpl.h>
36 #include <ne_uri.h>
37 #include <rtl/ustring.hxx>
38 #include "DAVException.hxx"
39 
40 namespace webdav_ucp
41 {
42 
43 #define DEFAULT_HTTP_PORT 80
44 #define DEFAULT_HTTPS_PORT 443
45 #define DEFAULT_FTP_PORT 21
46 
47 // A URI implementation for use with the neon/expat library
48 class NeonUri
49 {
50  private:
51  OUString mURI;
52  OUString mScheme;
53  OUString mUserInfo;
54  OUString mHostName;
55  sal_Int32 mPort;
56  OUString mPath;
57 
58  void init( const OString & rUri, const ne_uri * pUri );
59  void calculateURI ();
60 
61  public:
63  explicit NeonUri( const OUString & inUri );
65  explicit NeonUri( const ne_uri * inUri );
66 
67  bool operator== ( const NeonUri & rOther ) const;
68  bool operator!= ( const NeonUri & rOther ) const
69  { return !operator==( rOther ); }
70 
71  const OUString & GetURI() const
72  { return mURI; };
73  const OUString & GetScheme() const
74  { return mScheme; };
75  const OUString & GetUserInfo() const
76  { return mUserInfo; };
77  const OUString & GetHost() const
78  { return mHostName; };
79  sal_Int32 GetPort() const
80  { return mPort; };
81  const OUString & GetPath() const
82  { return mPath; };
83 
84  OUString GetPathBaseName() const;
85 
86  OUString GetPathBaseNameUnescaped() const;
87 
88  void SetScheme (const OUString& scheme)
89  { mScheme = scheme; calculateURI (); };
90 
91  void AppendPath (std::u16string_view rPath);
92 
93  static OUString escapeSegment( const OUString& segment );
94  static OUString unescape( const OUString& string );
95 
96  // "host:port", omit ":port" for port 80 and 443
97  static OUString makeConnectionEndPointString(
98  const OUString & rHostName,
99  int nPort );
100 };
101 
102 } // namespace webdav_ucp
103 
104 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_NEONURI_HXX
105 
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 mPort
Definition: NeonUri.hxx:55
static OUString unescape(const OUString &string)
Definition: NeonUri.cxx:257
const OUString & GetUserInfo() const
Definition: NeonUri.hxx:75
OUString GetPathBaseNameUnescaped() const
Definition: NeonUri.cxx:233
bool operator==(const NeonUri &rOther) const
Definition: NeonUri.cxx:228
OUString GetPathBaseName() const
Definition: NeonUri.cxx:199
const OUString & GetPath() const
Definition: NeonUri.hxx:81
sal_Int32 GetPort() const
Definition: NeonUri.hxx:79
OUString mUserInfo
Definition: NeonUri.hxx:53
NeonUri(const OUString &inUri)
Definition: NeonUri.cxx:90
void init(const OString &rUri, const ne_uri *pUri)
Definition: NeonUri.cxx:114
const OUString & GetHost() const
Definition: NeonUri.hxx:77
void AppendPath(std::u16string_view rPath)
Definition: NeonUri.cxx:238
void SetScheme(const OUString &scheme)
Definition: NeonUri.hxx:88
static OUString escapeSegment(const OUString &segment)
Definition: NeonUri.cxx:248
const OUString & GetScheme() const
Definition: NeonUri.hxx:73
const OUString & GetURI() const
Definition: NeonUri.hxx:71
bool operator!=(const NeonUri &rOther) const
Definition: NeonUri.hxx:68
OUString mScheme
Definition: NeonUri.hxx:52
OUString mHostName
Definition: NeonUri.hxx:54
static OUString makeConnectionEndPointString(const OUString &rHostName, int nPort)
Definition: NeonUri.cxx:265