Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / webdav / SerfUri.hxx
blob89298c09b2bbda84b8031bebb6c3c51bde92f223
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #ifndef INCLUDED_SERFURI_HXX
22 #define INCLUDED_SERFURI_HXX
24 #include <apr-util/apr_uri.h>
25 #include <rtl/ustring.hxx>
26 #include <DAVException.hxx>
28 namespace http_dav_ucp
31 #define DEFAULT_HTTP_PORT 80
32 #define DEFAULT_HTTPS_PORT 443
34 // -------------------------------------------------------------------
35 // SerfUri
36 // A URI implementation for use with the neon/expat library
37 // -------------------------------------------------------------------
38 class SerfUri
40 private:
41 apr_uri_t mAprUri;
42 ::rtl::OUString mURI;
43 ::rtl::OUString mScheme;
44 ::rtl::OUString mUserInfo;
45 ::rtl::OUString mHostName;
46 sal_Int32 mPort;
47 ::rtl::OUString mPath;
49 void init( const apr_uri_t * pUri );
50 void calculateURI ();
52 public:
53 SerfUri( const ::rtl::OUString & inUri ) throw ( DAVException );
54 SerfUri( const apr_uri_t * inUri ) throw ( DAVException );
55 ~SerfUri( );
57 bool operator== ( const SerfUri & rOther ) const;
58 bool operator!= ( const SerfUri & rOther ) const
59 { return !operator==( rOther ); }
61 apr_uri_t* getAprUri()
63 return &mAprUri;
65 const ::rtl::OUString & GetURI( void ) const
66 { return mURI; };
67 const ::rtl::OUString & GetScheme( void ) const
68 { return mScheme; };
69 const ::rtl::OUString & GetUserInfo( void ) const
70 { return mUserInfo; };
71 const ::rtl::OUString & GetHost( void ) const
72 { return mHostName; };
73 sal_Int32 GetPort( void ) const
74 { return mPort; };
75 const ::rtl::OUString & GetPath( void ) const
76 { return mPath; };
78 ::rtl::OUString GetPathBaseName ( void ) const;
80 ::rtl::OUString GetPathBaseNameUnescaped ( void ) const;
82 void SetScheme (const ::rtl::OUString& scheme)
83 { mScheme = scheme; calculateURI (); };
85 void AppendPath (const ::rtl::OUString& rPath);
87 static ::rtl::OUString escapeSegment( const ::rtl::OUString& segment );
88 static ::rtl::OUString unescape( const ::rtl::OUString& string );
90 // "host:port", omit ":port" for port 80 and 443
91 static rtl::OUString makeConnectionEndPointString(
92 const rtl::OUString & rHostName,
93 int nPort );
94 rtl::OUString makeConnectionEndPointString() const
95 { return makeConnectionEndPointString( GetHost(), GetPort() ); }
98 } // namespace http_dav_ucp
100 #endif // INCLUDED_SERFURI_HXX
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */