MoSync 3.3
Database API

Defines

#define MA_DB_TYPE_NULL   1
#define MA_DB_TYPE_INT   2
#define MA_DB_TYPE_INT64   3
#define MA_DB_TYPE_DOUBLE   4
#define MA_DB_TYPE_BLOB   5
#define MA_DB_TYPE_DATA   6
#define MA_DB_TYPE_TEXT   7
#define MA_DB_OK   0
#define MA_DB_ERROR   -2
#define MA_DB_NO_ROW   -3
#define MA_DB_NULL   -4

Functions

MAHandle maDBOpen (const char *path)
int maDBClose (MAHandle databaseHandle)
MAHandle maDBExecSQL (MAHandle databaseHandle, const char *sql)
MAHandle maDBExecSQLParams (MAHandle databaseHandle, const char *sql, const MADBValue *params, int paramCount)
int maDBCursorDestroy (MAHandle cursorHandle)
int maDBCursorNext (MAHandle cursorHandle)
int maDBCursorGetColumnData (MAHandle cursorHandle, int columnIndex, MAHandle placeholder)
int maDBCursorGetColumnText (MAHandle cursorHandle, int columnIndex, void *buffer, int bufferSize)
int maDBCursorGetColumnInt (MAHandle cursorHandle, int columnIndex, int *value)
int maDBCursorGetColumnDouble (MAHandle cursorHandle, int columnIndex, double *value)
struct __attribute ((packed, aligned(4))) MAAudioBufferInfo
 Information about an audio buffer, including format, sample rate, channels, and size.

Define Documentation

#define MA_DB_TYPE_NULL   1
#define MA_DB_TYPE_INT   2
#define MA_DB_TYPE_INT64   3
#define MA_DB_TYPE_DOUBLE   4
#define MA_DB_TYPE_BLOB   5
#define MA_DB_TYPE_DATA   6
#define MA_DB_TYPE_TEXT   7
#define MA_DB_OK   0

Status codes returned by the maDB functions. Success return value.

#define MA_DB_ERROR   -2

Error return value (-1 reserved for IOCtl not implemented).

#define MA_DB_NO_ROW   -3

The cursor is beyond the last row when calling maDBCursorNext.

#define MA_DB_NULL   -4

A database field value was NULL when calling the maDBCursorGetColumn* functions.


Function Documentation

MAHandle maDBOpen ( const char *  path)

Open a database file. The database is created if it does not exist.

Note:
The application needs file read/write permissions to access database files.
Parameters:
pathAbsolute path to the database file.
Returns:
Handle to the database >0 on success, MA_DB_ERROR on error.

References maIOCtl().

int maDBClose ( MAHandle  databaseHandle)

Close a database.

Parameters:
databaseHandleHandle to the database.
Returns:
MA_DB_OK on success, MA_DB_ERROR on error.

References maIOCtl().

MAHandle maDBExecSQL ( MAHandle  databaseHandle,
const char *  sql 
)

Executes an SQL statement. If the statement returns a query result, a cursor handle is returned. If a query result is empty, MA_DB_OK is returned.

Parameters:
databaseHandleHandle to the database.
sqlThe SQL statement.
Returns:
MA_DB_ERROR on error, MA_DB_OK on success, > 0 if there is a cursor to a query result, in this case the return value is the cursor handle.

References maIOCtl().

MAHandle maDBExecSQLParams ( MAHandle  databaseHandle,
const char *  sql,
const MADBValue params,
int  paramCount 
)

Executes an SQL statement. If the statement returns a query result, a cursor handle is returned. If a query result is empty, MA_DB_OK is returned.

Parameters:
databaseHandleHandle to the database.
sqlThe SQL statement.
Returns:
MA_DB_ERROR on error, MA_DB_OK on success, > 0 if there is a cursor to a query result, in this case the return value is the cursor handle.
Parameters:
paramsArray of values to bind to parameters. Parameters are specified by question marks (?) in the SQL statement.

If this function returns a cursor, any text or blob values being pointed to by elements of the array must remain valid until the cursor has been destroyed by maDBCursorDestroy().

The array itself does not need to remain valid after this function returns.

Parameters:
paramCountNumber of elements in the array pointed to by params.

This function is available on iOS, Android, and in MoRE.

References maIOCtl().

int maDBCursorDestroy ( MAHandle  cursorHandle)

Destroys a cursor. You must call this function when you are done with the cursor to release its resources.

Parameters:
cursorHandleHandle to the cursor.
Returns:
MA_DB_OK on success, MA_DB_ERROR on error.

References maIOCtl().

int maDBCursorNext ( MAHandle  cursorHandle)

Move the cursor to the next row in the result set. Note that you must call this function before retrieving column data. The initial position of the cursor is before the first row in the result set. If the result set is empty, this function will return MA_DB_NO_ROW.

Parameters:
cursorHandleHandle to the cursor.
Returns:
MA_DB_OK if successfully moved to next row, MA_DB_NO_ROW if there are no more rows in the result set, MA_DB_ERROR on error.

