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