LibreOffice Module ucb (master)  1
SerfUri.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 
21 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFURI_HXX
22 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFURI_HXX
23 
24 #include <apr_uri.h>
25 #include <rtl/ustring.hxx>
26 #include "DAVException.hxx"
27 
28 namespace http_dav_ucp
29 {
30 
31 #define DEFAULT_HTTP_PORT 80
32 #define DEFAULT_HTTPS_PORT 443
33 
34 
35 // SerfUri
36 // A URI implementation for use with the neon/expat library
37 
38 class SerfUri
39 {
40  private:
41  apr_uri_t mAprUri;
42  OUString mURI;
43  OUString mScheme;
44  OUString mUserInfo;
45  OUString mHostName;
46  sal_Int32 mPort;
47  OUString mPath;
48 
49  void init( const apr_uri_t * pUri );
50  void calculateURI ();
51 
52  public:
54  explicit SerfUri( const OUString & inUri );
56  explicit SerfUri( const apr_uri_t * inUri );
57 
58  bool operator== ( const SerfUri & rOther ) const;
59  bool operator!= ( const SerfUri & rOther ) const
60  { return !operator==( rOther ); }
61 
62  apr_uri_t& getAprUri()
63  {
64  return mAprUri;
65  }
66  const OUString & GetURI() const
67  { return mURI; };
68  const OUString & GetScheme() const
69  { return mScheme; };
70  const OUString & GetUserInfo() const
71  { return mUserInfo; };
72  const OUString & GetHost() const
73  { return mHostName; };
74  sal_Int32 GetPort() const
75  { return mPort; };
76  const OUString & GetPath() const
77  { return mPath; };
78 
79  OUString GetPathBaseName() const;
80 
81  OUString GetPathBaseNameUnescaped() const;
82 
83  void SetScheme (const OUString& scheme)
84  { mScheme = scheme; calculateURI (); };
85 
86  void AppendPath (const OUString& rPath);
87 
88  static OUString escapeSegment( const OUString& segment );
89  static OUString unescape( const OUString& string );
90 
91  // "host:port", omit ":port" for port 80 and 443
92  static OUString makeConnectionEndPointString(
93  const OUString & rHostName,
94  int nPort );
96  { return makeConnectionEndPointString( GetHost(), GetPort() ); }
97 };
98 
99 } // namespace http_dav_ucp
100 
101 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFURI_HXX
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const SerfUri &rOther) const
Definition: SerfUri.cxx:185
OUString GetPathBaseName() const
Definition: SerfUri.cxx:156
bool operator!=(const SerfUri &rOther) const
Definition: SerfUri.hxx:59
void AppendPath(const OUString &rPath)
Definition: SerfUri.cxx:195
void SetScheme(const OUString &scheme)
Definition: SerfUri.hxx:83
const OUString & GetHost() const
Definition: SerfUri.hxx:72
OUString makeConnectionEndPointString() const
Definition: SerfUri.hxx:95
sal_Int32 GetPort() const
Definition: SerfUri.hxx:74
apr_uri_t & getAprUri()
Definition: SerfUri.hxx:62
const OUString & GetPath() const
Definition: SerfUri.hxx:76
static OUString escapeSegment(const OUString &segment)
Definition: SerfUri.cxx:205
const OUString & GetUserInfo() const
Definition: SerfUri.hxx:70
SerfUri(const OUString &inUri)
Definition: SerfUri.cxx:54
OUString GetPathBaseNameUnescaped() const
Definition: SerfUri.cxx:190
const OUString & GetScheme() const
Definition: SerfUri.hxx:68
static OUString unescape(const OUString &string)
Definition: SerfUri.cxx:214
const OUString & GetURI() const
Definition: SerfUri.hxx:66
void init(const apr_uri_t *pUri)
Definition: SerfUri.cxx:91