◆ fiftyoneDegreesEvidencePrefix
- @
Introduction
An Evidence structure contains key value pairs to be parsed and processed by an engine.
Items of evidence (e.g. an HTTP header) are added to the structure. The values are then parsed based on the key prefix. In the case of an HTTP header the string would simply be copied, but other types can require further parsing. Evidence items can then be accessed by engines in their parsed form, enabling simpler processing.
Creation
An evidence structure is created using the #fiftyoneDegreesEvidenceCreate method. This takes the maximum number of evidence items which the structure can store.
Prefixes
Evidence keys contain a prefix and the key within that prefix. For example, the key header.user-agent has the prefix header indicating that the second part of the key is an HTTP header name (user-agent).
Prefixes are stored as an enum value with the type of fiftyoneDegreesEvidencePrefix. The enum value of the prefix can be found for a key string by using the #fiftyoneDegreesEvidenceMapPrefix method which takes the key string as an argument, and returns the enum value.
Prefix values are defined by their bit positions such that multiple prefixes can be filtered when iterating with the #fiftyoneDegreesEvidenceIterate method. For example, to iterate over all HTTP headers and all query parameters two prefixes can be used in combination like FIFTYONE_DEGREES_EVIDENCE_HTTP_HEADER_STRING | FIFTYONE_DEGREES_EVIDENCE_QUERY.
Add
An item of evidence is added to the evidence structure using the #fiftyoneDegreesEvidenceAddString method. This then parses the string value it is provided into the correct type which is determined by the prefix.
Iterate
The evidence a particular evidence structure can be iterated over using the #fiftyoneDegreesEvidenceIterate method. This takes a prefix filter (as described in the Prefixes section above), and a callback method which is called for each evidence item which matches the filter. The number of matching items is then returned.
Free
An evidence structure is freed using the #fiftyoneDegreesEvidenceFree method. It is important to note that this method does NOT free the original values which are referenced by the structure.
Usage Example
Evidence prefixes used to determine the category a piece of evidence belongs to. This will determine how the value is parsed.
