DIRECTORY Rope USING [ROPE], IO USING [STREAM]; Customize: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; AnyString: TYPE = REF; --Either ROPE, REF TEXT, or, ATOM DBreadonly: TYPE = REF READONLY DBRec; DB: TYPE = REF DBRec; DBRec: PRIVATE TYPE; CreateDB: PROC [] RETURNS [DB]; UpdateDB: PROC [db: DB, stream: IO.STREAM] RETURNS [errors: ROPE]; UpdateDBString: PROC [db: DB, string: AnyString] RETURNS [errors: ROPE]; UpdateDBExplicite: PROC [db: DB, key: AnyString, value: REF] RETURNS [errors: ROPE]; UpdateDBFromFile: PROC [file: REF, inputDb: DB ¬ NIL] RETURNS [db: DB, errors: ROPE]; DoQuery: PROC [db: DBreadonly, query: Query] RETURNS [REF]; DoQueryString: PROC [db: DBreadonly, string: AnyString ¬ NIL] RETURNS [REF]; Query: TYPE = REF QueryRep; QueryRep: TYPE; QueryState: PROC [query: Query] RETURNS [state: NAT]; NewQuery: PROC [reserve: NAT ¬ 16, useMemory: Query ¬ NIL] RETURNS [Query]; ResetQuery: PROC [query: Query, state: NAT ¬ 0]; CopyQuery: PROC [query: Query, reserve: NAT ¬ 0] RETURNS [Query]; AppendStepOnly: PROC [query: Query] RETURNS [Query]; AppendOptionOnly: PROC [query: Query, option: AnyString ¬ NIL] RETURNS [Query]; AppendStep: PROC [query: Query, val1, val2: AnyString ¬ NIL] RETURNS [Query]; FreeQuery: PRIVATE PROC [query: Query]; ParseQuery: PROC [string: AnyString ¬ NIL] RETURNS [Query]; QueryError: ERROR [what: ROPE]; END. ξ Customize.mesa Copyright Σ 1989, 1991 by Xerox Corporation. All rights reserved. Goran Rydqvist and Christian Jacobi, July 24, 1989 9:20:33 pm PDT Christian Jacobi, October 13, 1989 12:09:22 pm PDT This interface defines a database manager, including queries. It serves similar purposes as a user profile, however there is more expressive power and no restriction to a single file. The data base file syntax and query precedence rules are a superset of the X-Window standard for resource files. Programming hints Errors: Four classes of errors are distinguished. 1) A database might have a syntax error. This is considered an user error; Customize tries to continue and returns just an error message to its caller. 2) A query might be malformed. This is a client error which causes an error to be raised. 3) A returned value might have an unexpected form. This is a user error, and the client application has to deal with that; Customize doesn't notice. 4) A type converter might raise an error. This is considered a client error. It is assumed that the conversion goal type sufficiently restrict type converters to the ones desired by the client application. Multi-programming: The obvious care is recommended. 1) Constructing the same query, or, updating the same database from different threads is an error. 2) Querying a database while updating it might cause the query to miss an entry. The database itself is not affected. 3) Multiple queries on the same database need not be monitored. 4) Changing the query data while a query is in progress may cause the query to fail, but it will not affect the database. Do not use the same query concurrently on different databases. Database creation The database representation. Creates new, empty DB. Parse and merge database entries into . If a specification is identical to one that already exists, the later one takes precedence. Parse and and merge database entries into . Parse and add as database entry into . Database values may be overwriten, but, they can't be removed. Conveniance procedure: is updated and returned again. a STREAM or a string (string is interpreted as a file name). Not found files are reported like syntax errors in the data base. Querying Query the database with . Conveniance procedure. Query the database strings. Query construction Even doing queries might have side effects on QueryRep. Returns of query in construction. Meaning of numerical value is private. Creates new empty query. Query does not yet have any steps or options. : allocates enough memory for about steps or options. Resets state of query to . =0 means reset to empty. Creates new copy which does not share memory with query. is a guess: allocates enough memory to append about more steps or options. Appends step to ; The new step has no options yet. Returns or new query if new memory allocation needed. Append query option to the current step of . must not be empty. Returns or new query if new memory allocation needed. Conveniance proc Appends step to ; Also appends up to two options to new step. Returns or new query if new memory allocation needed. Returns query for re-use. Caller asserts that he won't modify query anymore. It is ok to not worry but leave query's to the garbage collector. Parses into a query. May raise error QueryError. Κ‡–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ Οeœ7™BKšœ>Οk™AKšœ2™2K™KšœΉ™ΉKšœr™rK™—šž ˜ Kšœžœžœ˜Kšžœžœžœ˜—K˜šΡaln œžœž œž˜$K˜Kšžœžœžœ˜šœ žœžœΟc!˜8K˜——K˜šΡael™K™šΟbœ+™1Jšœ@’œW™›Jšœ*’œ*™ZJšœ>’œT™–JšœΟ™ΟJ™—š’œ"™3Jšœd™dJšœx™xJšœA™AJšœΉ™ΉJ™——K™š‘™K˜Kšœ žœžœžœ˜&šžœžœžœ˜Kšœ™Kšœžœž˜—K˜šΟnœžœžœžœ˜K™K˜—š£œžœžœ žœžœžœ žœ˜BKšœ’™’K™—š £œžœžœžœ žœ˜HKšœ:™:K™—š £œžœžœžœžœ žœ˜TKšœ:™:Kšœ@™@K™—š£œžœžœ žœžœžœžœ žœ˜UKšœJžœw™ΗK˜——K˜š‘™K˜š£œžœ žœžœ˜;Kšœ&™&K˜—š £ œžœ&žœžœžœ˜LKšœ™Kšœ ™ K˜——K˜š‘™K˜šœžœžœ ˜Kšœ žœ˜Kšœ:™:K˜—š£ œžœžœ žœ˜5KšœS™SK˜—š £œžœ žœžœžœ ˜KKšœG™GKšœH™HK˜—š£ œžœžœ˜0KšœA™AK˜—š£ œžœžœžœ ˜AKšœ9™9Kšœ^™^K™—š£œžœžœ ˜4Kšœ9™9Kšœ=™=K™—š£œžœ$žœžœ ˜OKšœ4™4Kšœ™Kšœ=™=K™—š£ œžœ(žœžœ ˜MKšœ™KšœD™DKšœ=™=K™—š£ œžœžœ˜'KšœM™MKšœA™AK˜—š£ œžœžœžœ ˜;Kšœ™Kšœ™Kš£ œžœžœ˜K˜——K™šžœ˜K˜K˜——…—lα