References maIOCtl().

int maDBCursorGetColumnData ( MAHandle  cursorHandle,
int  columnIndex,
MAHandle  placeholder 
)

Get the column value at the current row pointed to by the cursor as a data object. Use this function for blob data or text data.

Parameters:
cursorHandleHandle to the cursor.
columnIndexIndex of the column to retrieve value from. First column has index zero.
placeholderHandle created with maCreatePlaceholder. A data object will be created with the column data, and the handle will refer to that data.
Returns:
MA_DB_OK on success, MA_DB_NULL if the column value is NULL, #MA_#MA_DB_ERROR on error.

References maIOCtl().

int maDBCursorGetColumnText ( MAHandle  cursorHandle,
int  columnIndex,
void *  buffer,
int  bufferSize 
)

Get the column value at the current row pointed to by the cursor as a text data buffer. Use this function for text data.

Parameters:
cursorHandleHandle to the cursor.
columnIndexIndex of the column to retrieve value from. First column has index zero.
bufferPointer to buffer to receive the data. The result is NOT zero terminated.
bufferSizeMax size of the buffer.
Returns:
The actual length of the data, if the actual length returned is > bufferSize, data was not copied (buffer too small), returns MA_DB_ERROR on other errors, returns MA_DB_NULL if the column value is NULL.

References maIOCtl().

int maDBCursorGetColumnInt ( MAHandle  cursorHandle,
int  columnIndex,
int *  value 
)

Get the column value at the current row pointed to by the cursor as an int value.

Parameters:
cursorHandleHandle to the cursor.
columnIndexIndex of the column to retrieve value from. First column has index zero.
valuePointer to int to receive the value.
Returns:
MA_DB_OK on success, MA_DB_NULL if the column value is NULL, #MA_#MA_DB_ERROR on error.

References maIOCtl().

int maDBCursorGetColumnDouble ( MAHandle  cursorHandle,
int  columnIndex,
double *  value 
)

Get the column value at the current row pointed to by the cursor as a double value.

Parameters:
cursorHandleHandle to the cursor.
columnIndexIndex of the column to retrieve value from. First column has index zero.
valuePointer to double to receive the value.
Returns:
MA_DB_OK on success, MA_DB_NULL if the column value is NULL, #MA_#MA_DB_ERROR on error.

References maIOCtl().

struct __attribute ( (packed, aligned(4))  ) [read]

Information about an audio buffer, including format, sample rate, channels, and size.

An push notification event.

Input value for maDBExecSQLParams().

The camera format, in pixels.

A structure containing information about the native framebuffer, including color format and resolution.

A geographical location specified by latitude and longitude, horizontal and vertical accuracy, and altitude.

Information about a Bluetooth service.

Information about an MABtService object.

A Universally Unique Identifier.

Information about a Bluetooth device.

A MoSync Panic or other unrecoverable error.

An event; a message indicating that something has happened, e.g. that a key has been pressed.

An puchase event struct. A MoSync event will contain an struct object of this type only if event type is EVENT_TYPE_PURCHASE.

An event send by the Native Image Picker(Capture API).

An event send by a banner widget.

An event containing the result of an NFC asynchronous operation.

A structure containing the sensor type and the data sent to the event.

Data for a connection event, including an indicator or success or failure.

A connection address.

An address for the Bluetooth Serial Port protocol.

A Bluetooth device address.

An address for the protocols TCP or UDP over IPv6.

An address for the protocols TCP or UDP over IPv4.

Parameters for the maCopyData() function.

A structure representing a rectangle.

A WLAN access point.

The x and y coordinate of the top-left corner are defined by 'left' and 'top'. The dimensions of the rectangle are defined by 'width' and 'height'.

In MoSync Debug builds, when such an error occurs, the runtime writes an instance of this structure to a Store named "panic.report".

The length of that instance may be greater than sizeof(MAPanicReport), because of the variable-length string that may appear at its end. The member string can, then, be longer than the one byte that is declared.

To properly read an instance of this struct from a store, you should allocate a chunk of memory whose size is equal to the size of the store, then read the entire store into that chunk of memory. Then you should make a pointer of type MAPanicReport and point it to the chunk. Then you can read normally, using that pointer.

See also:
maOpenStore()
maPanic()
malloc()

Common Bluetooth UUID values can be found in MAUtil/mauuid.h.

Only if state equals MA_LOC_QUALIFIED do the other members contain valid data.

Coordinates are in the WGS84 datum.

The horizontal accuracy is the RMS (root mean square) of east accuracy (latitudinal error in meters, 1-sigma standard deviation), north accuracy (longitudinal error in meters, 1-sigma).

The vertical accuracy is in meters in vertical direction (orthogonal to ellipsoid surface, 1-sigma standard deviation).

Accuracy values may be NaN, if accuracy is unknown.

See also:
maLocationStart()

The 'sizeInBytes' field is the amount of bytes that should be used to allocate the offscreen framebuffer (a backbuffer).

out

in(ptr), out(content)

in

out. dBm?

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines