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  ~SerfUri( );
58 
59  bool operator== ( const SerfUri & rOther ) const;
60  bool operator!= ( const SerfUri & rOther ) const
61  { return !operator==( rOther ); }
62 
63  apr_uri_t& getAprUri()
64  {
65  return mAprUri;
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 );
97  { return makeConnectionEndPointString( GetHost(), GetPort() ); }
98 };
99 
100 } // namespace http_dav_ucp
101 
102 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_SERFURI_HXX
103 
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const SerfUri &rOther) const
Definition: SerfUri.cxx:189
OUString GetPathBaseName() const
Definition: SerfUri.cxx:160
bool operator!=(const SerfUri &rOther) const
Definition: SerfUri.hxx:60
void AppendPath(const OUString &rPath)
Definition: SerfUri.cxx:199
void SetScheme(const OUString &scheme)
Definition: SerfUri.hxx:84
const OUString & GetHost() const
Definition: SerfUri.hxx:73
OUString makeConnectionEndPointString() const
Definition: SerfUri.hxx:96
sal_Int32 GetPort() const
Definition: SerfUri.hxx:75
apr_uri_t & getAprUri()
Definition: SerfUri.hxx:63
const OUString & GetPath() const
Definition: SerfUri.hxx:77
static OUString escapeSegment(const OUString &segment)
Definition: SerfUri.cxx:209
const OUString & GetUserInfo() const
Definition: SerfUri.hxx:71
SerfUri(const OUString &inUri)
Definition: SerfUri.cxx:54
OUString GetPathBaseNameUnescaped() const
Definition: SerfUri.cxx:194
const OUString & GetScheme() const
Definition: SerfUri.hxx:69
static OUString unescape(const OUString &string)
Definition: SerfUri.cxx:218
const OUString & GetURI() const
Definition: SerfUri.hxx:67
void init(const apr_uri_t *pUri)
Definition: SerfUri.cxx:91