Reprogramming the Within Operator

NOTE: The mechanism described here may be replaced with something different in a future version of the Metamorph API.

The symbolic expressions that the within operator knows about may be reprogrammed by the application developer. The within processor maintains two lists of symbolic expressions: a "standard" list and a "user" list. By default the standard list contains the symbols described elsewhere in this document (line/page/etc). The user list is empty by default.

The within processor processes the string after the "w/" in the following order:

  • If the first character is a digit its a proximity count.

  • If it matches something in the user list, use its expression.

  • If it matches something in the standard list, use its expression.

  • Otherwise it's taken literally as a rex expression.

Each list is made up of an array of MDPDLM structures

MDPDLM {
   char *name;
   char *expr;
   int   incsd;
   int   inced;
};

Where:

name is the name used in the query with the "w/" operator. expr is the rex expression associated with name. incsd is a flag indicating whether to include the start delimiter. inced is a flag indicating whether to include the end delimiter.

The array is terminated with a MDPDLM with the name member set to (char *)NULL.

The lists are manipulated with the mdpstd() and mdpusr() functions to control the standard and user lists respectively.

MDPDLM *mdpstd(MDPDLM *);
MDPDLM *mdpusr(MDPDLM *);

These functions set their respective lists to those provided by the argument. They return the previous lists. Any list may be MDPDLMPN to suppress its processing. The list pointers are kept in a static global variable within the api library, so all subsequent within operators will be effected by any changes. The table is not copied, so the pointers passed must remain valid for the duration of all api usage.

Comparisons to name need only match for the length of name, thus allowing abbreviations. e.g. The following will both match for a name of "mess": w/message, w/messy.


EXAMPLE

static MDPDLM mydelims[]={
   { "mess","^From:"         ,1,0 },           /* add a new name */
   { "page","-- \\digit+ --:",0,1 },/* override an existing name */
   { CHARPN }
};
   ...
   /*
      you could call
         mdpstd(MDPDLMPN);
      to suppress the standard names so that only the usr names
      would be recognized.
   */
   mdpusr(mydelims);
   ...
   setmmapi(mm,query);
   ...


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.