Пример #1
0
/**
 * @ingroup VuoText
 * Returns the index (starting at 1) of the last instance of @a substring in @a string.
 * Returns 0 if @a substring is not found.
 *
 * This function will find occurrences that consist of the same Unicode characters as @a substring, but won't find
 * occurrences that consist of the same Unicode string decomposed into a different number of Unicode characters.
 */
size_t VuoText_findLastOccurrence(const VuoText string, const VuoText substring)
{
	if (! string)
		return 0;

	size_t foundIndex = 0;

	size_t stringLength = VuoText_length(string);
	size_t substringLength = VuoText_length(substring);
	for (size_t i = 1; i <= stringLength - substringLength + 1; ++i)
	{
		VuoText currSubstring = VuoText_substring(string, i, substringLength);
		if (VuoText_areEqual(substring, currSubstring))
			foundIndex = i;
		VuoRetain(currSubstring);
		VuoRelease(currSubstring);
	}

	return foundIndex;
}
Пример #2
0
/**
 * Searches the scenegraph (depth-first) for a scene object with the given name.
 *
 * @param so The root object of the scenegraph to search.
 * @param nameToMatch The name to search for.
 * @param[out] ancestorObjects The ancestors of @a foundObject, starting with the root of the scenegraph.
 * @param[out] foundObject The first matching scene object found.
 * @return True if a matching scene object was found.
 */
bool VuoSceneObject_find(VuoSceneObject so, VuoText nameToMatch, VuoList_VuoSceneObject ancestorObjects, VuoSceneObject *foundObject)
{
	if (VuoText_areEqual(so.name, nameToMatch))
	{
		*foundObject = so;
		return true;
	}

	VuoListAppendValue_VuoSceneObject(ancestorObjects, so);

	unsigned long childObjectCount = (so.childObjects ? VuoListGetCount_VuoSceneObject(so.childObjects) : 0);
	for (unsigned long i = 1; i <= childObjectCount; ++i)
	{
		VuoSceneObject childObject = VuoListGetValue_VuoSceneObject(so.childObjects, i);
		if (VuoSceneObject_find(childObject, nameToMatch, ancestorObjects, foundObject))
			return true;
	}

	VuoListRemoveLastValue_VuoSceneObject(ancestorObjects);

	return false;
}
Пример #3
0
/**
 * Returns true if the two audio output device specifications are identical.
 */
bool VuoAudioOutputDevice_areEqual(VuoAudioOutputDevice value1, VuoAudioOutputDevice value2)
{
	return (value1.id == value2.id &&
			VuoText_areEqual(value1.name, value2.name) &&
			value1.channelCount == value2.channelCount);
}
Пример #4
0
/**
 * Returns true if the two MIDI device specifications are identical.
 */
bool VuoMidiInputDevice_areEqual(const VuoMidiInputDevice value1, const VuoMidiInputDevice value2)
{
	return value1.id == value2.id
		&& VuoText_areEqual(value1.name, value2.name);
}
/**
 * @ingroup VuoSyphonServerDescription
 * Returns true if the server descriptions are identical.
 */
bool VuoSyphonServerDescription_areEqual(const VuoSyphonServerDescription value1, const VuoSyphonServerDescription value2)
{
	return (VuoText_areEqual(value1.serverUUID, value2.serverUUID) &&
			VuoText_areEqual(value1.serverName, value2.serverName) &&
			VuoText_areEqual(value1.applicationName, value2.applicationName));
}