home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
NextDeveloper
/
Headers
/
dbkit
/
DBQualifier.h
< prev
next >
Wrap
Text File
|
1992-05-05
|
4KB
|
107 lines
/*
** DBQualifier.h
** Database Kit, Release 3.0
** Copyright (c) 1992, NeXT Computer, Inc. All rights reserved.
*/
#import <objc/Object.h>
#import <dbkit/protocols.h>
/*
** Both DBExpression and DBQualifier represent qualifications expressed in
** the underlying query language...they use a printf-style format string,
** in which strings, numbers, and other objects can be embedded by using
** %s, %d, %f, %@, or %p respectively.
**
** As the format string is parsed, each whitespace delimited 'word' that
** begins with an alpha and contains only '.' or alphanumeric characters
** is sought as a named property of the entity -- if a property with a
** matching name is found, it is inserted in place of the string. Example:
**
** aProp = [database propertyNamed:"employee"];
** [[DBExpression alloc] initForEntity:aProperty fromDescription:"mgr.name"];
**
** This expression is the equivalent of asking th$ Itabase for:
**
** [database propertyNamed:"employee.mgr.name"];
**
** Of course, to make things more interesting, multiple properties can be
** combined...
**
** These characters are treated as legal alphanumerics: "._$#"
**
** Here are the legal substitution formats:
**
** %s expects a (const char*) argument, which will be passed through (and
** possibly quoted by the database)
** %p expects a (const char*) argument, which will be resolved against the
** entity for this expression/qualifier as a property name.
** %d expects an (int) argument
** %f expects a (double/float) argument
** %@ expects an (id) argument -- valid objects are DBValue, DBExpression,
** DBQualifier, or anything that conforms with the DBExpressionValues
** protocol
** %% is a '%' passed through...
**
** All of the id arguments are expected to respond to either expressionValue:
** or stringValue.
**
** set1 = [[DBQualifier alloc] initForEntity:employeeEntity
** fromDescription:"%p > %d", "name", aNumber];
** set2 = [[DBQualifier alloc] initForEntity:employeeEntity
** fromDescription:"ID IN (45, 65 78)"
** [[DBQualifier alloc] initForEntity:employeeProp
** fromDescription:"(%@ OR %@) AND %p LIKE 'JONES'",
** set1, set2, "name"];
**
** Objects that respond to the stringValue message can be plugged into both
** DBExpressions and DBQualifiers. Their value will be retrieved whenever
** a query expression is generated -- this can be quite handy for user
** interace considerations, or any kind of "ad-hoc" interface.
**
** Quoting can be handled manually in the description string, or through the
** judicious use of format strings. Expressions and other properties print
** as literals. %s and %' formats will be quoted as character constants,
** according to the rules of the underlying query language.
**
** aProp = [aDatabase propertyNamed:"employee.mgr.dept.name"];
** [[DBQualifier alloc] initForEntity:ent
** fromDescription:"%@ LIKE %s", aProp, aString];
**
** in SQL would produce: WHERE dept.name LIKE 'theStringValue'
*/
@interface DBQualifier : Object <DBExpressionValues>
{
@private
id _nameString;
id _entity;
id _tree;
id _private;
}
+ initialize;
- initF$ Ptity:(id<DBEntities>)anEntity;
- initForEntity:(id<DBEntities>)anEntity
fromDescription:(const unsigned char*)aDescription, ...;
- copyFromZone:(NXZone*)z;
- free;
- empty;
- (BOOL)isEmpty;
- addDescription:(const unsigned char*)aDescription, ...;
- setEntity:(id<DBEntities>)anEntity
andDescription:(const unsigned char*)aDescription, ...;
- (id <DBEntities>)entity;
- (const char*)name;
- (BOOL)setName:(const char*)aName;
- read:(NXTypedStream*)ts;
- write:(NXTypedStream*)ts;
@end