Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_mobile / utils / include / dpl / utils / warp_iri.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 #ifndef _WARPIRI_H_
17 #define _WARPIRI_H_
18
19 #include <vector>
20
21 #include <dpl/string.h>
22 #include <dpl/log/log.h>
23
24 class WarpIRI
25 {
26     static const unsigned int UNKNOWN_PORT = 0;
27
28   public:
29     WarpIRI();
30
31     void set(const char *iri,
32              bool domain);
33     void set(const DPL::String &iristring,
34              bool domain);
35
36     /* It also checks port and schema */
37     bool isSubDomain(const WarpIRI &second) const;
38     bool isAccessDefinition() const;
39     bool getSubDomain() const;
40
41     static bool isIRISchemaIgnored(const char *iri);
42
43     bool operator ==(const WarpIRI &other) const
44     {
45         return m_domain == other.m_domain &&
46                m_host == other.m_host &&
47                m_schema == other.m_schema &&
48                m_port == other.m_port &&
49                m_isAccessDefinition == other.m_isAccessDefinition &&
50                m_isIRIValid == other.m_isIRIValid;
51     }
52
53   private:
54     unsigned int getPort(const DPL::String &schema) const;
55
56     bool m_domain;
57     std::vector<DPL::String> m_host;
58     DPL::String m_schema;
59     unsigned int m_port;
60     bool m_isAccessDefinition;
61     bool m_isIRIValid;
62 };
63
64 #endif // _WarpIRI_H_