3 // Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
23 // Permission to use, copy, modify, sell, and distribute this software
24 // is hereby granted without fee, provided that the above copyright
25 // notice appears in all copies, and that both that copyright notice
26 // and this permission notice appear in supporting documentation. None
27 // of the above authors, nor IBM Haifa Research Laboratories, make any
28 // representation about the suitability of this software for any
29 // purpose. It is provided "as is" without express or implied
33 * @file string_form.hpp
34 * Transforms containers into string form.
37 #ifndef PB_DS_STRING_FORM_HPP
38 #define PB_DS_STRING_FORM_HPP
42 #include <ext/pb_ds/detail/type_utils.hpp>
43 #include <ext/pb_ds/tag_and_trait.hpp>
44 #include <native_type/native_hash_map.hpp>
45 #include <native_type/native_hash_set.hpp>
46 #include <native_type/native_multimap.hpp>
47 #include <native_type/native_hash_multimap.hpp>
48 #include <native_type/native_set.hpp>
49 #include <common_type/assoc/template_policy.hpp>
50 #include <common_type/assoc/detail/ds_string_form.hpp>
51 #include <regression/basic_type.hpp>
60 template<typename Cntnr>
61 struct pb_ds_string_form
64 typedef typename Cntnr::mapped_type mapped_type;
66 struct mapped_string_form
69 template<typename D_Cntnr>
72 { return ("mmap_" + pb_ds_string_form<D_Cntnr>::name()); }
74 template<typename D_Cntnr>
77 { return pb_ds_string_form<D_Cntnr>::desc(); }
112 name(__gnu_pbds::null_type)
116 desc(__gnu_pbds::null_type)
122 { return name(mapped_type()); }
126 { return desc(mapped_type()); }
130 detail::ds_string_form<Cntnr, typename Cntnr::container_category>
136 { return (ds_string_form_t::name() + mapped_string_form::name()); }
140 { return (ds_string_form_t::desc() + mapped_string_form::desc()); }
143 template<typename Cntnr>
144 struct native_string_form
148 { return Cntnr::name(); }
152 { return Cntnr::desc(); }
155 template<typename Cntnr, class Tag>
156 struct tag_select_string_form : public pb_ds_string_form<Cntnr>
159 template<typename Cntnr>
160 struct tag_select_string_form<Cntnr, native_hash_tag>
161 : public native_string_form<Cntnr>
164 template<typename Cntnr>
165 struct tag_select_string_form<Cntnr, native_tree_tag>
166 : public native_string_form<Cntnr>
168 } // namespace detail
170 template<typename Cntnr>
172 : public detail::tag_select_string_form<Cntnr,
173 typename Cntnr::container_category>
176 } // namespace __gnu_pbds