15static bool xml_read_boolean(
const char *
value)
20static const char *xml_write_boolean(
bool value)
22 return (
value) ?
"true" :
"false";
25template<
int VECTOR_SIZE,
typename T>
31 if (tokens.size() % VECTOR_SIZE != 0) {
35 value.resize(tokens.size() / VECTOR_SIZE);
36 for (
size_t i = 0; i <
value.size(); i++) {
37 float *value_float = (
float *)&
value[i];
39 for (
size_t j = 0; j < VECTOR_SIZE; j++) {
40 value_float[j] = (float)atof(tokens[i * VECTOR_SIZE + j].c_str());
45void xml_read_node(XMLReader &reader,
Node *
node,
const xml_node xml_node)
47 const xml_attribute name_attr = xml_node.attribute(
"name");
49 node->name = ustring(name_attr.value());
60 const xml_attribute attr = xml_node.attribute(socket.name.c_str());
66 switch (socket.type) {
68 node->set(socket, xml_read_boolean(attr.value()));
76 value.resize(tokens.size());
77 for (
size_t i = 0; i <
value.size(); i++) {
78 value[i] = xml_read_boolean(tokens[i].c_str());
84 node->set(socket, (
float)atof(attr.value()));
94 node->set(socket, atoi(attr.value()));
98 node->set(socket, (
uint)atoi(attr.value()));
102 node->set(socket, (
uint64_t)strtoull(attr.value(),
nullptr, 10));
110 value.resize(tokens.size());
111 for (
size_t i = 0; i <
value.size(); i++) {
112 value[i] = atoi(attr.value());
123 if (
value.size() == 1) {
140 if (
value.size() == 1) {
152 node->set(socket, attr.value());
156 const ustring
value(attr.value());
157 if (socket.enum_values->exists(
value)) {
162 "Unknown value \"%s\" for attribute \"%s\".\n",
164 socket.name.c_str());
173 value.resize(tokens.size());
174 for (
size_t i = 0; i <
value.size(); i++) {
175 value[i] = ustring(tokens[i]);
183 if (
value.size() == 1) {
195 const ustring
value(attr.value());
196 const map<ustring, Node *>::iterator it = reader.node_map.find(
value);
197 if (it != reader.node_map.end()) {
198 Node *value_node = it->second;
199 if (value_node->
is_a(socket.node_type)) {
200 node->set(socket, it->second);
210 value.resize(tokens.size());
211 for (
size_t i = 0; i <
value.size(); i++) {
212 const map<ustring, Node *>::iterator it = reader.node_map.find(ustring(tokens[i]));
213 if (it != reader.node_map.end()) {
214 Node *value_node = it->second;
231 if (!
node->name.empty()) {
236xml_node xml_write_node(
Node *
node, xml_node xml_root)
238 xml_node xml_node = xml_root.append_child(
node->type->name.c_str());
240 xml_node.append_attribute(
"name") =
node->name.c_str();
249 if (
node->has_default_value(socket)) {
253 xml_attribute attr = xml_node.append_attribute(socket.name.c_str());
255 switch (socket.type) {
257 attr = xml_write_boolean(
node->get_bool(socket));
261 std::stringstream ss;
263 for (
size_t i = 0; i <
value.size(); i++) {
264 ss << xml_write_boolean(
value[i]);
265 if (i !=
value.size() - 1) {
269 attr = ss.str().c_str();
273 attr = (double)
node->get_float(socket);
277 std::stringstream ss;
279 for (
size_t i = 0; i <
value.size(); i++) {
281 if (i !=
value.size() - 1) {
285 attr = ss.str().c_str();
289 attr =
node->get_int(socket);
293 attr =
node->get_uint(socket);
297 attr =
node->get_uint64(socket);
301 std::stringstream ss;
303 for (
size_t i = 0; i <
value.size(); i++) {
305 if (i !=
value.size() - 1) {
309 attr = ss.str().c_str();
325 std::stringstream ss;
327 for (
size_t i = 0; i <
value.size(); i++) {
330 if (i !=
value.size() - 1) {
334 attr = ss.str().c_str();
343 std::stringstream ss;
345 for (
size_t i = 0; i <
value.size(); i++) {
347 if (i !=
value.size() - 1) {
351 attr = ss.str().c_str();
356 attr =
node->get_string(socket).c_str();
360 std::stringstream ss;
362 for (
size_t i = 0; i <
value.size(); i++) {
364 if (i !=
value.size() - 1) {
368 attr = ss.str().c_str();
373 std::stringstream ss;
374 for (
int i = 0; i < 3; i++) {
382 attr = ss.str().c_str();
386 std::stringstream ss;
388 for (
size_t j = 0; j <
value.size(); j++) {
391 for (
int i = 0; i < 3; i++) {
399 if (j !=
value.size() - 1) {
403 attr = ss.str().c_str();
409 attr =
value->name.c_str();
414 std::stringstream ss;
416 for (
size_t i = 0; i <
value.size(); i++) {
418 ss <<
value[i]->name.c_str();
420 if (i !=
value.size() - 1) {
424 attr = ss.str().c_str();
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
static bool xml_read_float_array(vector< float > &value, const xml_node node, const char *name)
#define CCL_NAMESPACE_END
static blender::bke::bNodeSocketTemplate inputs[]
unsigned __int64 uint64_t
bool string_iequals(const string &a, const string &b)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
void string_split(vector< string > &tokens, const string &str, const string &separators, bool skip_empty_tokens)
bool is_a(const NodeType *type)