Imported Upstream version 1.71.0
[platform/upstream/boost.git] / boost / geometry / srs / projections / factory_key.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2018, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #ifndef BOOST_GEOMETRY_PROJECTIONS_FACTORY_KEY_HPP
11 #define BOOST_GEOMETRY_PROJECTIONS_FACTORY_KEY_HPP
12
13 #include <string>
14
15 #include <boost/geometry/srs/projections/dpar.hpp>
16 #include <boost/geometry/srs/projections/proj4.hpp>
17
18 namespace boost { namespace geometry { namespace projections
19 {
20
21 namespace detail
22 {
23
24 template <typename Params>
25 struct factory_key_util
26 {
27     BOOST_MPL_ASSERT_MSG((false), INVALID_PARAMETERS_TYPE, (Params));
28 };
29
30 template <>
31 struct factory_key_util<srs::detail::proj4_parameters>
32 {
33     typedef std::string type;
34     template <typename ProjParams>
35     static type const& get(ProjParams const& par)
36     {
37         return par.id.name;
38     }
39 };
40
41 template <typename T>
42 struct factory_key_util<srs::dpar::parameters<T> >
43 {
44     typedef srs::dpar::value_proj type;
45     template <typename ProjParams>
46     static type const& get(ProjParams const& par)
47     {
48         return par.id.id;
49     }
50 };
51
52 struct factory_key
53 {
54     factory_key(const char* name, srs::dpar::value_proj id)
55         : m_name(name), m_id(id)
56     {}
57
58     operator const char*() const
59     {
60         return m_name;
61     }
62
63     operator std::string() const
64     {
65         return std::string(m_name);
66     }
67
68     operator srs::dpar::value_proj() const
69     {
70         return m_id;
71     }
72
73 private:
74     const char* m_name;
75     srs::dpar::value_proj m_id;
76 };
77
78
79 } // namespace detail
80
81 }}} // namespace boost::geometry::projections
82
83 #endif // BOOST_GEOMETRY_PROJECTIONS_FACTORY_KEY_HPP