#ifndef UTIL_H #define UTIL_H #include #include #include #include #include #include "types.h" class Node; #include "Node.h" namespace Util { void Die(const char *msg); void Die(const char * msg, const char * more); void Die(std::string msg); template T* FindNodeByType(Node *&root, const Name &type) { if (root->GetType() == type) { return dynamic_cast(root); } for (Node *child : root->GetChildren()) { T* res = FindNodeByType(child, type); if (res) { return res; } } return nullptr; } template std::vector FindNodesByType(Node *&root, const Name &type) { std::vector nodes; if (root->GetType() == type) { nodes.push_back(dynamic_cast(root)); } for (Node *child : root->GetChildren()) { std::vector childs = FindNodesByType(child, type); nodes.insert(nodes.begin(), childs.begin(), childs.end()); } return nodes; } std::string ShaderArrayName(const char* arrName, int index, const char* memberName); } #endif /* UTIL_H */