void QalfConfig::setProperty(QString &key, QString &value) {
    QString keyCopy(key) ;
    QString valueCopy(value) ;
    qDebug() << "asking for lock write" ;
    lock.lockForWrite() ;
    qDebug() << "lock got" ;
    properties[keyCopy] = valueCopy ;
    qDebug() << "releasing lock" ;
    lock.unlock() ;
}
Пример #2
0
void UltimateLyricsProvider::doUrlReplace(const QString &tag, const QString &value, QString &u) const
{
    if (!u.contains(tag)) {
        return;
    }

    // Apply URL character replacement
    QString valueCopy(value);
    for (const UltimateLyricsProvider::UrlFormat& format: urlFormats) {
        QRegExp re("[" + QRegExp::escape(format.first) + "]");
        valueCopy.replace(re, format.second);
    }
    u.replace(tag, urlEncode(valueCopy), Qt::CaseInsensitive);
}
Пример #3
0
void Preferences_set(Preferences * self, const char * key, DataValue value) {
	struct PreferencesEvent event;
	DataValue * previousValue;
	
	event.key = key;
	event.value = value;
	previousValue = hashGet(self->private_ivar(hashTable), key);
	if (previousValue == NULL) {
		memset(&event.previousValue, 0, sizeof(event.previousValue));
		event.previousValue.type = value.type;
	} else {
		event.previousValue = *previousValue;
	}
	EventDispatcher_dispatchEvent(self->eventDispatcher, ATOM(PREFERENCES_EVENT_VALUE_CHANGED), &event);
	
	hashSet(self->private_ivar(hashTable), key, valueCopy(&event.value));
}
Пример #4
0
void arrayElementFetch(dplVal *result, dplVal *_array, dplVal *element) {
	dplVal array, *elementData;


	/* check to see if we need to fetch the array */
	if(_array->isArray != TRUE) {
		if(variableFetch(&array, _array) == FAILURE) {
			dplError(DPL_CORE, "failed fetching array %s in arrayElementFetch", _array->value.str.val);
			return;
		}
	}
	else {
		arrayValueCopy(&array, _array);
	}

#ifdef DEBUG
	printf("arrayElementFetch array check (init = %d, ce = %d, elements = %d)\n", array.value.array.elements->isInit, array.value.array.currentElement, array.value.array.elements->numElements);
#endif

	/* fetch the element data */
	if(dplHashIndexFind(array.value.array.elements, element->value.ival, (void **) &elementData) == FAILURE) {
		dplError(DPL_WARNINGL, "cannot fetch element %d of array %s", element->value.ival, _array->value.str.val);
		result->isNull = TRUE;
		return;
	}
	else {
#ifdef DEBUG
		printf("fetched element %d from array %s successfully\n", element->value.ival, _array->value.str.val);
#endif
	}
	
	/* result */
	if(elementData->isArray == TRUE) {
		arrayValueCopy(result, elementData);
	}
	else {
		valueCopy(result, elementData);
	}
}
Пример #5
0
static void testCopy() {
	DataValue value, copy;
	HashTable * hashTable;
	DataArray * array;
	AssociativeArray * assArray;
	
	value = valueCreateBoolean(false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_BOOLEAN, "Expected %d but got %d", DATA_TYPE_BOOLEAN, copy.type);
	TestCase_assert(!copy.value.boolean, "Expected false but got true");
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateBoolean(true);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_BOOLEAN, "Expected %d but got %d", DATA_TYPE_BOOLEAN, copy.type);
	TestCase_assert(copy.value.boolean, "Expected true but got false");
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateInt8(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT8, "Expected %d but got %d", DATA_TYPE_INT8, copy.type);
	TestCase_assert(copy.value.int8 == 0, "Expected 0 but got %d", copy.value.int8);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateInt8(INT8_MIN);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT8, "Expected %d but got %d", DATA_TYPE_INT8, copy.type);
	TestCase_assert(copy.value.int8 == INT8_MIN, "Expected -128 but got %d", copy.value.int8);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateUInt8(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT8, "Expected %d but got %d", DATA_TYPE_UINT8, copy.type);
	TestCase_assert(copy.value.uint8 == 0, "Expected 0 but got %u", copy.value.uint8);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateUInt8(UINT8_MAX);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT8, "Expected %d but got %d", DATA_TYPE_UINT8, copy.type);
	TestCase_assert(copy.value.uint8 == UINT8_MAX, "Expected 255 but got %u", copy.value.uint8);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateInt16(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT16, "Expected %d but got %d", DATA_TYPE_INT16, copy.type);
	TestCase_assert(copy.value.int16 == 0, "Expected 0 but got %d", copy.value.int16);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateInt16(INT16_MIN);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT16, "Expected %d but got %d", DATA_TYPE_INT16, copy.type);
	TestCase_assert(copy.value.int16 == INT16_MIN, "Expected -32768 but got %d", copy.value.int16);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateUInt16(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT16, "Expected %d but got %d", DATA_TYPE_UINT16, copy.type);
	TestCase_assert(copy.value.uint16 == 0, "Expected 0 but got %u", copy.value.uint16);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateUInt16(UINT16_MAX);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT16, "Expected %d but got %d", DATA_TYPE_UINT16, copy.type);
	TestCase_assert(copy.value.uint16 == UINT16_MAX, "Expected 65535 but got %u", copy.value.uint16);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateInt32(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT32, "Expected %d but got %d", DATA_TYPE_INT32, copy.type);
	TestCase_assert(copy.value.int32 == 0, "Expected 0 but got %d", copy.value.int32);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateInt32(INT32_MIN);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT32, "Expected %d but got %d", DATA_TYPE_INT32, copy.type);
	TestCase_assert(copy.value.int32 == INT32_MIN, "Expected -214783648 but got %d", copy.value.int32);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateUInt32(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT32, "Expected %d but got %d", DATA_TYPE_UINT32, copy.type);
	TestCase_assert(copy.value.uint32 == 0, "Expected 0 but got %u", copy.value.uint32);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateUInt32(UINT32_MAX);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT32, "Expected %d but got %d", DATA_TYPE_UINT32, copy.type);
	TestCase_assert(copy.value.uint32 == UINT32_MAX, "Expected 4294967295 but got %u", copy.value.uint32);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateInt64(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT64, "Expected %d but got %d", DATA_TYPE_INT64, copy.type);
	TestCase_assert(copy.value.int64 == 0, "Expected 0 but got " INT64_FORMAT, copy.value.int64);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateInt64(INT64_MIN);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_INT64, "Expected %d but got %d", DATA_TYPE_INT64, copy.type);
	TestCase_assert(copy.value.int64 == INT64_MIN, "Expected -9223372036854775808 but got " INT64_FORMAT, copy.value.int64);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateUInt64(0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT64, "Expected %d but got %d", DATA_TYPE_UINT64, copy.type);
	TestCase_assert(copy.value.uint64 == 0, "Expected 0 but got " UINT64_FORMAT, copy.value.uint64);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateUInt64(UINT64_MAX);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_UINT64, "Expected %d but got %d", DATA_TYPE_UINT64, copy.type);
	TestCase_assert(copy.value.uint64 == UINT64_MAX, "Expected 18446744073709551615 but got " UINT64_FORMAT, copy.value.uint64);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateFloat(0.0f);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_FLOAT, "Expected %d but got %d", DATA_TYPE_FLOAT, copy.type);
	TestCase_assert(copy.value.float32 == 0.0f, "Expected 0.0 but got %f", copy.value.float32);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateFloat(FLT_MAX);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_FLOAT, "Expected %d but got %d", DATA_TYPE_FLOAT, copy.type);
	TestCase_assert(copy.value.float32 == FLT_MAX, "Expected %f but got %f", FLT_MAX, copy.value.float32);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateDouble(0.0);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_DOUBLE, "Expected %d but got %d", DATA_TYPE_DOUBLE, copy.type);
	TestCase_assert(copy.value.float64 == 0.0, "Expected 0.0 but got %f", copy.value.float64);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateDouble(DBL_MAX);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_DOUBLE, "Expected %d but got %d", DATA_TYPE_DOUBLE, copy.type);
	TestCase_assert(copy.value.float64 == DBL_MAX, "Expected %f but got %f", DBL_MAX, copy.value.float64);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateFixed16_16(0x00000);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_FIXED_16_16, "Expected %d but got %d", DATA_TYPE_FIXED_16_16, copy.type);
	TestCase_assert(copy.value.fixed == 0.0, "Expected 0.0 but got %f", copy.value.fixed);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateFixed16_16(FIXED_16_16_MIN);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_FIXED_16_16, "Expected %d but got %d", DATA_TYPE_FIXED_16_16, copy.type);
	TestCase_assert(copy.value.fixed == FIXED_16_16_MIN, "Expected 0x%05X but got 0x%05X", FIXED_16_16_MIN, copy.value.fixed);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreatePointer(NULL);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_POINTER, "Expected %d but got %d", DATA_TYPE_POINTER, copy.type);
	TestCase_assert(copy.value.pointer == NULL, "Expected NULL but got %p", copy.value.pointer);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreatePointer((void *) 0xFFFFFFFF);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_POINTER, "Expected %d but got %d", DATA_TYPE_POINTER, copy.type);
	TestCase_assert(copy.value.pointer == (void *) 0xFFFFFFFF, "Expected 0xffffffff but got %p", copy.value.pointer);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateString("", DATA_USE_STRLEN, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_STRING, "Expected %d but got %d", DATA_TYPE_STRING, copy.type);
	TestCase_assert(copy.value.string != NULL, "Expected non-NULL but got NULL");
	TestCase_assert(!strcmp(copy.value.string, ""), "Expected \"\" but got \"%s\"", copy.value.string);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateString("abc", DATA_USE_STRLEN, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_STRING, "Expected %d but got %d", DATA_TYPE_STRING, copy.type);
	TestCase_assert(copy.value.string != NULL, "Expected non-NULL but got NULL");
	TestCase_assert(!strcmp(copy.value.string, "abc"), "Expected \"abc\" but got \"%s\"", copy.value.string);
	TestCase_assert(copy.value.string == value.value.string, "Expected %p but got %p", value.value.string, copy.value.string);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateString("abc", DATA_USE_STRLEN, true, true);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_STRING, "Expected %d but got %d", DATA_TYPE_STRING, copy.type);
	TestCase_assert(copy.value.string != NULL, "Expected non-NULL but got NULL");
	TestCase_assert(!strcmp(copy.value.string, "abc"), "Expected \"abc\" but got \"%s\"", copy.value.string);
	TestCase_assert(copy.value.string != value.value.string, "Expected pointers to differ, but both are %p", copy.value.string);
	valueDispose(&value);
	valueDispose(&copy);
	
	value = valueCreateBlob("", 0, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_BLOB, "Expected %d but got %d", DATA_TYPE_BLOB, copy.type);
	TestCase_assert(copy.value.blob.bytes != NULL, "Expected non-NULL but got NULL");
	TestCase_assert(copy.value.blob.length == 0, "Expected 0 but got " SIZE_T_FORMAT, copy.value.blob.length);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateBlob("\x00\xFF", 2, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_BLOB, "Expected %d but got %d", DATA_TYPE_BLOB, copy.type);
	TestCase_assert(copy.value.blob.bytes != NULL, "Expected non-NULL but got NULL");
	TestCase_assert(copy.value.blob.length == 2, "Expected 2 but got " SIZE_T_FORMAT, copy.value.blob.length);
	TestCase_assert(!memcmp(copy.value.blob.bytes, "\x00\xFF", 2), "Expected {0x00, 0xFF} but got {0x%02X, 0x%02X}", ((char *) copy.value.blob.bytes)[0], ((char *) copy.value.blob.bytes)[1]);
	TestCase_assert(copy.value.blob.bytes == value.value.blob.bytes, "Expected %p but got %p", value.value.blob.bytes, copy.value.blob.bytes);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateBlob("\x00\xFF", 2, true, true);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_BLOB, "Expected %d but got %d", DATA_TYPE_BLOB, copy.type);
	TestCase_assert(copy.value.blob.bytes != NULL, "Expected non-NULL but got NULL");
	TestCase_assert(copy.value.blob.length == 2, "Expected 2 but got " SIZE_T_FORMAT, copy.value.blob.length);
	TestCase_assert(!memcmp(copy.value.blob.bytes, "\x00\xFF", 2), "Expected {0x00, 0xFF} but got {0x%02X, 0x%02X}", ((char *) copy.value.blob.bytes)[0], ((char *) copy.value.blob.bytes)[1]);
	TestCase_assert(copy.value.blob.bytes != value.value.blob.bytes, "Expected pointers to differ, but both are %p", copy.value.blob.bytes);
	valueDispose(&value);
	valueDispose(&copy);
	
	hashTable = hashCreate();
	hashSet(hashTable, "a", valueCreateBoolean(false));
	value = valueCreateHashTable(hashTable, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_HASH_TABLE, "Expected %d but got %d", DATA_TYPE_HASH_TABLE, copy.type);
	TestCase_assert(copy.value.hashTable == value.value.hashTable, "Expected %p but got %p", value.value.hashTable, copy.value.hashTable);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateHashTable(hashTable, true, true);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_HASH_TABLE, "Expected %d but got %d", DATA_TYPE_HASH_TABLE, copy.type);
	TestCase_assert(copy.value.hashTable->count == 1, "Expected 1 but got " SIZE_T_FORMAT, copy.value.hashTable->count);
	TestCase_assert(copy.value.hashTable != value.value.hashTable, "Expected pointers to differ, but both are %p", copy.value.hashTable);
	valueDispose(&value);
	valueDispose(&copy);
	hashDispose(hashTable);
	
	array = arrayCreate();
	arrayAppend(array, valueCreateBoolean(false));
	value = valueCreateArray(array, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_ARRAY, "Expected %d but got %d", DATA_TYPE_ARRAY, copy.type);
	TestCase_assert(copy.value.array == value.value.array, "Expected %p but got %p", value.value.array, copy.value.array);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateArray(array, true, true);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_ARRAY, "Expected %d but got %d", DATA_TYPE_ARRAY, copy.type);
	TestCase_assert(copy.value.array->count == 1, "Expected 1 but got " SIZE_T_FORMAT, copy.value.array->count);
	TestCase_assert(copy.value.array != value.value.array, "Expected pointers to differ, but both are %p", copy.value.array);
	valueDispose(&value);
	valueDispose(&copy);
	arrayDispose(array);
	
	assArray = associativeArrayCreate();
	associativeArrayAppend(assArray, "a", valueCreateBoolean(false));
	value = valueCreateAssociativeArray(assArray, false, false);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_ASSOCIATIVE_ARRAY, "Expected %d but got %d", DATA_TYPE_ASSOCIATIVE_ARRAY, copy.type);
	TestCase_assert(copy.value.associativeArray == value.value.associativeArray, "Expected %p but got %p", value.value.associativeArray, copy.value.associativeArray);
	valueDispose(&value);
	valueDispose(&copy);
	value = valueCreateAssociativeArray(assArray, true, true);
	copy = valueCopy(&value);
	TestCase_assert(copy.type == DATA_TYPE_ASSOCIATIVE_ARRAY, "Expected %d but got %d", DATA_TYPE_ASSOCIATIVE_ARRAY, copy.type);
	TestCase_assert(copy.value.associativeArray->count == 1, "Expected 1 but got " SIZE_T_FORMAT, copy.value.associativeArray->count);
	TestCase_assert(copy.value.associativeArray != value.value.associativeArray, "Expected pointers to differ, but both are %p", copy.value.associativeArray);
	valueDispose(&value);
	valueDispose(&copy);
	associativeArrayDispose(assArray);
}
Пример #6
0
void CssmDbAttributeData::add(const CssmPolyData &inValue, Allocator &inAllocator)
{
	Value = reinterpret_cast<CSSM_DATA *>(inAllocator.realloc(Value, sizeof(*Value) * (NumberOfValues + 1)));
	CssmAutoData valueCopy(inAllocator, inValue);
	Value[NumberOfValues++] = valueCopy.release();
}