]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp
typelist.h (type_to_type): Remove.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / common_type / assoc / string_form.hpp
CommitLineData
4569a895
AT
1// -*- C++ -*-
2
3// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4//
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 2, or (at your option) any later
9// version.
10
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.
15
16// You should have received a copy of the GNU General Public License
17// along with this library; see the file COPYING. If not, write to
18// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19// MA 02111-1307, USA.
20
21// As a special exception, you may use this file as part of a free
22// software library without restriction. Specifically, if other files
23// instantiate templates or use macros or inline functions from this
24// file, or you compile this file and link it with other files to
25// produce an executable, this file does not by itself cause the
26// resulting executable to be covered by the GNU General Public
27// License. This exception does not however invalidate any other
28// reasons why the executable file might be covered by the GNU General
29// Public License.
30
31// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32
33// Permission to use, copy, modify, sell, and distribute this software
34// is hereby granted without fee, provided that the above copyright
35// notice appears in all copies, and that both that copyright notice
36// and this permission notice appear in supporting documentation. None
37// of the above authors, nor IBM Haifa Research Laboratories, make any
38// representation about the suitability of this software for any
39// purpose. It is provided "as is" without express or implied
40// warranty.
41
42/**
43 * @file string_form.hpp
44 * Transforms containers into string form.
45 */
46
47#ifndef PB_DS_STRING_FORM_HPP
48#define PB_DS_STRING_FORM_HPP
49
50#include <string>
51#include <sstream>
52#include <ext/pb_ds/detail/type_utils.hpp>
53#include <ext/pb_ds/tag_and_trait.hpp>
54#include <native_type/assoc/native_hash_map.hpp>
55#include <native_type/assoc/native_hash_set.hpp>
56#include <native_type/assoc/native_multimap.hpp>
57#include <native_type/assoc/native_hash_multimap.hpp>
58#include <native_type/assoc/native_set.hpp>
59#include <common_type/assoc/template_policy.hpp>
60#include <common_type/assoc/detail/ds_string_form.hpp>
61#include <regression/basic_type.hpp>
62#include <io/xml.hpp>
63
64namespace pb_ds
65{
4569a895
AT
66 namespace test
67 {
4569a895
AT
68 namespace detail
69 {
4569a895
AT
70 template<typename Cntnr>
71 struct pb_ds_string_form
72 {
73 private:
74 typedef typename Cntnr::mapped_type mapped_type;
75
76 struct mapped_string_form
77 {
78 private:
79 template<typename D_Cntnr>
80 static std::string
3441f106
BK
81 name(D_Cntnr)
82 { return ("mmap_" + pb_ds_string_form<D_Cntnr>::name()); }
4569a895
AT
83
84 template<typename D_Cntnr>
85 static std::string
3441f106
BK
86 desc(D_Cntnr)
87 { return pb_ds_string_form<D_Cntnr>::desc(); }
4569a895
AT
88
89 static std::string
3441f106
BK
90 name(size_t)
91 { return ("map"); }
4569a895
AT
92
93 static std::string
3441f106
BK
94 desc(size_t)
95 { return (""); }
4569a895
AT
96
97 static std::string
3441f106
BK
98 name(basic_type)
99 { return ("map"); }
4569a895
AT
100
101 static std::string
3441f106
BK
102 desc(basic_type)
103 { return (""); }
4569a895
AT
104
105 static std::string
3441f106
BK
106 name(int)
107 { return ("map"); }
4569a895
AT
108
109 static std::string
3441f106
BK
110 desc(int)
111 { return (""); }
4569a895
AT
112
113 static std::string
3441f106
BK
114 name(char)
115 { return ("map"); }
4569a895
AT
116
117 static std::string
3441f106
BK
118 desc(char)
119 { return (""); }
4569a895
AT
120
121 static std::string
3441f106
BK
122 name(pb_ds::null_mapped_type)
123 { return ("set"); }
4569a895
AT
124
125 static std::string
3441f106
BK
126 desc(pb_ds::null_mapped_type)
127 { return (""); }
4569a895
AT
128
129 public:
130 static std::string
131 name()
3441f106 132 { return name(mapped_type()); }
4569a895
AT
133
134 static std::string
135 desc()
3441f106 136 { return desc(mapped_type()); }
4569a895
AT
137 };
138
139 typedef
3441f106 140 detail::ds_string_form<Cntnr, typename Cntnr::container_category>
4569a895
AT
141 ds_string_form_t;
142
143 public:
144 static std::string
145 name()
3441f106 146 { return (ds_string_form_t::name() + mapped_string_form::name()); }
4569a895
AT
147
148 static std::string
149 desc()
3441f106 150 { return (ds_string_form_t::desc() + mapped_string_form::desc()); }
4569a895
AT
151 };
152
153 template<typename Cntnr>
154 struct native_string_form
155 {
156 static std::string
157 name()
3441f106 158 { return Cntnr::name(); }
4569a895
AT
159
160 static std::string
161 desc()
3441f106 162 { return Cntnr::desc(); }
4569a895
AT
163 };
164
165 template<typename Cntnr, class Tag>
3441f106 166 struct tag_select_string_form : public pb_ds_string_form<Cntnr>
4569a895
AT
167 { };
168
169 template<typename Cntnr>
3441f106
BK
170 struct tag_select_string_form<Cntnr, native_hash_tag>
171 : public native_string_form<Cntnr>
4569a895
AT
172 { };
173
174 template<typename Cntnr>
3441f106
BK
175 struct tag_select_string_form<Cntnr, native_tree_tag>
176 : public native_string_form<Cntnr>
4569a895 177 { };
4569a895
AT
178 } // namespace detail
179
180 template<typename Cntnr>
3441f106
BK
181 struct string_form
182 : public detail::tag_select_string_form<Cntnr,
183 typename Cntnr::container_category>
4569a895 184 { };
4569a895 185 } // namespace test
4569a895
AT
186} // namespace pb_ds
187
3441f106 188#endif
4569a895 189