]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / common_type / assoc / string_form.hpp
CommitLineData
4569a895
AT
1// -*- C++ -*-
2
a945c346 3// Copyright (C) 2005-2024 Free Software Foundation, Inc.
4569a895
AT
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
748086b7 8// Foundation; either version 3, or (at your option) any later
4569a895
AT
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
748086b7
JJ
17// along with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
4569a895 19
4569a895
AT
20
21// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
22
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
30// warranty.
31
32/**
33 * @file string_form.hpp
34 * Transforms containers into string form.
35 */
36
37#ifndef PB_DS_STRING_FORM_HPP
38#define PB_DS_STRING_FORM_HPP
39
40#include <string>
41#include <sstream>
42#include <ext/pb_ds/detail/type_utils.hpp>
43#include <ext/pb_ds/tag_and_trait.hpp>
2e3f9c21
BK
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>
4569a895
AT
49#include <common_type/assoc/template_policy.hpp>
50#include <common_type/assoc/detail/ds_string_form.hpp>
51#include <regression/basic_type.hpp>
52#include <io/xml.hpp>
53
5e11f978 54namespace __gnu_pbds
4569a895 55{
4569a895
AT
56 namespace test
57 {
4569a895
AT
58 namespace detail
59 {
4569a895
AT
60 template<typename Cntnr>
61 struct pb_ds_string_form
62 {
63 private:
64 typedef typename Cntnr::mapped_type mapped_type;
65
66 struct mapped_string_form
67 {
68 private:
69 template<typename D_Cntnr>
70 static std::string
3441f106
BK
71 name(D_Cntnr)
72 { return ("mmap_" + pb_ds_string_form<D_Cntnr>::name()); }
4569a895
AT
73
74 template<typename D_Cntnr>
75 static std::string
3441f106
BK
76 desc(D_Cntnr)
77 { return pb_ds_string_form<D_Cntnr>::desc(); }
4569a895
AT
78
79 static std::string
3441f106
BK
80 name(size_t)
81 { return ("map"); }
4569a895
AT
82
83 static std::string
3441f106
BK
84 desc(size_t)
85 { return (""); }
4569a895
AT
86
87 static std::string
3441f106
BK
88 name(basic_type)
89 { return ("map"); }
4569a895
AT
90
91 static std::string
3441f106
BK
92 desc(basic_type)
93 { return (""); }
4569a895
AT
94
95 static std::string
3441f106
BK
96 name(int)
97 { return ("map"); }
4569a895
AT
98
99 static std::string
3441f106
BK
100 desc(int)
101 { return (""); }
4569a895
AT
102
103 static std::string
3441f106
BK
104 name(char)
105 { return ("map"); }
4569a895
AT
106
107 static std::string
3441f106
BK
108 desc(char)
109 { return (""); }
4569a895
AT
110
111 static std::string
a345e45d 112 name(__gnu_pbds::null_type)
3441f106 113 { return ("set"); }
4569a895
AT
114
115 static std::string
a345e45d 116 desc(__gnu_pbds::null_type)
3441f106 117 { return (""); }
4569a895
AT
118
119 public:
120 static std::string
121 name()
3441f106 122 { return name(mapped_type()); }
4569a895
AT
123
124 static std::string
125 desc()
3441f106 126 { return desc(mapped_type()); }
4569a895
AT
127 };
128
129 typedef
3441f106 130 detail::ds_string_form<Cntnr, typename Cntnr::container_category>
4569a895
AT
131 ds_string_form_t;
132
133 public:
134 static std::string
135 name()
3441f106 136 { return (ds_string_form_t::name() + mapped_string_form::name()); }
4569a895
AT
137
138 static std::string
139 desc()
3441f106 140 { return (ds_string_form_t::desc() + mapped_string_form::desc()); }
4569a895
AT
141 };
142
143 template<typename Cntnr>
144 struct native_string_form
145 {
146 static std::string
147 name()
3441f106 148 { return Cntnr::name(); }
4569a895
AT
149
150 static std::string
151 desc()
3441f106 152 { return Cntnr::desc(); }
4569a895
AT
153 };
154
155 template<typename Cntnr, class Tag>
3441f106 156 struct tag_select_string_form : public pb_ds_string_form<Cntnr>
4569a895
AT
157 { };
158
159 template<typename Cntnr>
f92ab29f 160 struct tag_select_string_form<Cntnr, native_hash_tag>
3441f106 161 : public native_string_form<Cntnr>
4569a895
AT
162 { };
163
164 template<typename Cntnr>
f92ab29f 165 struct tag_select_string_form<Cntnr, native_tree_tag>
3441f106 166 : public native_string_form<Cntnr>
4569a895 167 { };
4569a895
AT
168 } // namespace detail
169
170 template<typename Cntnr>
f92ab29f
CG
171 struct string_form
172 : public detail::tag_select_string_form<Cntnr,
3441f106 173 typename Cntnr::container_category>
4569a895 174 { };
4569a895 175 } // namespace test
5e11f978 176} // namespace __gnu_pbds
4569a895 177
3441f106 178#endif
4569a895 179