]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / common_type / assoc / detail / ds_string_form.hpp
1 // -*- C++ -*-
2
3 // Copyright (C) 2005-2019 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 3, 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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
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 ds_string_form.hpp
34 * Transforms containers into string form.
35 */
36
37 #ifndef PB_DS_DS_STRING_FORM_HPP
38 #define PB_DS_DS_STRING_FORM_HPP
39
40 #include <string>
41 #include <ext/pb_ds/tag_and_trait.hpp>
42 #include <common_type/assoc/detail/list_update_policy_string_form.hpp>
43 #include <common_type/assoc/detail/comb_hash_fn_string_form.hpp>
44 #include <common_type/assoc/detail/resize_policy_string_form.hpp>
45 #include <common_type/assoc/detail/probe_fn_string_form.hpp>
46 #include <common_type/assoc/detail/tree_supports_order_statistics.hpp>
47 #include <common_type/assoc/detail/trie_supports_order_statistics.hpp>
48 #include <common_type/assoc/detail/trie_supports_prefix_search.hpp>
49 #include <common_type/assoc/detail/store_hash_string_form.hpp>
50 #include <io/xml.hpp>
51
52 namespace __gnu_pbds
53 {
54 namespace test
55 {
56 namespace detail
57 {
58 template<typename Cntnr, class Tag>
59 struct ds_string_form;
60
61 template<typename Cntnr>
62 struct ds_string_form<Cntnr, __gnu_pbds::cc_hash_tag>
63 {
64 static std::string
65 name()
66 {
67 return ("cc_hash_" +
68 comb_hash_fn_string_form<typename Cntnr::comb_hash_fn>::name() +
69 resize_policy_string_form<typename Cntnr::resize_policy>::name() +
70 store_hash_string_form<Cntnr::store_hash>::name());
71 }
72
73 static std::string
74 desc()
75 {
76 const std::string comb_hash_fn_desc =
77 comb_hash_fn_string_form<typename Cntnr::comb_hash_fn>::desc();
78
79 const std::string resize_policy_desc =
80 resize_policy_string_form<typename Cntnr::resize_policy>::desc();
81
82 const std::string store_hash_desc =
83 store_hash_string_form<Cntnr::store_hash>::desc();
84
85 return (make_xml_tag("type", "value", "cc_hash_table", comb_hash_fn_desc + resize_policy_desc + store_hash_desc));
86 }
87 };
88
89 template<typename Cntnr>
90 struct ds_string_form<Cntnr, __gnu_pbds::gp_hash_tag>
91 {
92 static std::string
93 name()
94 {
95 return ("gp_hash_" +
96 comb_hash_fn_string_form<typename Cntnr::comb_probe_fn>::name() +
97 probe_fn_string_form<typename Cntnr::probe_fn>::name() +
98 resize_policy_string_form<typename Cntnr::resize_policy>::name() +
99 store_hash_string_form<Cntnr::store_hash>::name());
100 }
101
102 static std::string
103 desc()
104 {
105 const std::string comb_probe_fn_desc =
106 comb_hash_fn_string_form<typename Cntnr::comb_probe_fn>::desc();
107
108 const std::string probe_fn_desc =
109 probe_fn_string_form<typename Cntnr::probe_fn>::desc();
110
111 const std::string resize_policy_desc =
112 resize_policy_string_form<typename Cntnr::resize_policy>::desc();
113
114 const std::string store_hash_desc =
115 store_hash_string_form<Cntnr::store_hash>::desc();
116
117 return make_xml_tag("type", "value", "gp_hash_table",
118 comb_probe_fn_desc + probe_fn_desc + resize_policy_desc + store_hash_desc);
119 }
120 };
121
122 template<typename Cntnr>
123 struct tree_ds_string_form
124 {
125 static std::string
126 name(const std::string container_category_str)
127 {
128 if (tree_supports_order_statistics<Cntnr>::value)
129 return (container_category_str + "ost_");
130 return container_category_str;
131 }
132
133 static std::string
134 desc(const std::string container_category_str)
135 {
136 const std::string category_str =
137 make_xml_tag("Tag", "value", container_category_str);
138
139 const std::string node_update_str =
140 make_xml_tag("Node_Update",
141 "value",(tree_supports_order_statistics<Cntnr>::value ?
142 "tree_order_statistics_node_update" : "null_node_update"));
143
144 return make_xml_tag("type", "value", "tree", category_str + node_update_str);
145 }
146 };
147
148 template<typename Cntnr>
149 struct ds_string_form<Cntnr, __gnu_pbds::rb_tree_tag>
150 : private tree_ds_string_form<Cntnr>
151 {
152 private:
153 typedef tree_ds_string_form< Cntnr> base_type;
154
155 public:
156 static std::string
157 name()
158 { return base_type::name("rb_tree_"); }
159
160 static std::string
161 desc()
162 { return base_type::desc("rb_tree_tag"); }
163 };
164
165 template<typename Cntnr>
166 struct ds_string_form<Cntnr, __gnu_pbds::splay_tree_tag>
167 : private tree_ds_string_form<Cntnr>
168 {
169 private:
170 typedef tree_ds_string_form< Cntnr> base_type;
171
172 public:
173 static std::string
174 name()
175 { return base_type::name("splay_tree_"); }
176
177 static std::string
178 desc()
179 { return base_type::desc("splay_tree_tag"); }
180 };
181
182 template<typename Cntnr>
183 struct ds_string_form<Cntnr, __gnu_pbds::ov_tree_tag>
184 : private tree_ds_string_form<Cntnr>
185 {
186 private:
187 typedef tree_ds_string_form< Cntnr> base_type;
188
189 public:
190 static std::string
191 name()
192 { return (base_type::name("ov_tree_")); }
193
194 static std::string
195 desc()
196 { return (base_type::desc("ov_tree_tag")); }
197 };
198
199 template<typename Cntnr>
200 struct ds_string_form<Cntnr, __gnu_pbds::list_update_tag>
201 {
202 static std::string
203 name()
204 {
205 return ("lu_" +
206 lu_policy_string_form<typename Cntnr::update_policy>::name());
207 }
208
209 static std::string
210 desc()
211 {
212 return make_xml_tag("type", "value", "list_update",
213 lu_policy_string_form<typename Cntnr::update_policy>::desc());
214 }
215 };
216
217 template<typename Cntnr>
218 struct ds_string_form<Cntnr, __gnu_pbds::pat_trie_tag>
219 {
220 static std::string
221 name()
222 {
223 if (trie_supports_order_statistics<Cntnr>::value)
224 return ("pat_trie_ost_");
225
226 if (trie_supports_prefix_search<Cntnr>::value)
227 return ("pat_trie_prs_");
228
229 return ("pat_trie_");
230 }
231
232 static std::string
233 desc()
234 {
235 std::string category_s = make_xml_tag("Tag", "value", "pat_trie_tag");
236 const char* s;
237 if (trie_supports_order_statistics<Cntnr>::value)
238 s = "trie_order_statistics_node_update";
239 else if (trie_supports_prefix_search<Cntnr>::value)
240 s = "trie_prefix_search_node_update";
241 else
242 s = "null_node_update";
243 std::string node_s = make_xml_tag("Node_Update", "value", s);
244 return make_xml_tag("type", "value", "trie", category_s + node_s);
245 }
246 };
247
248 } // namespace detail
249
250 } // namespace test
251
252 } // namespace __gnu_pbds
253
254 #endif // #ifndef PB_DS_DS_STRING_FORM_HPP
255