Exemple #1
0
// Get an EXTfldval for a defined constant
void OmnisTools::getEXTFldValFromConstant(EXTfldval& fVal, qlong constID, qlong prefixID) {
    
	// Check for prefix
	str80 prefixRead;
	str255 constantValue;
	if (prefixID > 0) {
		// Read string from resource, and assign it to return parameter
		RESloadString(gInstLib,prefixID,prefixRead);
		constantValue.concat(prefixRead);
	}
    
	// Read complete resource string
	str255 resourceValue;
	RESloadString(gInstLib,constID,resourceValue);
	
	// Translate into std::wstring for easy substring
	EXTfldval convVar;
	convVar.setChar(resourceValue, dpDefault);
	std::wstring resourceString = getWStringFromEXTFldVal(convVar);
	
	// Get substring between tilde (sometimes used for categories) and first colon.
	int tildePos = resourceString.find(L"~") + 1;
	int colonPos = resourceString.find(L":");
	
	std::wstring constantString = resourceString.substr(tildePos,colonPos-tildePos);
	getEXTFldValFromWString(convVar, constantString);
	
	// Add constant to EXTfldval
	constantValue.concat(convVar.getChar());
	fVal.setConstant(constantValue);
}
Exemple #2
0
void JsonValue::propertyValueType(EXTfldval &retVal) {
    switch (jsonValue->type()) {
    case Json::nullValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 0);
        break;
    case Json::intValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 1);
        break;
    case Json::uintValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 2);
        break;
    case Json::realValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 3);
        break;
    case Json::stringValue:
        // String can be a string or a date
        switch( isISO8601Date(jsonValue ->asString())) {
        case kISODateTime:
            retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 8);
            break;
        case kISODate:
            retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 9);
            break;
        case kISOTime:
            retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 10);
            break;
        default:
            retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 4);
            break;
        }

        break;
    case Json::booleanValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 5);
        break;
    case Json::arrayValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 6);
        break;
    case Json::objectValue:
        retVal.setConstant(kConstValueTypeStart, kConstValueTypeEnd, 7);
        break;
    default:
        break;
    }
}