Пример #1
0
// Initialises the properties provided.
void initSpecificPropertiesFromArray(char** properties, int count) {
   int i;
	int propertyIndex, currentIndex = 0;
   char *currentProperty;
   int currentLength = 0;

	// Count the number of valid properties.
	_requiredPropertiesCount = 0;
   for (i = 0; i < count; i++) {
      currentProperty = properties[i];
      currentLength = strlen(currentProperty);
      if (getPropertyIndexRange(currentProperty, currentLength) > 0)
			_requiredPropertiesCount++;
   }

	// Create enough memory for the properties.
	_requiredProperties = (uint32_t*)malloc(_requiredPropertiesCount * sizeof(int));
	_requiredPropertiesNames = (char**)malloc(_requiredPropertiesCount * sizeof(char**));


	// Initialise the requiredProperties array.
   for (i = 0; i < count; i++ ) {
      currentProperty = properties[i];
      currentLength = strlen(currentProperty);
      // If this is a valid property add it to the list.
		propertyIndex = getPropertyIndexRange(currentProperty, currentLength);
		if (propertyIndex > 0) {
			*(_requiredProperties + currentIndex) = propertyIndex;
			*(_requiredPropertiesNames + currentIndex) = _strings + *(_properties + propertyIndex);
			currentIndex++;
		}
   }
}
Пример #2
0
// Initialises the properties provided.
void initSpecificProperties(char* properties) {
	char *start, *end;
	int propertyIndex, currentIndex = 0;

	// Count the number of valid properties.
	_requiredPropertiesCount = 0;
	start = properties;
	end = properties - 1;
	do {
		end++;
		if (*end == '|' || *end == ',' || *end == '\0') {
			// Check the property we've just reached is valid and
			// if it is then increase the count.
			if (getPropertyIndexRange(start, end) > 0)
				_requiredPropertiesCount++;
			start = end + 1;
		}
	} while (*end != '\0');

	// Create enough memory for the properties.
	_requiredProperties = (uint32_t*)malloc(_requiredPropertiesCount * sizeof(int));
	_requiredPropertiesNames = (char**)malloc(_requiredPropertiesCount * sizeof(char**));

	// Initialise the requiredProperties array.
	start = properties;
	end = properties - 1;
	do {
		end++;
		if (*end == '|' || *end == ',' || *end == '\0') {
			// If this is a valid property add it to the list.
			propertyIndex = getPropertyIndexRange(start, end);
			if (propertyIndex > 0) {
				*(_requiredProperties + currentIndex) = propertyIndex;
				*(_requiredPropertiesNames + currentIndex) = _strings + *(_properties + propertyIndex);
				currentIndex++;
			}
			start = end + 1;
		}

	} while (*end != '\0');
}