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