| 877 | } |
| 878 | |
| 879 | void StringResolver::addTokenSubstitutions(ConstElementPtr element) |
| 880 | { |
| 881 | const string DELIMITER_PREFIX = "["; |
| 882 | const string DELIMITER_POSTFIX = "]"; |
| 883 | |
| 884 | // Traverse from siblings up until root is reached. |
| 885 | // Child tokens override any parent tokens. |
| 886 | ConstElementPtr parent = element->getParent(); |
| 887 | while (parent) |
| 888 | { |
| 889 | ConstInterfaceElementPtr interfaceElem = parent->asA<InterfaceElement>(); |
| 890 | if (interfaceElem) |
| 891 | { |
| 892 | vector<TokenPtr> tokens = interfaceElem->getActiveTokens(); |
| 893 | for (auto token : tokens) |
| 894 | { |
| 895 | string key = DELIMITER_PREFIX + token->getName() + DELIMITER_POSTFIX; |
| 896 | string value = token->getResolvedValueString(); |
| 897 | if (!_filenameMap.count(key)) |
| 898 | { |
| 899 | setFilenameSubstitution(key, value); |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | // This is a functional nodegraph. Get the corresponding nodedef and |
| 904 | // check for tokens on it. |
| 905 | ConstNodeGraphPtr nodegraph = parent->asA<NodeGraph>(); |
| 906 | if (nodegraph) |
| 907 | { |
| 908 | NodeDefPtr nodedef = nodegraph->getNodeDef(); |
| 909 | if (nodedef) |
| 910 | { |
| 911 | tokens = nodedef->getActiveTokens(); |
| 912 | for (auto token : tokens) |
| 913 | { |
| 914 | string key = DELIMITER_PREFIX + token->getName() + DELIMITER_POSTFIX; |
| 915 | string value = token->getResolvedValueString(); |
| 916 | if (!_filenameMap.count(key)) |
| 917 | { |
| 918 | setFilenameSubstitution(key, value); |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | } |
| 925 | parent = parent->getParent(); |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | string StringResolver::resolve(const string& str, const string& type) const |
| 930 | { |
no test coverage detected