Database Functions

Functions:

MTK_Database_Close

int MTK_Database_Close(MTK_Database* data);
		

Description

Close database and release any memory used.

Parameters

data

pointer to an MTK_Database struct

Return Value

0

successful

other

failure

MTK_Database_DeleteLayer

int MTK_Database_DeleteLayer(MTK_Database* data, const char* name);
		

Description

Delete a layer from a database.

Parameters

data

pointer to an MTK_Database struct

name

name of the layer (const char*)

Return Value

0

success

other

failure

MTK_Database_GetLayerByIndex

MTK_Layer* MTK_Database_GetLayerByIndex(MTK_Database* data, const int& index);
		

Description

Get the layer with the specified index from a database    Allocates a new object which needs to be freed using MTK_Layer_Close .

Parameters

data

pointer to an MTK_Database struct

index

index of desired layer (int)

Return Value

Pointer to an MTK_Layer struct

success

Null pointer

failure

MTK_Database_GetLayerByName

MTK_Layer* MTK_Database_GetLayerByName(MTK_Database* data, const char* name);
		

Description

Get the layer with the specified name from a database    Allocates a new object which needs to be freed using MTK_Layer_Close .

Parameters

data

pointer to an MTK_Database struct

name

name of desired layer (const char*)

Return Value

Pointer to an MTK_Layer struct

success

Null pointer

failure

MTK_Database_GetLayerNameByIndex

int MTK_Database_GetLayerNameByIndex(
			MTK_Database* data, const int& index,
			char* name
			);
		

Description

Get a specific layer name without loading the layer.

Parameters

data

pointer to an MTK_Database struct

index

index of desired layer (const int&)

name

buffer of length MTK_BUFFER_SIZE to receive the name of desired layer (char*)

Return Value

0

success

other

failure

MTK_Database_GetName

int MTK_Database_GetName(MTK_Database* data, char* name);
		

Description

Get the name of a database.

Parameters

data

pointer to an MTK_Database struct

name

buffer of length MTK_BUFFER_SIZE to receive the database name (char*)

Return Value

0

success

other

failure

MTK_Database_IsOpen

int MTK_Database_IsOpen(MTK_Database* data);
		

Description

Query current database state.

Parameters

data

pointer to an MTK_Database struct

Return Value

0

closed

1

open

other

failure

MTK_Database_LayerExists

int MTK_Database_LayerExists(MTK_Database* data, const char* name);
		

Description

Find if a specific layer exists in a database.

Parameters

data

pointer to an MTK_Database struct

name

name of layer (const char*)

Return Value

1

exists

0

does not exist

other

failure

MTK_Database_NLayers

int MTK_Database_NLayers(MTK_Database* data);
		

Description

Get the number of layers in a database.

Parameters

data

pointer to an MTK_Database struct

Return Value

int

number of layers in the database

-1

failed

MTK_Database_Open

MTK_Database* MTK_Database_Open(const char* name, MTK_Database_OpenMode mode);
		

Description

Open database file.

Parameters

name

database filename (const char*)

mode

file open mode (MTK_Database_OpenMode) (see below)

Return Value

Pointer to a MTK_Database struct

success

Null pointer

failure

enum MTK_Database_OpenMode
{
   DESIGN_MODE_READONLY, // readonly
   DESIGN_MODE_WRITE, // read/write
   DESIGN_MODE_CREATEIF, // read/write create if doesn't exist
   DESIGN_MODE_CREATE // read/write create even if exists
};

MTK_Database_SaveLayer

int MTK_Database_SaveLayer(MTK_Database* data, MTK_Layer* layer);
		

Description

Save a layer in a database.

Parameters

data

pointer to an MTK_Database struct

layer

pointer to an MTK_Layer struct

Return Value

0

success

other

failure

MTK_Database_SaveLayerAs

int MTK_Database_SaveLayerAs(
			MTK_Database* data, MTK_Layer* layer,
			const char* name
			);
		

Description

Save a layer in a database as a selected name.

Parameters

data

pointer to an MTK_Database struct

layer

pointer to an MTK_Layer struct

name

desired name of the layer (const char*)

Return Value

0

success

other

failure