This is an example of collection use written in C++.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <string>
static char *btrieveCollectionName = (char *)"squaresAndSquareRoots.btr";
#define MIN_X 0
#define MAX_X 255
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
int i;
char json[1024];
int iSquared;
double iSquareRoot;
for (i = MIN_X; i <= MAX_X; i++)
{
iSquared = i * i;
iSquareRoot = sqrt((double)i);
snprintf(json, sizeof(json),
"{ \"x\": %d, \"xSquared\": %d, \"xSquareRoot\": %f, \"text\": \"The square of %d is %d and its square root is %f.\" }",
i, iSquared, iSquareRoot, i, iSquared, iSquareRoot);
json[sizeof(json) - 1] = '\0';
{
goto leave;
}
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
std::string query;
int size;
int id;
const char *json;
query = "{ \"x\": ";
query = query + key;
query = query + "}";
{
goto leave;
}
if ((size = btrieveDocumentSet.
Size()) < 0)
{
goto leave;
}
if (size != 1)
{
printf("Error: BtrieveDocumentSet::Size():%d:%s.\n", size, "Unexpected size. Size should be one.");
goto leave;
}
if ((
id = btrieveDocumentSet.
PopFirst()) < 0)
{
goto leave;
}
{
goto leave;
}
printf("json: %s\n", json);
leave:
return status;
}
int
main(int argc, char *argv[])
{
static const char *usage = "Usage: %s uint8_value\n";
const char *key;
uint64_t integerValue;
if (argc != 2)
{
printf(usage, argv[0]);
goto leave;
}
integerValue = atoi(argv[1]);
if ((integerValue < MIN_X) || (integerValue > MAX_X))
{
printf(usage, argv[0]);
goto leave;
}
key = argv[1];
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return 0;
return 1;
}
The Btrieve client class.
Definition btrieveCpp.h:1388
Btrieve::StatusCode CollectionDelete(const char *collectionName)
Delete a collection.
Btrieve::StatusCode CollectionClose(BtrieveCollection *btrieveCollection)
Close a collection.
Btrieve::StatusCode CollectionOpen(BtrieveCollection *btrieveCollection, const char *collectionName, const char *password=NULL)
Open a collection.
Btrieve::StatusCode CollectionCreate(const char *collectionName)
Create a collection.
The Btrieve collection class.
Definition btrieveCpp.h:4154
const char * DocumentRetrieveJson(int id)
Retrieve a document json.
Btrieve::StatusCode Query(BtrieveDocumentSet *btrieveDocumentSet, const char *query=NULL)
Query the collection.
Btrieve::StatusCode GetLastStatusCode()
Get the last status code.
int DocumentCreate(const char *json)
Create a document.
The Btrieve document set class.
Definition btrieveCpp.h:4393
int PopFirst()
Remove and return the first document identifier from the set.
int Size()
Return the number of document identifiers in the set.
Btrieve::StatusCode GetLastStatusCode()
Get the last status code.
static const char * StatusCodeToString(StatusCode statusCode)
Return a status code as a string.
StatusCode
The Btrieve status codes.
Definition btrieveCpp.h:713
@ STATUS_CODE_UNKNOWN
-7 - Unknown.
Definition btrieveCpp.h:1194
@ STATUS_CODE_NO_ERROR
0 - No error.
Definition btrieveCpp.h:715