gda.global

Global functions for gda5 library

Members

Functions

alphanumToText
string alphanumToText(string text)

Does the opposite of gda.global.textToAlphanum, in the same string

completionListGet
string[] completionListGet(gda.connection.Connection cnc, string sql, int start, int end)

Creates an array of strings (terminated by a null) corresponding to possible completions. If no completion is available, then the returned array contains just one NULL entry, and if it was not possible to try to compute a completions list, then null is returned.

computeDmlStatements
bool computeDmlStatements(gda.connection.Connection cnc, gda.statement.Statement selectStmt, bool requirePk, gda.statement.Statement insertStmt, gda.statement.Statement updateStmt, gda.statement.Statement deleteStmt)

Creates an INSERT, an UPDATE and a DELETE statement from a SELECT statement using the database metadata available in cnc's meta store. Each statements are computed only if the corresponding place to store the created statement is not null.

dsnSplit
void dsnSplit(string string_, string outDsn, string outUsername, string outPassword)

Extract the DSN, username and password from string. in string, the various parts are strings which are expected to be encoded using an RFC 1738 compliant encoding. If they are specified, the returned username and password strings are correctly decoded.

escapeString
string escapeString(string string_)

Escapes string to make it understandable by a DBMS. The escape method is very common and replaces any occurrence of "'" with "''" and "\" with "\\"

gTypeFromString
gobject.types.GType gTypeFromString(string str)

Converts a named type to ts GType type (also see the gda.global.gTypeToString function).

gTypeToString
string gTypeToString(gobject.types.GType type)

Converts a GType to its string representation (use gda.global.gTypeFromString for the operation in the other direction).

getApplicationExecPath
string getApplicationExecPath(string appName)

Find the path to the application identified by app_name. For example if the application is "gda-sql", then calling this function will return "/your/prefix/bin/gda-sql-5.0" if Libgda is installed in the "/your/prefix" prefix (which would usually be "/usr"), and for the ABI version 5.0.

identifierEqual
bool identifierEqual(string id1, string id2)

Does the same as strcmp(id1, id2), but handles the case where id1 and/or id2 are enclosed in double quotes. can also be used in hash tables as a #GEqualFunc.

identifierHash
uint identifierHash(string id)

computes a hash string from id, to be used in hash tables as a #GHashFunc

init_
void init_()

Initializes the GDA library, must be called prior to any Libgda usage.

localeChanged
void localeChanged()

Call this function whenever the setlocale() function has been called to change the current locale; this function is first called by gda.global.init_ so you don't need to call it if you have set the locale before calling gda.global.init_.

logDisable
void logDisable()

Disables GDA logs.

logEnable
void logEnable()

Enables GDA logs.

logIsEnabled
bool logIsEnabled()
mutexFree
void mutexFree(gda.types.Mutex mutex)
mutexLock
void mutexLock(gda.types.Mutex mutex)
mutexTrylock
bool mutexTrylock(gda.types.Mutex mutex)
mutexUnlock
void mutexUnlock(gda.types.Mutex mutex)
parseFormattedDate
bool parseFormattedDate(glib.date.Date gdate, string value, glib.types.DateDMY first, glib.types.DateDMY second, glib.types.DateDMY third, char sep)

This function is similar to gda.global.parseIso8601Date (with first being G_DATE_YEAR, second being G_DATE_MONTH, third being G_DATE_DAY and sep being '-') but allows one to specify the expected date format.

parseFormattedTime
bool parseFormattedTime(gda.time.Time timegda, string value, char sep)
parseFormattedTimestamp
bool parseFormattedTimestamp(gda.timestamp.Timestamp timestamp, string value, glib.types.DateDMY first, glib.types.DateDMY second, glib.types.DateDMY third, char sep)

This function is similar to gda.global.parseIso8601Timestamp (with first being G_DATE_YEAR, second being G_DATE_MONTH, third being G_DATE_DAY and sep being '-') but allows one to specify the expected date format.

parseIso8601Date
bool parseIso8601Date(glib.date.Date gdate, string value)

Extracts date parts from value, and sets gdate's contents

parseIso8601Time
bool parseIso8601Time(gda.time.Time timegda, string value)

Extracts time parts from value, and sets timegda's contents

parseIso8601Timestamp
bool parseIso8601Timestamp(gda.timestamp.Timestamp timestamp, string value)

Extracts date and time parts from value, and sets timestamp's contents

rewriteStatementForNullParameters
bool rewriteStatementForNullParameters(gda.statement.Statement stmt, gda.set.Set params, gda.statement.Statement outStmt)

Modifies stmt to take into account any parameter which might be null: if stmt contains the equivalent of "xxx = <parameter definition>" and if that parameter is in params and its value is of type GDA_TYPE_NUL, then that part is replaced with "xxx IS NULL". It also handles the "xxx IS NOT NULL" transformation.

