]>
Commit | Line | Data |
---|---|---|
4569a895 AT |
1 | // -*- C++ -*- |
2 | ||
99dee823 | 3 | // Copyright (C) 2005-2021 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 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 | ||
5e11f978 | 52 | namespace __gnu_pbds |
4569a895 | 53 | { |
4569a895 AT |
54 | namespace test |
55 | { | |
4569a895 AT |
56 | namespace detail |
57 | { | |
4569a895 AT |
58 | template<typename Cntnr, class Tag> |
59 | struct ds_string_form; | |
60 | ||
61 | template<typename Cntnr> | |
2e3f9c21 | 62 | struct ds_string_form<Cntnr, __gnu_pbds::cc_hash_tag> |
4569a895 AT |
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 | ||
2e3f9c21 | 85 | return (make_xml_tag("type", "value", "cc_hash_table", comb_hash_fn_desc + resize_policy_desc + store_hash_desc)); |
4569a895 AT |
86 | } |
87 | }; | |
88 | ||
89 | template<typename Cntnr> | |
2e3f9c21 | 90 | struct ds_string_form<Cntnr, __gnu_pbds::gp_hash_tag> |
4569a895 AT |
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(); | |
f92ab29f CG |
116 | |
117 | return make_xml_tag("type", "value", "gp_hash_table", | |
2e3f9c21 | 118 | comb_probe_fn_desc + probe_fn_desc + resize_policy_desc + store_hash_desc); |
4569a895 AT |
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_"); | |
2e3f9c21 | 130 | return container_category_str; |
4569a895 AT |
131 | } |
132 | ||
133 | static std::string | |
134 | desc(const std::string container_category_str) | |
135 | { | |
136 | const std::string category_str = | |
2e3f9c21 | 137 | make_xml_tag("Tag", "value", container_category_str); |
4569a895 AT |
138 | |
139 | const std::string node_update_str = | |
2e3f9c21 BK |
140 | make_xml_tag("Node_Update", |
141 | "value",(tree_supports_order_statistics<Cntnr>::value ? | |
a345e45d | 142 | "tree_order_statistics_node_update" : "null_node_update")); |
4569a895 | 143 | |
2e3f9c21 | 144 | return make_xml_tag("type", "value", "tree", category_str + node_update_str); |
4569a895 AT |
145 | } |
146 | }; | |
147 | ||
148 | template<typename Cntnr> | |
f92ab29f | 149 | struct ds_string_form<Cntnr, __gnu_pbds::rb_tree_tag> |
2e3f9c21 | 150 | : private tree_ds_string_form<Cntnr> |
4569a895 AT |
151 | { |
152 | private: | |
153 | typedef tree_ds_string_form< Cntnr> base_type; | |
154 | ||
155 | public: | |
156 | static std::string | |
157 | name() | |
2e3f9c21 | 158 | { return base_type::name("rb_tree_"); } |
4569a895 AT |
159 | |
160 | static std::string | |
161 | desc() | |
2e3f9c21 | 162 | { return base_type::desc("rb_tree_tag"); } |
4569a895 AT |
163 | }; |
164 | ||
165 | template<typename Cntnr> | |
f92ab29f | 166 | struct ds_string_form<Cntnr, __gnu_pbds::splay_tree_tag> |
2e3f9c21 | 167 | : private tree_ds_string_form<Cntnr> |
4569a895 AT |
168 | { |
169 | private: | |
170 | typedef tree_ds_string_form< Cntnr> base_type; | |
171 | ||
172 | public: | |
173 | static std::string | |
174 | name() | |
2e3f9c21 | 175 | { return base_type::name("splay_tree_"); } |
4569a895 AT |
176 | |
177 | static std::string | |
178 | desc() | |
2e3f9c21 | 179 | { return base_type::desc("splay_tree_tag"); } |
4569a895 AT |
180 | }; |
181 | ||
182 | template<typename Cntnr> | |
f92ab29f | 183 | struct ds_string_form<Cntnr, __gnu_pbds::ov_tree_tag> |
2e3f9c21 | 184 | : private tree_ds_string_form<Cntnr> |
4569a895 AT |
185 | { |
186 | private: | |
187 | typedef tree_ds_string_form< Cntnr> base_type; | |
188 | ||
189 | public: | |
190 | static std::string | |
191 | name() | |
2e3f9c21 | 192 | { return (base_type::name("ov_tree_")); } |
4569a895 AT |
193 | |
194 | static std::string | |
195 | desc() | |
2e3f9c21 | 196 | { return (base_type::desc("ov_tree_tag")); } |
4569a895 AT |
197 | }; |
198 | ||
199 | template<typename Cntnr> | |
2e3f9c21 | 200 | struct ds_string_form<Cntnr, __gnu_pbds::list_update_tag> |
4569a895 AT |
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 | { | |
2e3f9c21 BK |
212 | return make_xml_tag("type", "value", "list_update", |
213 | lu_policy_string_form<typename Cntnr::update_policy>::desc()); | |
4569a895 AT |
214 | } |
215 | }; | |
216 | ||
217 | template<typename Cntnr> | |
2e3f9c21 | 218 | struct ds_string_form<Cntnr, __gnu_pbds::pat_trie_tag> |
4569a895 AT |
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 | { | |
2e3f9c21 BK |
235 | std::string category_s = make_xml_tag("Tag", "value", "pat_trie_tag"); |
236 | const char* s; | |
4569a895 | 237 | if (trie_supports_order_statistics<Cntnr>::value) |
2e3f9c21 | 238 | s = "trie_order_statistics_node_update"; |
4569a895 | 239 | else if (trie_supports_prefix_search<Cntnr>::value) |
2e3f9c21 | 240 | s = "trie_prefix_search_node_update"; |
4569a895 | 241 | else |
a345e45d | 242 | s = "null_node_update"; |
2e3f9c21 BK |
243 | std::string node_s = make_xml_tag("Node_Update", "value", s); |
244 | return make_xml_tag("type", "value", "trie", category_s + node_s); | |
4569a895 AT |
245 | } |
246 | }; | |
247 | ||
248 | } // namespace detail | |
249 | ||
250 | } // namespace test | |
251 | ||
5e11f978 | 252 | } // namespace __gnu_pbds |
4569a895 AT |
253 | |
254 | #endif // #ifndef PB_DS_DS_STRING_FORM_HPP | |
255 |