WPDirectoryImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Doug Terry, July 13, 1987 5:51:12 pm PDT
Whitepage database facilities.
DIRECTORY
WPDirectory;
WPDirectoryImpl: CEDAR PROGRAM
IMPORTS Rope, FinchSmarts, FinchTool, IO, MBQueue, NodeProps, TiogaButtons, TiogaOps, ViewerTools, VoiceUtils
EXPORTS WPDirectory = {
ROPE: TYPE ~ Rope.ROPE;
Entry: TYPE ~ WPDirectory.Entry;
Cursor: TYPE ~ WPDirectory.ComplexCursor;
AttributePatterns: TYPE ~ WPDirectory.AttributePatterns;
Ad-hoc query parsing
Query syntax:
<attribute>(<filter>): <value> ... { at { home | office } } { in <dbname> }
Defaults:
a missing <attribute> is taken to be:
"officenumber" if <value> starts with a digit and "at home" is not specified,
"homenumber" if <value> starts with a digit and "at home" is specified,
"rname" if <value> does not start with a digit but contains a ".",
"name" if <value> does not start with a digit and contains no ".".
a missing <filter> is taken to be:
"SimpleDWIM" (without subrange or date parsing).
a missing <dbname> is taken to be:
all standard databases.
Notes:
if "officenumber" is selected as a default and produces no results, then "homenumber" should be tried.
Whitepage query execution
Operations on entries
tName: LoganBerry.AttributeType = $name;
tRname: LoganBerry.AttributeType = $rname;
tOffice: LoganBerry.AttributeType = $officenumber;
tHome: LoganBerry.AttributeType = $homenumber;
tRemarks: LoganBerry.AttributeType = $remarks;
GetName: PUBLIC PROC [entry: Entry] RETURNS [ROPE] ~ {
RETURN[GetAttributeValue[entry, tName]];
};
GetRName: PUBLIC PROC [entry: Entry] RETURNS [ROPE] ~ {
RETURN[GetAttributeValue[entry, tRname]];
};
GetHomePhone: PUBLIC PROC [entry: Entry] RETURNS [ROPE] ~ {
RETURN[GetAttributeValue[entry, tHome]];
};
GetOfficePhone: PUBLIC PROC [entry: Entry] RETURNS [ROPE] ~ {
RETURN[GetAttributeValue[entry, tOffice]];
};
GetRemarks: PUBLIC PROC [entry: Entry] RETURNS [ROPE] ~ {
RETURN[GetAttributeValue[entry, tRemarks]];
};
GetAttributeValue: PROC [entry: LoganBerry.Entry, type: LoganBerry.AttributeType] RETURNS [LoganBerry.AttributeValue] ~ {
FOR e: LoganBerry.Entry ← entry, e.rest WHILE e # NIL DO
IF e.first.type = type THEN
RETURN[e.first.value];
ENDLOOP;
RETURN[NIL];
};
}.