|
4 | 4 |
|
5 | 5 | #pragma once |
6 | 6 |
|
| 7 | +#include "gl/attributes/force_inline.hpp" |
7 | 8 | #include "gl/constants.hpp" |
8 | 9 | #include "gl/directional_tags.hpp" |
9 | 10 | #include "gl/io/format.hpp" |
@@ -160,44 +161,80 @@ class edge_descriptor final { |
160 | 161 | return this->_properties.get(); |
161 | 162 | } |
162 | 163 |
|
163 | | - friend inline std::ostream& operator<<(std::ostream& os, const edge_descriptor& edge) { |
164 | | - edge._write(os); |
165 | | - return os; |
| 164 | + friend gl_attr_force_inline std::ostream& operator<<( |
| 165 | + std::ostream& os, const edge_descriptor& edge |
| 166 | + ) { |
| 167 | + return edge._write(os); |
166 | 168 | } |
167 | 169 |
|
168 | 170 | private: |
169 | | - void _write(std::ostream& os) const { |
| 171 | + std::ostream& _write(std::ostream& os) const |
| 172 | + requires std::same_as<directional_tag, undirected_t> |
| 173 | + { |
170 | 174 | using io::detail::option_bit; |
171 | 175 |
|
172 | 176 | if constexpr (not traits::c_writable<properties_type>) { |
173 | | - this->_write_no_properties(os); |
174 | | - return; |
| 177 | + return this->_write_no_properties(os); |
175 | 178 | } |
176 | 179 | else { |
177 | | - if (not io::is_option_set(os, option_bit::with_connection_properties)) { |
178 | | - this->_write_no_properties(os); |
179 | | - return; |
180 | | - } |
| 180 | + if (not io::is_option_set(os, option_bit::with_connection_properties)) |
| 181 | + return this->_write_no_properties(os); |
181 | 182 |
|
182 | | - // TODO: print ID |
183 | 183 | if (io::is_option_set(os, option_bit::verbose)) |
184 | | - os << "[source: " << this->_vertices.first << ", target: " << this->_vertices.second |
185 | | - << " | properties: " << this->_properties.get() << "]"; |
| 184 | + return os |
| 185 | + << "[id: " << this->_id << " | endpoints: {" << this->_vertices.first << ", " |
| 186 | + << this->_vertices.second << "} | " << this->_properties.get() << ']'; |
186 | 187 | else |
187 | | - os << "[" << this->_vertices.first << ", " << this->_vertices.second << " | " |
188 | | - << this->_properties.get() << "]"; |
| 188 | + return os << '{' << this->_vertices.first << ", " << this->_vertices.second << "}[" |
| 189 | + << this->_properties.get() << ']'; |
189 | 190 | } |
190 | 191 | } |
191 | 192 |
|
192 | | - void _write_no_properties(std::ostream& os) const { |
| 193 | + std::ostream& _write_no_properties(std::ostream& os) const |
| 194 | + requires std::same_as<directional_tag, undirected_t> |
| 195 | + { |
| 196 | + using io::detail::option_bit; |
| 197 | + |
| 198 | + if (io::is_option_set(os, option_bit::verbose)) |
| 199 | + return os << "[id: " << this->_id << " | endpoints: {" << this->_vertices.first << ", " |
| 200 | + << this->_vertices.second << "}]"; |
| 201 | + else |
| 202 | + return os << '{' << this->_vertices.first << ", " << this->_vertices.second << '}'; |
| 203 | + } |
| 204 | + |
| 205 | + std::ostream& _write(std::ostream& os) const |
| 206 | + requires std::same_as<directional_tag, directed_t> |
| 207 | + { |
| 208 | + using io::detail::option_bit; |
| 209 | + |
| 210 | + if constexpr (not traits::c_writable<properties_type>) { |
| 211 | + return this->_write_no_properties(os); |
| 212 | + } |
| 213 | + else { |
| 214 | + if (not io::is_option_set(os, option_bit::with_connection_properties)) |
| 215 | + return this->_write_no_properties(os); |
| 216 | + |
| 217 | + if (io::is_option_set(os, option_bit::verbose)) |
| 218 | + return os |
| 219 | + << "[id: " << this->_id << " | source: " << this->_vertices.first |
| 220 | + << ", target: " << this->_vertices.second << " | " << this->_properties.get() |
| 221 | + << ']'; |
| 222 | + else |
| 223 | + return os << '(' << this->_vertices.first << ", " << this->_vertices.second << ")[" |
| 224 | + << this->_properties.get() << ']'; |
| 225 | + } |
| 226 | + } |
| 227 | + |
| 228 | + std::ostream& _write_no_properties(std::ostream& os) const |
| 229 | + requires std::same_as<directional_tag, directed_t> |
| 230 | + { |
193 | 231 | using io::detail::option_bit; |
194 | 232 |
|
195 | | - // TODO: print ID |
196 | 233 | if (io::is_option_set(os, option_bit::verbose)) |
197 | | - os << "[source: " << this->_vertices.first << ", target: " << this->_vertices.first |
198 | | - << "]"; |
| 234 | + return os << "[id: " << this->_id << " | source: " << this->_vertices.first |
| 235 | + << ", target: " << this->_vertices.second << ']'; |
199 | 236 | else |
200 | | - os << "[" << this->_vertices.first << ", " << this->_vertices.second << "]"; |
| 237 | + return os << '(' << this->_vertices.first << ", " << this->_vertices.second << ')'; |
201 | 238 | } |
202 | 239 |
|
203 | 240 | id_type _id; |
|
0 commit comments