14 const string VuoGenericType::genericTypeNamePrefix =
"VuoGenericType";
22 this->compatibleSpecializedTypes = compatibleSpecializedTypes;
24 string compatiblesDescription;
28 compatiblesDescription =
"any type";
30 compatiblesDescription =
"any list type";
33 for (
size_t i = 0; i < compatibles.size(); ++i)
35 compatiblesDescription += compatibles[i];
36 if (compatibles.size() >= 3)
38 if (i < compatibles.size() - 2)
39 compatiblesDescription +=
", ";
40 else if (i == compatibles.size() - 2)
41 compatiblesDescription +=
", or ";
43 else if (compatibles.size() == 2 && i == 0)
44 compatiblesDescription +=
" or ";
47 string suffix = extractSuffixStringFromGenericTypeName(typeName);
49 setDefaultTitle(
"(" + typeDescription +
" — can connect to " + compatiblesDescription +
")" );
64 return find(compatibles.begin(), compatibles.end(), typeName) != compatibles.end();
77 if (thisCompatibility ==
anyType || otherCompatibility ==
anyType ||
82 std::sort(thisCompatibles.begin(), thisCompatibles.end());
83 std::sort(otherCompatibles.begin(), otherCompatibles.end());
85 set<string> bothCompatibles;
86 set_intersection(thisCompatibles.begin(), thisCompatibles.end(),
87 otherCompatibles.begin(), otherCompatibles.end(),
88 std::insert_iterator<set<string> >(bothCompatibles, bothCompatibles.begin() ));
89 return (! bothCompatibles.empty());
103 compatibility = (compatibleSpecializedTypes.empty() ?
109 return compatibleSpecializedTypes;
117 string genericTypeName;
119 return genericTypeName == typeName;
134 size_t genericStartPos = startPos;
138 genericStartPos = stringToSearch.find(genericTypeNamePrefix, genericStartPos);
139 if (genericStartPos == string::npos)
141 genericTypeName =
"";
146 for (
size_t i = genericStartPos + genericTypeNamePrefix.length(); i < stringToSearch.length(); ++i)
148 if (
'0' <= stringToSearch[i] && stringToSearch[i] <=
'9')
149 suffix += stringToSearch[i];
154 if (! suffix.empty())
163 genericStartPos = listPrefixStartPos;
167 genericTypeName = listPrefix + genericTypeNamePrefix + suffix;
171 genericStartPos += genericTypeNamePrefix.length();
174 return genericStartPos;
185 return genericTypeName;
187 string typeName = genericTypeName;
189 size_t innermostTypeNamePos = typeName.find(innermostTypeName);
190 typeName.replace(innermostTypeNamePos, innermostTypeName.length(), replacementTypeName);
200 oss << genericTypeNamePrefix << suffix;
209 sort(genericTypeNames.begin(), genericTypeNames.end(), isPairOfGenericTypesSorted);
215 bool VuoGenericType::isPairOfGenericTypesSorted(
string type1,
string type2)
217 unsigned int suffix1 = extractSuffixFromGenericTypeName(type1);
218 unsigned int suffix2 = extractSuffixFromGenericTypeName(type2);
219 return (suffix1 < suffix2);
225 string VuoGenericType::extractSuffixStringFromGenericTypeName(
string genericTypeName)
230 size_t prefixStartPos = genericTypeName.find(genericTypeNamePrefix);
231 size_t suffixStartPos = prefixStartPos + genericTypeNamePrefix.length();
232 return genericTypeName.substr(suffixStartPos);
238 unsigned int VuoGenericType::extractSuffixFromGenericTypeName(
string genericTypeName)
240 string suffixStr = extractSuffixStringFromGenericTypeName(genericTypeName);
241 unsigned int suffix = 0;
242 istringstream iss(suffixStr);