| 233 | } |
| 234 | |
| 235 | xml_node xml_write_node(Node *node, xml_node xml_root) |
| 236 | { |
| 237 | xml_node xml_node = xml_root.append_child(node->type->name.c_str()); |
| 238 | |
| 239 | xml_node.append_attribute("name") = node->name.c_str(); |
| 240 | |
| 241 | for (const SocketType &socket : node->type->inputs) { |
| 242 | if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) { |
| 243 | continue; |
| 244 | } |
| 245 | if (socket.flags & SocketType::INTERNAL) { |
| 246 | continue; |
| 247 | } |
| 248 | if (node->has_default_value(socket)) { |
| 249 | continue; |
| 250 | } |
| 251 | |
| 252 | xml_attribute attr = xml_node.append_attribute(socket.name.c_str()); |
| 253 | |
| 254 | switch (socket.type) { |
| 255 | case SocketType::BOOLEAN: { |
| 256 | attr = xml_write_boolean(node->get_bool(socket)); |
| 257 | break; |
| 258 | } |
| 259 | case SocketType::BOOLEAN_ARRAY: { |
| 260 | std::stringstream ss; |
| 261 | const array<bool> &value = node->get_bool_array(socket); |
| 262 | for (size_t i = 0; i < value.size(); i++) { |
| 263 | ss << xml_write_boolean(value[i]); |
| 264 | if (i != value.size() - 1) { |
| 265 | ss << " "; |
| 266 | } |
| 267 | } |
| 268 | attr = ss.str().c_str(); |
| 269 | break; |
| 270 | } |
| 271 | case SocketType::FLOAT: { |
| 272 | attr = (double)node->get_float(socket); |
| 273 | break; |
| 274 | } |
| 275 | case SocketType::FLOAT_ARRAY: { |
| 276 | std::stringstream ss; |
| 277 | const array<float> &value = node->get_float_array(socket); |
| 278 | for (size_t i = 0; i < value.size(); i++) { |
| 279 | ss << value[i]; |
| 280 | if (i != value.size() - 1) { |
| 281 | ss << " "; |
| 282 | } |
| 283 | } |
| 284 | attr = ss.str().c_str(); |
| 285 | break; |
| 286 | } |
| 287 | case SocketType::INT: { |
| 288 | attr = node->get_int(socket); |
| 289 | break; |
| 290 | } |
| 291 | case SocketType::UINT: { |
| 292 | attr = node->get_uint(socket); |
nothing calls this directly
no test coverage detected