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 #pragma once
29 
30 #include <sal/config.h>
31 
32 #include <string_view>
33 
34 #include <config_lgpl.h>
35 #include <ne_uri.h>
36 #include <rtl/ustring.hxx>
37 #include "DAVException.hxx"
38 
39 namespace webdav_ucp
40 {
41 
42 #define DEFAULT_HTTP_PORT 80
43 #define DEFAULT_HTTPS_PORT 443
44 #define DEFAULT_FTP_PORT 21
45 
46 // A URI implementation for use with the neon/expat library
47 class NeonUri
48 {
49  private:
50  OUString mURI;
51  OUString mScheme;
52  OUString mUserInfo;
53  OUString mHostName;
54  sal_Int32 mPort;
55  OUString mPath;
56 
57  void init( const OString & rUri, const ne_uri * pUri );
58  void calculateURI ();
59 
60  public:
62  explicit NeonUri( const OUString & inUri );
64  explicit NeonUri( const ne_uri * inUri );
65 
66  bool operator== ( const NeonUri & rOther ) const;
67  bool operator!= ( const NeonUri & rOther ) const
68  { return !operator==( rOther ); }
69 
70  const OUString & GetURI() const
71  { return mURI; };
72  const OUString & GetScheme() const
73  { return mScheme; };
74  const OUString & GetUserInfo() const
75  { return mUserInfo; };
76  const OUString & GetHost() const
77  { return mHostName; };
78  sal_Int32 GetPort() const
79  { return mPort; };
80  const OUString & GetPath() const
81  { return mPath; };
82 
83  OUString GetPathBaseName() const;
84 
85  OUString GetPathBaseNameUnescaped() const;
86 
87  void SetScheme (const OUString& scheme)
88  { mScheme = scheme; calculateURI (); };
89 
90  void AppendPath (std::u16string_view rPath);
91 
92  static OUString escapeSegment( const OUString& segment );
93  static OUString unescape( const OUString& string );
94 
95  // "host:port", omit ":port" for port 80 and 443
96  static OUString makeConnectionEndPointString(
97  const OUString & rHostName,
98  int nPort );
99 };
100 
101 } // namespace webdav_ucp
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 mPort
Definition: NeonUri.hxx:54
static OUString unescape(const OUString &string)
Definition: NeonUri.cxx:257
const OUString & GetUserInfo() const
Definition: NeonUri.hxx:74
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:80
sal_Int32 GetPort() const
Definition: NeonUri.hxx:78
OUString mUserInfo
Definition: NeonUri.hxx:52
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:76
void AppendPath(std::u16string_view rPath)
Definition: NeonUri.cxx:238
void SetScheme(const OUString &scheme)
Definition: NeonUri.hxx:87
static OUString escapeSegment(const OUString &segment)
Definition: NeonUri.cxx:248
const OUString & GetScheme() const
Definition: NeonUri.hxx:72
const OUString & GetURI() const
Definition: NeonUri.hxx:70
bool operator!=(const NeonUri &rOther) const
Definition: NeonUri.hxx:67
OUString mScheme
Definition: NeonUri.hxx:51
OUString mHostName
Definition: NeonUri.hxx:53
static OUString makeConnectionEndPointString(const OUString &rHostName, int nPort)
Definition: NeonUri.cxx:265