Btrieve 2
|
The Btrieve collection class. More...
#include <btrieveCpp.h>
Public Member Functions | |
BtrieveCollection () | |
~BtrieveCollection () | |
Btrieve::StatusCode | Decrypt () |
Decrypt a collection. | |
int | DocumentCreate (const char *json) |
Create a document. | |
int | DocumentCreate (const char *json, const char *blob, int blobLength) |
Create a document. | |
Btrieve::StatusCode | DocumentDelete (int id, int entityTag=-1) |
Delete a document. | |
Btrieve::StatusCode | DocumentRetrieve (int id, char *json=NULL, int jsonSize=0, char *blob=NULL, int blobSize=0, int documentBlobOffset=0, int documentBlobLength=0) |
Retrieve a document. | |
Btrieve::StatusCode | DocumentRetrieveBlob (int id, char *blob, int blobSize, int documentBlobOffset=0, int documentBlobLength=0) |
Retrieve a document blob. | |
int | DocumentRetrieveEntityTag (int id) |
Retrieve a document entity tag. | |
const char * | DocumentRetrieveJson (int id) |
Retrieve a document json. | |
const char * | DocumentRetrieveJson (int id, char *blob, int blobSize, int documentBlobOffset=0, int documentBlobLength=0) |
Retrieve a document json. | |
Btrieve::StatusCode | DocumentUpdate (int id, const char *json) |
Update a document. | |
Btrieve::StatusCode | DocumentUpdate (int id, const char *json, const char *blob, int blobLength) |
Update a document. | |
Btrieve::StatusCode | DocumentUpdate (int id, int entityTag, const char *json) |
Update a document. | |
Btrieve::StatusCode | DocumentUpdate (int id, int entityTag, const char *json, const char *blob, int blobLength) |
Update a document. | |
Btrieve::StatusCode | Encrypt (const char *password, const char *passwordAgain) |
Encrypt a collection. | |
Btrieve::StatusCode | GetLastStatusCode () |
Get the last status code. | |
Btrieve::StatusCode | Query (BtrieveDocumentSet *btrieveDocumentSet, const char *query=NULL) |
Query the collection. | |
The Btrieve collection class.
A Btrieve collection consists of zero or more documents. Each document consists of a label, JSON and an optional BLOB. The maximum label length is Btrieve::MAXIMUM_KEY_LENGTH bytes, including the terminating NULL byte. The maximum JSON length is Btrieve::MAXIMUM_RECORD_LENGTH bytes. The maximum BLOB length is 2147483647 bytes (2 GiB - 1).
JSON field names which begin with "_" or "$" are reserved. The following reserved JSON field names are currently defined:
Field Name | User Settable | System Generated | Indexed | Duplicates Allowed | Type | Description |
---|---|---|---|---|---|---|
_blobLength | no | yes | yes | yes | number | The document blob length. |
_createTime | no | yes | yes | yes | number | The document create time in microseconds since the Unix Epoch. |
_id | no | yes | yes | no | number | The document identifier. |
_jsonLength | no | yes | yes | yes | number | The document json length. |
_label | yes | no | yes | yes | string | The document label. |
_updateTime | no | yes | yes | yes | number | The document update time in microseconds since the Unix Epoch. |
Non-user settable JSON field names are silently ignored by BtrieveCollection::DocumentCreate and BtrieveCollection::DocumentUpdate. Use of reserved JSON field names other than those listed above will generate an error. Reserved JSON field names are added to the document JSON retrieved by BtrieveCollection::DocumentRetrieveJson and BtrieveCollection::DocumentRetrieve.
The document identifier is an autoincrement positive integer with a maximum value of 2147483647 (2^31 - 1).
BtrieveCollection::BtrieveCollection | ( | ) |
BtrieveCollection::~BtrieveCollection | ( | ) |
Btrieve::StatusCode BtrieveCollection::Decrypt | ( | ) |
Decrypt a collection.
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
int BtrieveCollection::DocumentCreate | ( | const char * | json | ) |
Create a document.
[in] | json | The json. |
>= 0 | The document identifier. |
-1 | An error has occurred. Use BtrieveCollection::GetLastStatusCode to determine the Btrieve::StatusCode associated with any error. |
int BtrieveCollection::DocumentCreate | ( | const char * | json, |
const char * | blob, | ||
int | blobLength ) |
Create a document.
[in] | json | The json. |
[in] | blob | The blob. |
[in] | blobLength | The blob length. If blob is NULL, then blobLength must be 0. |
>= 0 | The document identifier. |
-1 | An error has occurred. Use BtrieveCollection::GetLastStatusCode to determine the Btrieve::StatusCode associated with any error. |
Btrieve::StatusCode BtrieveCollection::DocumentDelete | ( | int | id, |
int | entityTag = -1 ) |
Delete a document.
[in] | id | The identifier. |
[in] | entityTag | The entity tag. The entity tag must either equal the entity tag of the document or -1. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::DocumentRetrieve | ( | int | id, |
char * | json = NULL, | ||
int | jsonSize = 0, | ||
char * | blob = NULL, | ||
int | blobSize = 0, | ||
int | documentBlobOffset = 0, | ||
int | documentBlobLength = 0 ) |
Retrieve a document.
[in] | id | The identifier. |
[out] | json | The json. |
[in] | jsonSize | The json size. |
[out] | blob | The blob. |
[in] | blobSize | The blob size. |
[in] | documentBlobOffset | The document blob offset. |
[in] | documentBlobLength | The document blob length. If document blob length is 0, then the entire document blob will be retrieved beginning at document blob offset. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::DocumentRetrieveBlob | ( | int | id, |
char * | blob, | ||
int | blobSize, | ||
int | documentBlobOffset = 0, | ||
int | documentBlobLength = 0 ) |
Retrieve a document blob.
[in] | id | The identifier. |
[out] | blob | The blob. |
[in] | blobSize | The blob size. |
[in] | documentBlobOffset | The document blob offset. |
[in] | documentBlobLength | The document blob length. If document blob length is 0, then the entire document blob will be retrieved beginning at document blob offset. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
int BtrieveCollection::DocumentRetrieveEntityTag | ( | int | id | ) |
Retrieve a document entity tag.
[in] | id | The identifier. |
>= 0 | The document entity tag. |
-1 | An error has occurred. Use BtrieveCollection::GetLastStatusCode to determine the Btrieve::StatusCode associated with any error. |
const char * BtrieveCollection::DocumentRetrieveJson | ( | int | id | ) |
Retrieve a document json.
[in] | id | The identifier. |
!= NULL | The json. |
NULL | An error has occurred. |
const char * BtrieveCollection::DocumentRetrieveJson | ( | int | id, |
char * | blob, | ||
int | blobSize, | ||
int | documentBlobOffset = 0, | ||
int | documentBlobLength = 0 ) |
Retrieve a document json.
[in] | id | The identifier. |
[out] | blob | The blob. |
[in] | blobSize | The blob size. |
[in] | documentBlobOffset | The document blob offset. |
[in] | documentBlobLength | The document blob length. If document blob length is 0, then the entire document blob will be retrieved beginning at document blob offset. |
!= NULL | The json. |
NULL | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::DocumentUpdate | ( | int | id, |
const char * | json ) |
Update a document.
[in] | id | The identifier. |
[in] | json | The json. If json is NULL, then the document json will not be updated. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::DocumentUpdate | ( | int | id, |
const char * | json, | ||
const char * | blob, | ||
int | blobLength ) |
Update a document.
[in] | id | The identifier. |
[in] | json | The json. If json is NULL, then the document json will not be updated. |
[in] | blob | The blob. If blob is NULL, then the document blob will not be updated. |
[in] | blobLength | The blob length. If blob is not NULL and blobLength is 0, then the document blob will be deleted. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::DocumentUpdate | ( | int | id, |
int | entityTag, | ||
const char * | json ) |
Update a document.
[in] | id | The identifier. |
[in] | entityTag | The entity tag. The entity tag must either equal the entity tag of the document or -1. |
[in] | json | The json. If json is NULL, then the document json will not be updated. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::DocumentUpdate | ( | int | id, |
int | entityTag, | ||
const char * | json, | ||
const char * | blob, | ||
int | blobLength ) |
Update a document.
[in] | id | The identifier. |
[in] | entityTag | The entity tag. The entity tag must either equal the entity tag of the document or -1. |
[in] | json | The json. If json is NULL, then the document json will not be updated. |
[in] | blob | The blob. If blob is NULL, then the document blob will not be updated. |
[in] | blobLength | The blob length. If blob is not NULL and blobLength is 0, then the document blob will be deleted. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::Encrypt | ( | const char * | password, |
const char * | passwordAgain ) |
Encrypt a collection.
[in] | password | The password. Password is a null terminated string limited to 32 bytes in length. |
[in] | passwordAgain | The password (again). |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::GetLastStatusCode | ( | ) |
Get the last status code.
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. |
Btrieve::StatusCode BtrieveCollection::Query | ( | BtrieveDocumentSet * | btrieveDocumentSet, |
const char * | query = NULL ) |
Query the collection.
[out] | btrieveDocumentSet | The Btrieve document set. |
[in] | query | The query. The maximum query length is Btrieve::MAXIMUM_RECORD_LENGTH bytes. |
= Btrieve::STATUS_CODE_NO_ERROR | Success. |
!= Btrieve::STATUS_CODE_NO_ERROR | An error has occurred. A more detailed description of the error may be available in the Zen event log. |