ajquery.c
Datatypes: AjPQuery AjPQueryField AjPList AjPStr
Query object
Sections: Query Constructors Query Destructors Query Casts Modifiers Debug exit
All constructors return a new query object by pointer. It
is the responsibility of the user to first destroy any previous
query object. The target pointer does not need to be
initialised to NULL, but it is good programming practice to do so
anyway.
Functions: ajQueryNew
Creates a new query object for a specific datatype from the
AJDATATYPE enumerated types
Synopsis
Prototype
AjPQuery ajQueryNew (
const AjEDataType datatype
);
Type | Name | Read/Write | Description |
const AjEDataType | datatype | Input | Enumerated datatype |
AjPQuery | | RETURN | New query object. |
Input
datatype: | (Input) | Enumerated datatype |
Returns
AjPQuery: | New query object. |
Description
Creates a new query object for a specific datatype from the
AJDATATYPE enumerated types
See Also
See other functions in this section
Availability
In release 6.4.0
Destruction destroys all internal data structures and frees the
memory allocated for the query object.
Functions: ajQueryDel
Deletes a query object
Synopsis
Prototype
void ajQueryDel (
AjPQuery* pthis
);
Type | Name | Read/Write | Description |
AjPQuery* | pthis | Delete | Address of query object |
void | | RETURN | |
Output
pthis: | (Delete) | Address of query object |
Returns
Description
Deletes a query object
See Also
See other functions in this section
Availability
In release 6.4.0
These functions examine the contents of a query object
and return some derived information. Some of them provide access to
the internal components of a query object. They are
provided for programming convenience but should be used with
caution.
Functions: ajQueryGetDatatype ajQueryGetFormat ajQueryGetId ajQueryGetQuery ajQueryGetallFields
Returns the query datatype from a query
Synopsis
Prototype
const char* ajQueryGetDatatype (
const AjPQuery query
);
Type | Name | Read/Write | Description |
const AjPQuery | query | Input | Query |
const char* | | RETURN | Standard name for query datatype |
Input
Returns
const char*: | Standard name for query datatype |
Description
Returns the query datatype from a query
See Also
See other functions in this section
Availability
In release 6.4.0
Returns the format name from a query
Synopsis
Prototype
const AjPStr ajQueryGetFormat (
const AjPQuery query
);
Type | Name | Read/Write | Description |
const AjPQuery | query | Input | Query |
const AjPStr | | RETURN | Format name |
Input
Returns
Description
Returns the format name from a query
See Also
See other functions in this section
Availability
In release 6.4.0
Returns the ID query string from a query
Synopsis
Prototype
const AjPStr ajQueryGetId (
const AjPQuery query
);
Type | Name | Read/Write | Description |
const AjPQuery | query | Input | Query |
const AjPStr | | RETURN | Wildcard ID query string |
Input
Returns
const AjPStr: | Wildcard ID query string |
Description
Returns the ID query string from a query
See Also
See other functions in this section
Availability
In release 6.4.0
Returns a report of the query string from a query
Synopsis
Prototype
AjBool ajQueryGetQuery (
const AjPQuery query,
AjPStr* Pdest
);
Type | Name | Read/Write | Description |
const AjPQuery | query | Input | Query |
AjPStr* | Pdest | Output | Query string |
AjBool | | RETURN | True on success |
Input
Output
Pdest: | (Output) | Query string |
Returns
Description
Returns a report of the query string from a query
See Also
See other functions in this section
Availability
In release 6.4.0
Returns the standard sequence query string from a query
Synopsis
Prototype
const AjPList ajQueryGetallFields (
const AjPQuery query
);
Type | Name | Read/Write | Description |
const AjPQuery | query | Input | Query |
const AjPList | | RETURN | List of field objects |
Input
Returns
const AjPList: | List of field objects |
Description
Returns the standard sequence query string from a query
See Also
See other functions in this section
Availability
In release 6.4.0
Tests whether any element of a query has been set.
Synopsis
Prototype
AjBool ajQueryIsSet (
const AjPQuery thys
);
Type | Name | Read/Write | Description |
const AjPQuery | thys | Input | Query object. |
AjBool | | RETURN | ajTrue if query should be made. ajFalse if the query
includes all entries. |
Input
thys: | (Input) | Query object. |
Returns
AjBool: | ajTrue if query should be made. ajFalse if the query
includes all entries. |
Description
Tests whether any element of a query has been set.
See Also
See other functions in this section
Availability
In release 6.4.0
Checks whether a query field is defined for a database as a "fields:"
string in the database definition.
Synopsis
Prototype
AjBool ajQueryKnownFieldC (
const AjPQuery thys,
const char* fieldtxt
);
Type | Name | Read/Write | Description |
const AjPQuery | thys | Input | Query object |
const char* | fieldtxt | Input | field name |
AjBool | | RETURN | ajTrue if the field is defined |
Input
thys: | (Input) | Query object |
fieldtxt: | (Input) | field name |
Returns
AjBool: | ajTrue if the field is defined |
Description
Checks whether a query field is defined for a database as a "fields:"
string in the database definition.
See Also
See other functions in this section
Availability
In release 6.4.0
Checks whether a query field is defined for a database as a "fields:"
string in the database definition.
Synopsis
Prototype
AjBool ajQueryKnownFieldS (
const AjPQuery thys,
const AjPStr field
);
Type | Name | Read/Write | Description |
const AjPQuery | thys | Input | Query object |
const AjPStr | field | Input | field name |
AjBool | | RETURN | ajTrue if the field is defined |
Input
thys: | (Input) | Query object |
field: | (Input) | field name |
Returns
AjBool: | ajTrue if the field is defined |
Description
Checks whether a query field is defined for a database as a "fields:"
string in the database definition.
See Also
See other functions in this section
Availability
In release 6.4.0
Modify values in a query object
Functions: ajQueryAddFieldAndC ajQueryAddFieldAndS ajQueryAddFieldElseC ajQueryAddFieldElseS ajQueryAddFieldEorC ajQueryAddFieldEorS ajQueryAddFieldNotC ajQueryAddFieldNotS ajQueryAddFieldOrC ajQueryAddFieldOrS ajQueryClear ajQuerySetWild ajQueryStarclear
Adds a query with an 'AND' operator
Synopsis
Prototype
AjBool ajQueryAddFieldAndC (
AjPQuery thys,
const char* fieldtxt,
const char* wildquerytxt
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const char* | fieldtxt | Input | field name |
const char* | wildquerytxt | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
fieldtxt: | (Input) | field name |
wildquerytxt: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'AND' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'AND' operator
Synopsis
Prototype
AjBool ajQueryAddFieldAndS (
AjPQuery thys,
const AjPStr field,
const AjPStr wildquery
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const AjPStr | field | Input | field name |
const AjPStr | wildquery | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
field: | (Input) | field name |
wildquery: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'AND' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'ELSE' operator
Synopsis
Prototype
AjBool ajQueryAddFieldElseC (
AjPQuery thys,
const char* fieldtxt,
const char* wildquerytxt
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const char* | fieldtxt | Input | field name |
const char* | wildquerytxt | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
fieldtxt: | (Input) | field name |
wildquerytxt: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'ELSE' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'ELSE' operator
Synopsis
Prototype
AjBool ajQueryAddFieldElseS (
AjPQuery thys,
const AjPStr field,
const AjPStr wildquery
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const AjPStr | field | Input | field name |
const AjPStr | wildquery | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
field: | (Input) | field name |
wildquery: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'ELSE' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'EOR' operator
Synopsis
Prototype
AjBool ajQueryAddFieldEorC (
AjPQuery thys,
const char* fieldtxt,
const char* wildquerytxt
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const char* | fieldtxt | Input | field name |
const char* | wildquerytxt | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
fieldtxt: | (Input) | field name |
wildquerytxt: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'EOR' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'EOR' operator
Synopsis
Prototype
AjBool ajQueryAddFieldEorS (
AjPQuery thys,
const AjPStr field,
const AjPStr wildquery
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const AjPStr | field | Input | field name |
const AjPStr | wildquery | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
field: | (Input) | field name |
wildquery: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'EOR' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with a 'NOT' operator
Synopsis
Prototype
AjBool ajQueryAddFieldNotC (
AjPQuery thys,
const char* fieldtxt,
const char* wildquerytxt
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const char* | fieldtxt | Input | field name |
const char* | wildquerytxt | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
fieldtxt: | (Input) | field name |
wildquerytxt: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with a 'NOT' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with a 'NOT' operator
Synopsis
Prototype
AjBool ajQueryAddFieldNotS (
AjPQuery thys,
const AjPStr field,
const AjPStr wildquery
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const AjPStr | field | Input | field name |
const AjPStr | wildquery | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
field: | (Input) | field name |
wildquery: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with a 'NOT' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'OR' operator
Synopsis
Prototype
AjBool ajQueryAddFieldOrC (
AjPQuery thys,
const char* fieldtxt,
const char* wildquerytxt
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const char* | fieldtxt | Input | field name |
const char* | wildquerytxt | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
fieldtxt: | (Input) | field name |
wildquerytxt: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'OR' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Adds a query with an 'OR' operator
Synopsis
Prototype
AjBool ajQueryAddFieldOrS (
AjPQuery thys,
const AjPStr field,
const AjPStr wildquery
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object |
const AjPStr | field | Input | field name |
const AjPStr | wildquery | Input | wildcard query string |
AjBool | | RETURN | ajTrue on success |
Input
field: | (Input) | field name |
wildquery: | (Input) | wildcard query string |
Input & Output
thys: | (Modify) | Query object |
Returns
Description
Adds a query with an 'OR' operator
See Also
See other functions in this section
Availability
In release 6.4.0
Resets a query object to a clean state for reuse.
Keep the begin, end and reverse values.
Synopsis
Prototype
void ajQueryClear (
AjPQuery thys
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | query object |
void | | RETURN | |
Input & Output
thys: | (Modify) | query object |
Returns
Description
Resets a query object to a clean state for reuse.
Keep the begin, end and reverse values.
See Also
See other functions in this section
Availability
In release 6.4.0
Tests whether a query includes wild cards in any element,
or can return more than one entry (keyword and some other search terms
will find multiple entries)
Synopsis
Prototype
AjBool ajQuerySetWild (
AjPQuery thys
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object. |
AjBool | | RETURN | ajTrue if query had wild cards. |
Input & Output
thys: | (Modify) | Query object. |
Returns
AjBool: | ajTrue if query had wild cards. |
Description
Tests whether a query includes wild cards in any element,
or can return more than one entry (keyword and some other search terms
will find multiple entries)
See Also
See other functions in this section
Availability
In release 6.4.0
Clears elements of a query object if they are simply "*" because this
is equivalent to a null string.
Synopsis
Prototype
void ajQueryStarclear (
AjPQuery thys
);
Type | Name | Read/Write | Description |
AjPQuery | thys | Modify | Query object. |
void | | RETURN | |
Input & Output
thys: | (Modify) | Query object. |
Returns
Description
Clears elements of a query object if they are simply "*" because this
is equivalent to a null string.
See Also
See other functions in this section
Availability
In release 6.4.0
Reports sequence contents for debugging purposes
Functions: ajQueryTrace
Debug calls to trace the data in a query object.
Synopsis
Prototype
void ajQueryTrace (
const AjPQuery thys
);
Type | Name | Read/Write | Description |
const AjPQuery | thys | Input | query object. |
void | | RETURN | |
Input
thys: | (Input) | query object. |
Returns
Description
Debug calls to trace the data in a query object.
See Also
See other functions in this section
Availability
In release 6.4.0
Functions called on exit from the program by ajExit to do
any necessary cleanup and to report internal statistics to the debug file
Functions: ajQueryExit
Cleans up query processing internal memory
Synopsis
Prototype
void ajQueryExit (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
Cleans up query processing internal memory
See Also
See other functions in this section
Availability
In release 6.4.0
Query fields
Sections: constructors Query Field Destructors
Constructors
Functions: ajQueryfieldNewC ajQueryfieldNewS
Constructor for a query field
Synopsis
Prototype
AjPQueryField ajQueryfieldNewC (
const char* fieldtxt,
const char* wildtxt,
AjEQryLink oper
);
Type | Name | Read/Write | Description |
const char* | fieldtxt | Input | Field name |
const char* | wildtxt | Input | Wildcard query string |
AjEQryLink | oper | Input | Operator |
AjPQueryField | | RETURN | Query field |
Input
fieldtxt: | (Input) | Field name |
wildtxt: | (Input) | Wildcard query string |
oper: | (Input) | Operator |
Returns
AjPQueryField: | Query field |
Description
Constructor for a query field
See Also
See other functions in this section
Availability
In release 6.4.0
Constructor for a query field
Synopsis
Prototype
AjPQueryField ajQueryfieldNewS (
const AjPStr field,
const AjPStr wild,
AjEQryLink oper
);
Type | Name | Read/Write | Description |
const AjPStr | field | Input | Field name |
const AjPStr | wild | Input | Wildcard query string |
AjEQryLink | oper | Input | Operator |
AjPQueryField | | RETURN | Query field |
Input
field: | (Input) | Field name |
wild: | (Input) | Wildcard query string |
oper: | (Input) | Operator |
Returns
AjPQueryField: | Query field |
Description
Constructor for a query field
See Also
See other functions in this section
Availability
In release 6.4.0
Destruction destroys all internal data structures and frees the
memory allocated for the query field object.
Functions: ajQueryfieldDel
Destructor for a query field
Synopsis
Prototype
void ajQueryfieldDel (
AjPQueryField* Pthis
);
Type | Name | Read/Write | Description |
AjPQueryField* | Pthis | Delete | Query field object to be deleted |
void | | RETURN | |
Output
Pthis: | (Delete) | Query field object to be deleted |
Returns
Description
Destructor for a query field
See Also
See other functions in this section
Availability
In release 6.4.0
Query field list
Sections: Debug
Reports sequence contents for debugging purposes
Functions: ajQuerylistTrace
Traces the nodes in a query list
Synopsis
Prototype
void ajQuerylistTrace (
const AjPList list
);
Type | Name | Read/Write | Description |
const AjPList | list | Input | The query list |
void | | RETURN | |
Input
list: | (Input) | The query list |
Returns
Description
Traces the nodes in a query list
See Also
See other functions in this section
Availability
In release 6.4.0
Query string
Sections: Query string parsing
Parses a query string and removes the processed string trokens
Functions: ajQuerystrParseFormat ajQuerystrParseListfile ajQuerystrParseRange ajQuerystrParseRead
Parses a query (USA, UFO or general query).
Then tests for "format::" and returns this if it is found,
removing the format part of the original query.
Synopsis
Prototype
const AjPStr ajQuerystrParseFormat (
AjPStr* Pqry,
AjPTextin textin,
AjBool function findformat
);
Type | Name | Read/Write | Description |
AjPStr* | Pqry | Modify | Query string |
AjPTextin | textin | Modify | Text input object |
AjBool function | findformat | Function | Function to validate format name |
const AjPStr | | RETURN | Format name if found |
Input
findformat: | (Function) | Function to validate format name |
Input & Output
Pqry: | (Modify) | Query string |
textin: | (Modify) | Text input object |
Returns
const AjPStr: | Format name if found |
Description
Parses a query (USA, UFO or general query).
Then tests for "format::" and returns this if it is found,
removing the format part of the original query.
See Also
See other functions in this section
Availability
In release 6.4.0
Parses a query (USA, UFO or general query).
Then tests for "list::" or "
Synopsis
Prototype
AjBool ajQuerystrParseListfile (
AjPStr* Pqry
);
Type | Name | Read/Write | Description |
AjPStr* | Pqry | Modify | Query string |
AjBool | | RETURN | True if found |
Input & Output
Pqry: | (Modify) | Query string |
Returns
Description
Parses a query (USA, UFO or general query).
Then tests for "list::" or "
See Also
See other functions in this section
Availability
In release 6.4.0
Parses a query (USA, UFO or general query).
Tests for "[n:n:r]" range and sets this if it is found,
removing the range part of the original query.
Synopsis
Prototype
AjBool ajQuerystrParseRange (
AjPStr* Pqry,
ajint* Pbegin,
ajint* Pend,
AjBool* Prev
);
Type | Name | Read/Write | Description |
AjPStr* | Pqry | Modify | Query string |
ajint* | Pbegin | Modify | Begin position |
ajint* | Pend | Modify | End position |
AjBool* | Prev | Modify | Reverse orientation |
AjBool | | RETURN | True if range was found. |
Input & Output
Pqry: | (Modify) | Query string |
Pbegin: | (Modify) | Begin position |
Pend: | (Modify) | End position |
Prev: | (Modify) | Reverse orientation |
Returns
AjBool: | True if range was found. |
Description
Parses a query (USA, UFO or general query).
Tests for "[n:n:r]" range and sets this if it is found,
removing the range part of the original query.
See Also
See other functions in this section
Availability
In release 6.4.0
Parses a query (USA, UFO or general query).
First tests for "asis" input and sets the rest of the query as input data.
Then tests for server:dbname:query or dbname:query
and tests whether the access method is a text method.
For text access, calls the access method to opens the file
(and set the file position).
If there is no database, looks for file:query and opens the file.
If an offset is provided as %offset sets the file position
If the file does now exist, tests again for a database of that name
from any known server.
If no text data was found, returns the filled in datatype-specific details
Synopsis
Prototype
AjBool ajQuerystrParseRead (
AjPStr* Pqry,
AjPTextin textin,
AjBool function findformat,
AjBool* Pnontext
);
Type | Name | Read/Write | Description |
AjPStr* | Pqry | Modify | Query string |
AjPTextin | textin | Modify | Text input structure. |
AjBool function | findformat | Function | Function to validate format name |
AjBool* | Pnontext | Output | True if access is a non-text method |
AjBool | | RETURN | ajTrue on success. |
Input
findformat: | (Function) | Function to validate format name |
Output
Pnontext: | (Output) | True if access is a non-text method |
Input & Output
Pqry: | (Modify) | Query string |
textin: | (Modify) | Text input structure. |
Returns
AjBool: | ajTrue on success. |
Description
Parses a query (USA, UFO or general query).
First tests for "asis" input and sets the rest of the query as input data.
Then tests for server:dbname:query or dbname:query
and tests whether the access method is a text method.
For text access, calls the access method to opens the file
(and set the file position).
If there is no database, looks for file:query and opens the file.
If an offset is provided as %offset sets the file position
If the file does now exist, tests again for a database of that name
from any known server.
If no text data was found, returns the filled in datatype-specific details
See Also
See other functions in this section
Availability
In release 6.4.0