rfc1738Decode
bool rfc1738Decode(string string_)

Decodes string using the RFC 1738 recommendations: the <constant>&lt;&gt;&quot;#%{}|\^~[]&apos;`;/?:@=&amp;</constant> and space characters are replaced by <constant>&quot;%ab&quot;</constant> where <constant>ab</constant> is the hexadecimal number corresponding to the character.

rfc1738Encode
string rfc1738Encode(string string_)

Encodes string using the RFC 1738 recommendations: the <constant>&lt;&gt;&quot;#%{}|\^~[]&apos;`;/?:@=&amp;</constant> and space characters are replaced by <constant>&quot;%ab&quot;</constant> where <constant>ab</constant> is the hexadecimal number corresponding to the character.

selectAlterSelectForEmpty
gda.statement.Statement selectAlterSelectForEmpty(gda.statement.Statement stmt)

Creates a new #GdaStatement, selecting the same data as stmt, but which always returns an empty (no row) data model. This is use dy database providers' implementations.

sqlErrorQuark
glib.types.Quark sqlErrorQuark()
sqlIdentifierQuote
string sqlIdentifierQuote(string id, gda.connection.Connection cnc, gda.server_provider.ServerProvider prov, bool metaStoreConvention, bool forceQuotes)

Use this function for any SQL identifier to make sure that: <itemizedlist> <listitem> <para>it is correctly formatted to be used with cnc (if cnc is null, then some default SQL quoting rules will be applied, similar to PostgreSQL's way) if for_meta_store is false; </para> </listitem> <listitem> <para>it is correctly formatted to be used with the #GdaMetaStore's object associated to cnc is for_meta_store is true. </para> </listitem> </itemizedlist>

sqlIdentifierSplit
string[] sqlIdentifierSplit(string id)

Splits id into an array of it sub parts. id's format has to be "&lt;part&gt;[.&lt;part&gt;...]" where each part is either a text surrounded by double quotes which can contain upper and lower cases or an SQL identifier in lower case.

stringToBinary
gda.binary.Binary stringToBinary(string str)

Performs the reverse of gda.binary.Binary.toString_ (note that for any "\xyz" succession of 4 characters where "xyz" represents a valid octal value, the resulting read value will be modulo 256).

stringToBlob
gda.blob.Blob stringToBlob(string str)

Performs the reverse of gda.blob.Blob.toString_.

textToAlphanum
string textToAlphanum(string text)

The "encoding" consists in replacing non alphanumeric character with the string "__gdaXX" where XX is the hex. representation of the non alphanumeric char.

unescapeString
string unescapeString(string string_)

Do the reverse of gda.global.defaultEscapeString: transforms any "''" into "'", any "\\" into "\" and any "\'" into "'".

utilityCheckDataModel
bool utilityCheckDataModel(gda.data_model.DataModel model, gobject.types.GType[] types)

Check the column types of a GdaDataModel.

utilityDataModelDumpDataToXml
bool utilityDataModelDumpDataToXml(gda.data_model.DataModel model, libxml2.types.NodePtr parent, int[] cols, int[] rows, bool useColIds)

Dump the data in a #GdaDataModel into a xmlNodePtr (as used in libxml).

utilityDataModelFindColumnDescription
string utilityDataModelFindColumnDescription(gda.data_select.DataSelect model, string fieldName)

Finds the description of a field into Metadata from a #GdaDataModel.

utilityHolderLoadAttributes
bool utilityHolderLoadAttributes(gda.holder.Holder holder, libxml2.types.NodePtr node, gda.data_model.DataModel[] sources)

Note: this method may set the "source" custom string property

valueCompare
int valueCompare(gobject.value.Value value1, gobject.value.Value value2)

Compares two values of the same type, with the exception that a value of any type can be compared to a GDA_TYPE_NULL value, specifically: <itemizedlist> <listitem><para>if value1 and value2 are both GDA_TYPE_NULL values then the returned value is 0</para></listitem> <listitem><para>if value1 is a GDA_TYPE_NULL value and value2 is of another type then the returned value is -1</para></listitem> <listitem><para>if value1 is of another type and value2 is a GDA_TYPE_NULL value then the returned value is 1</para></listitem> <listitem><para>in all other cases, value1 and value2 must be of the same type and their values are compared</para></listitem> </itemizedlist>

valueDiffer
int valueDiffer(gobject.value.Value value1, gobject.value.Value value2)

Tells if two values are equal or not, by comparing memory representations. Unlike gda.global.valueCompare, the returned value is boolean, and gives no idea about ordering.

valueStringify
string valueStringify(gobject.value.Value value)

Converts a GValue to its string representation which is a human readable value. Note that the returned string does not take into account the current locale of the user (on the contrary to the #GdaDataHandler objects). Using this function should be limited to debugging and values serialization purposes.