Line data Source code
1 : /*
2 : Copyright 2013-2015 Paul Colby
3 :
4 : This file is part of libqtaws.
5 :
6 : Libqtaws is free software: you can redistribute it and/or modify
7 : it under the terms of the GNU Lesser General Public License as published by
8 : the Free Software Foundation, either version 3 of the License, or
9 : (at your option) any later version.
10 :
11 : Libqtaws is distributed in the hope that it will be useful,
12 : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : GNU Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public License
17 : along with libqtaws. If not, see <http://www.gnu.org/licenses/>.
18 : */
19 :
20 : #ifndef AWSENDPOINT_P_H
21 : #define AWSENDPOINT_P_H
22 :
23 : #include "qtawsglobal.h"
24 :
25 : #include "awsendpoint.h"
26 :
27 : #include <QMutex>
28 : #include <QString>
29 : #include <QStringList>
30 : #include <QXmlStreamReader>
31 : #include <QVariant>
32 :
33 : QTAWS_BEGIN_NAMESPACE
34 :
35 : class AwsEndpoint;
36 :
37 1175 : class QTAWS_EXPORT AwsEndpointPrivate {
38 :
39 : public:
40 : QString hostName; ///< This endpoint's hostname.
41 : QString regionName; ///< This endpoint's region name.
42 : QString serviceName; ///< This endpoint's service name.
43 :
44 : AwsEndpointPrivate(AwsEndpoint * const q);
45 :
46 : protected:
47 : /// The per-host information to load from the endpoints.xml file.
48 3183980 : struct HostInfo {
49 : QStringList regionNames; ///< AWS regions supported by the host.
50 : QString serviceName; ///< AWS service supported by the host.
51 : };
52 :
53 : /// The per-region endpoint-specific information to load from the endpoints.xml file.
54 6631902 : struct RegionEndpointInfo {
55 : QString hostName; ///< AWS endpoint's hostname.
56 : AwsEndpoint::Transports transports; ///< Transports supported by this AWS endpoint.
57 : };
58 :
59 : /// Hash of service names to RegionEndpointInfo.
60 : typedef QHash<QString, RegionEndpointInfo> RegionServices;
61 :
62 : /// The per-region information to load from the endpoints.xml file.
63 155760 : struct RegionInfo {
64 : RegionServices services; ///< AWS services supported by the AWS region.
65 : };
66 :
67 : /// The per-service information to load from the endpoints.xml file.
68 553752 : struct ServiceInfo {
69 : QString fullName; ///< AWS service's full human-friendly name.
70 : QStringList regionNames; ///< AWS regions support by this service.
71 : };
72 :
73 : static QHash<QString, HostInfo> hosts;
74 : static QHash<QString, RegionInfo> regions;
75 : static QHash<QString, ServiceInfo> services;
76 :
77 : static QMutex mutex;
78 :
79 : static void loadEndpointData(const QString &fileName = QLatin1String(":/aws/endpoints.xml"));
80 : static void loadEndpointData(QIODevice &device);
81 : static void loadEndpointData(QXmlStreamReader &xml);
82 : static void parseRegion(QXmlStreamReader &xml);
83 : static void parseRegions(QXmlStreamReader &xml);
84 : static void parseService(QXmlStreamReader &xml);
85 : static void parseServices(QXmlStreamReader &xml);
86 :
87 : private:
88 : Q_DECLARE_PUBLIC(AwsEndpoint)
89 : AwsEndpoint * const q_ptr; ///< Internal q-pointer.
90 : friend class TestAwsEndpoint;
91 : friend class TestAwsSignatureV4;
92 : };
93 :
94 : QTAWS_END_NAMESPACE
95 :
96 : #endif
|