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 #ifndef INCLUDED_STOC_SOURCE_URIPROC_URIREFERENCE_HXX
21 #define INCLUDED_STOC_SOURCE_URIPROC_URIREFERENCE_HXX
22 
23 #include <osl/mutex.hxx>
24 #include <rtl/ustring.hxx>
25 #include <sal/types.h>
26 #include <rtl/ustrbuf.hxx>
27 
28 namespace stoc::uriproc {
29 
30 class UriReference {
31 public:
32     UriReference(
33         OUString const & scheme, bool hasAuthority,
34         OUString const & authority, OUString const & path,
35         bool hasQuery, OUString const & query);
36 
37     ~UriReference();
38 
39     /// @throws css::uno::RuntimeException
40     OUString getUriReference();
41 
42     /// @throws css::uno::RuntimeException
43     bool isAbsolute() const;
44 
45     /// @throws css::uno::RuntimeException
getScheme() const46     const OUString& getScheme() const { return m_scheme;}
47 
48     /// @throws css::uno::RuntimeException
49     OUString getSchemeSpecificPart();
50 
51     /// @throws css::uno::RuntimeException
52     bool isHierarchical();
53 
54     /// @throws css::uno::RuntimeException
55     bool hasAuthority();
56 
57     /// @throws css::uno::RuntimeException
58     OUString getAuthority();
59 
60     /// @throws css::uno::RuntimeException
61     OUString getPath();
62 
63     /// @throws css::uno::RuntimeException
64     bool hasRelativePath();
65 
66     /// @throws css::uno::RuntimeException
67     sal_Int32 getPathSegmentCount();
68 
69     /// @throws css::uno::RuntimeException
70     OUString getPathSegment(sal_Int32 index);
71 
72     /// @throws css::uno::RuntimeException
73     bool hasQuery();
74 
75     /// @throws css::uno::RuntimeException
76     OUString getQuery();
77 
78     /// @throws css::uno::RuntimeException
79     bool hasFragment();
80 
81     /// @throws css::uno::RuntimeException
82     OUString getFragment();
83 
84     /// @throws css::uno::RuntimeException
85     void setFragment(OUString const & fragment);
86 
87     /// @throws css::uno::RuntimeException
88     void clearFragment();
89 
90     osl::Mutex m_mutex;
91     OUString m_scheme;
92     OUString m_authority;
93     OUString m_path;
94     OUString m_query;
95     OUString m_fragment;
96     bool m_hasAuthority;
97     bool m_hasQuery;
98     bool m_hasFragment;
99 
100 private:
101     UriReference(UriReference const &) = delete;
102     void operator =(UriReference const &) = delete;
103 
104     void appendSchemeSpecificPart(OUStringBuffer & buffer) const;
105 };
106 
107 }
108 
109 #endif
110 
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
112