/** * Returns a string representation of the value associated with the required * property index. If the index is not valid an empty string is returned. If * the property relates to a list with more than one value then values are * seperated by | characters. * @param requiredPropertyIndex of the property required * @returns a string representation of the value for the property */ string Match::getValue(int requiredPropertyIndex) { string result; const fiftyoneDegreesAsciiString* valueName; if (requiredPropertyIndex >= 0 && fiftyoneDegreesSetValues(ws, requiredPropertyIndex) > 0) { valueName = fiftyoneDegreesGetString( ws->dataSet, ws->values[0]->nameOffset); result.assign(&(valueName->firstByte)); } return result; }
/** * Returns a vector with all values associated with the required property * index. If the index is not valid an empty vector is returned. * @param requiredPropertyIndex of the property required * @returns a vector of values for the property */ vector<string> Match::getValues(int requiredPropertyIndex) { vector<string> result; const fiftyoneDegreesAsciiString* valueName; if (requiredPropertyIndex >= 0 && fiftyoneDegreesSetValues(ws, requiredPropertyIndex) > 0) { for (int valueIndex = 0; valueIndex < ws->valuesCount; valueIndex++) { valueName = fiftyoneDegreesGetString( ws->dataSet, ws->values[valueIndex]->nameOffset); result.insert(result.end(), string(&(valueName->firstByte))); } } return result; }
/** * Returns the hash code for the values of properties contained in the work * set. * @param ws work set containing the results of a match */ static unsigned long getHashCode(fiftyoneDegreesWorkset *ws) { unsigned long hashCode = 0; int32_t requiredPropertyIndex; const fiftyoneDegreesAsciiString *valueName; for (requiredPropertyIndex = 0; requiredPropertyIndex < ws->dataSet->requiredPropertyCount; requiredPropertyIndex++) { fiftyoneDegreesSetValues(ws, requiredPropertyIndex); valueName = fiftyoneDegreesGetString( ws->dataSet, ws->values[0]->nameOffset); hashCode ^= hash((unsigned char*)&(valueName->firstByte)); } return hashCode; }
/** * Returns a string representation of the value associated with the required * property name. If the property name is not valid an empty string is * returned.If the property relates to a list with more than one value then * values are separated by | characters. * @param propertyName pointer to a string containing the property name * @returns a string representation of the value for the property */ const char* getValue(fiftyoneDegreesWorkset* ws, char* propertyName) { int requiredPropertyIndex; const char* result; const fiftyoneDegreesAsciiString* valueName; requiredPropertyIndex = fiftyoneDegreesGetRequiredPropertyIndex(ws->dataSet, propertyName); if (requiredPropertyIndex != -1) { fiftyoneDegreesSetValues(ws, requiredPropertyIndex); valueName = fiftyoneDegreesGetString(ws->dataSet, ws->values[0]->nameOffset); result = &(valueName->firstByte); return result; } else { return ""; } }