Utility functions

Utility functions — Utility functions

Stability Level

Stable, unless otherwise indicated

Description

Some useful functions.

Functions

gda_g_type_to_string ()

const gchar *
gda_g_type_to_string (GType type);

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

This function wraps g_type_name() but for common types it provides an easier to understand and remember name. For Example the G_TYPE_STRING is converted to "string" whereas g_type_name() converts it to "gchararray".

Parameters

type

Type to convert from.

 

Returns

the GDA's string representing the given GType or the name returned by g_type_name.


gda_g_type_from_string ()

GType
gda_g_type_from_string (const gchar *str);

Converts a named type to ts GType type (also see the gda_g_type_to_string() function).

This function is a wrapper around the g_type_from_name() function, but also recognizes some type synonyms such as:

  • "int" for G_TYPE_INT

  • "uint" for G_TYPE_UINT

  • "int64" for G_TYPE_INT64

  • "uint64" for G_TYPE_UINT64

  • "char" for G_TYPE_CHAR

  • "uchar" for G_TYPE_UCHAR

  • "short" for GDA_TYPE_SHORT

  • "ushort" for GDA_TYPE_USHORT

  • "string" for G_TYPE_STRING

  • "date" for G_TYPE_DATE

  • "time" for GDA_TYPE_TIME

  • "timestamp" for G_TYPE_DATE_TIME

  • "boolean" for G_TYPE_BOOLEAN

  • "blob" for GDA_TYPE_BLOB

  • "binary" for GDA_TYPE_BINARY

  • "null" for GDA_TYPE_NULL

Parameters

str

the name of a GType, as returned by gda_g_type_to_string().

 

Returns

the GType represented by the given str , or G_TYPE_INVALID if not found


gda_default_escape_string ()

gchar *
gda_default_escape_string (const gchar *string);

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

Parameters

string

string to escape

 

Returns

a new string


gda_default_unescape_string ()

gchar *
gda_default_unescape_string (const gchar *string);

Do the reverse of gda_default_escape_string(): transforms any "''" into "'", any "\" into "\" and any "\'" into "'".

Parameters

string

string to unescape

 

Returns

a new unescaped string, or NULL in an error was found in string


gda_identifier_hash ()

guint
gda_identifier_hash (const gchar *id);

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

Parameters

id

an identifier string

 

Returns

a new hash


gda_identifier_equal ()

gboolean
gda_identifier_equal (const gchar *id1,
                      const gchar *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.

Parameters

id1

an identifier string

 

id2

an identifier string

 

Returns

TRUE if id1 and id2 are equal.


gda_completion_list_get ()

gchar **
gda_completion_list_get (GdaConnection *cnc,
                         const gchar *sql,
                         gint start,
                         gint 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.

Parameters

cnc

a GdaConnection object

 

sql

a partial SQL statement which is the context of the completion proposal, may also start with a "." for Gda's tools which use internal commands

 

start

starting position within sql of the "token" to complete (starts at 0)

 

end

ending position within sql of the "token" to complete

 

Returns

a new array of strings, or NULL (use g_strfreev() to free the returned array).

[transfer full][array zero-terminated=1][allow-none]


gda_sql_identifier_split ()

gchar **
gda_sql_identifier_split (const gchar *id);

Splits id into an array of it sub parts. id 's format has to be "<part>[.<part>[...]]" 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.

For example the "test.\"ATable\"" string will result in the array: {"test", "\"ATable\"", NULL}

Parameters

id

an SQL identifier

 

Returns

a new NULL-terminated array of strings, or NULL (use g_strfreev() to free the returned array).

[transfer full][array zero-terminated=1][allow-none]


gda_sql_identifier_quote ()

gchar *
gda_sql_identifier_quote (const gchar *id,
                          GdaConnection *cnc,
                          GdaServerProvider *prov,
                          gboolean meta_store_convention,
                          gboolean force_quotes);

Use this function for any SQL identifier to make sure that:

  • 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;

  • it is correctly formatted to be used with the GdaMetaStore's object associated to cnc is for_meta_store is TRUE.

The force_quotes allow some control of how to interpret id : if FALSE, then id will be left unchanged most of the time (except for example if it's a reserved keyword), otherwise if force_quotes is TRUE, then the returned string will most probably have quotes around it to request that the database keep the case sensitiveness (but again, this may vary depending on the database being accessed through cnc ).

For example, the following table gives the result of this function depending on the arguments when cnc is NULL (and prov is also NULL):

Table 1. 

id for_meta_store=FALSE, force_quotes=FALSE for_meta_store=TRUE, force_quotes=FALSE for_meta_store=FALSE, force_quotes=TRUE for_meta_store=TRUE, force_quotes=TRUE remark
"double word" "double word" "double word" "double word" "double word" non allowed character in SQL identifier
"CapitalTest" "CapitalTest" "CapitalTest" "CapitalTest" "CapitalTest" Mixed case SQL identifier, already quoted
CapitalTest CapitalTest capitaltest "CapitalTest" "CapitalTest" Mixed case SQL identifier, non quoted
"mytable" "mytable" mytable "mytable" mytable All lowser case, quoted
mytable mytable mytable "mytable" mytable All lowser case
MYTABLE MYTABLE mytable "MYTABLE" "MYTABLE" All upper case
"MYTABLE" "MYTABLE" "MYTABLE" "MYTABLE" "MYTABLE" All upper case, quoted
desc "desc" "desc" "desc" "desc" SQL reserved keyword
5ive "5ive" "5ive" "5ive" "5ive" SQL identifier starting with a digit


Here are a few examples of when and how to use this function:

  • When creating a table, the user has entered the table name, this function can be used to create a valid SQL identifier from the user provided table name:

    gchar *user_sqlid=...
    gchar *valid_sqlid = gda_sql_identifier_quote (user_sqlid, cnc, NULL, FALSE, FALSE);
    gchar *sql = g_strdup_printf ("CREATE TABLE %s ...", valid_sqlid);
    g_free (valid_sqlid);
          

    Note that this is an illustration and creating a table should be sone using a GdaServerOperation object.

  • When updating the meta data associated to a table which has been created with the code above:

    GValue table_name_value = { 0 };
    gchar* column_names[] = { (gchar*)"table_name" };
    GValue* column_values[] = { &table_name_value };
    GdaMetaContext mcontext = { (gchar*)"_tables", 1, column_names, column_values };
    g_value_init (&table_name_value, G_TYPE_STRING);
    g_value_take_string (&table_name_value, gda_sql_identifier_quote (user_sqlid, cnc, NULL, TRUE, FALSE);
    gda_connection_update_meta_store (cnc, &mcontext, NULL);
    g_value_reset (&table_name_value);
          

  • When using a GdaMetaStruct object to fetch information about a table (which has been created with the code above):

    GValue table_name_value = { 0 };
    g_value_init (&table_name_value, G_TYPE_STRING);
    g_value_take_string (&table_name_value, gda_sql_identifier_quote (user_sqlid, cnc, NULL, TRUE, FALSE);
    GdaMetaDbObject *dbo;
    dbo = gda_meta_struct_complement (mstruct, GDA_META_DB_TABLE, NULL, NULL, &table_name_value, NULL);
    g_value_reset (&table_name_value);
          

Note that id must not be a composed SQL identifier (such as "mytable.mycolumn" which should be treated as the "mytable" and "mycolumn" SQL identifiers). If unsure, use gda_sql_identifier_split().

Also note that if cnc is NULL, then it's possible to pass an non NULL prov to have a result specific to prov .

For more information, see the SQL identifiers and abstraction and

SQL identifiers in meta data sections.

Parameters

id

an SQL identifier

 

cnc

a GdaConnection object, or NULL.

[allow-none]

prov

a GdaServerProvider object, or NULL for_meta_store set to TRUE if the returned string will be used in a GdaMetaStore.

[allow-none]

force_quotes

set to TRUE to force the returned string to be quoted

 

Returns

the representation of id ready to be used in SQL statement, as a new string, or NULL if id is in a wrong format

Since: 4.0.3


gda_utility_check_data_model ()

gboolean
gda_utility_check_data_model (GdaDataModel *model,
                              gint nbcols,
                              ...);

Check the column types of a GdaDataModel.

Parameters

model

a GdaDataModel object

 

nbcols

the minimum requested number of columns

 

...

nbcols arguments of type GType or -1 (if any data type is accepted)

 

Returns

TRUE if the data model's columns match the provided data types and number


gda_utility_check_data_model_v ()

gboolean
gda_utility_check_data_model_v (GdaDataModel *model,
                                gint nbcols,
                                GType *types);

Check the column types of a GdaDataModel.

[rename-to gda_utility_check_data_model]

Parameters

model

a GdaDataModel object

 

nbcols

the minimum requested number of columns

 

types

array with nbcols length of type GType or null (if any data type is accepted).

[array length=nbcols]

Returns

TRUE if the data model's columns match the provided data types and number

Since: 4.2.6


gda_utility_data_model_dump_data_to_xml ()

gboolean
gda_utility_data_model_dump_data_to_xml
                               (GdaDataModel *model,
                                xmlNodePtr parent,
                                const gint *cols,
                                gint nb_cols,
                                const gint *rows,
                                gint nb_rows,
                                gboolean use_col_ids);

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

Warning: this function uses a GdaDataModelIter iterator, and if model does not offer a random access (check using gda_data_model_get_access_flags()), the iterator will be the same as normally used to access data in model previously to calling this method, and this iterator will be moved (point to another row).

Parameters

model

a GdaDataModel

 

parent

the parent XML node

 

cols

an array containing which columns of model will be exported, or NULL for all columns.

[allow-none][array length=nb_cols]

nb_cols

the number of columns in cols

 

rows

an array containing which rows of model will be exported, or NULL for all rows.

[allow-none][array length=nb_rows]

nb_rows

the number of rows in rows

 

use_col_ids

set to TRUE to add column ID information

 

Returns

TRUE if no error occurred


gda_utility_data_model_find_column_description ()

const gchar *
gda_utility_data_model_find_column_description
                               (GdaDataSelect *model,
                                const gchar *field_name);

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

Parameters

model

a GdaDataSelect data model

 

field_name

field name

 

Returns

The field's description, or NULL if description is not set


gda_utility_holder_load_attributes ()

gboolean
gda_utility_holder_load_attributes (GdaHolder *holder,
                                    xmlNodePtr node,
                                    GSList *sources,
                                    GError **error);

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

Parameters

holder

a GdaHolder

 

node

an xmlNodePtr with a <parameter> tag

 

sources

a list of GdaDataModel.

[element-type Gda.DataModel]

error

a place to store errors, or NULL

 

Returns

TRUE if no error occurred


gda_statement_rewrite_for_default_values ()

GdaSqlStatement *
gda_statement_rewrite_for_default_values
                               (GdaStatement *stmt,
                                GdaSet *params,
                                gboolean remove,
                                GError **error);

Rewrites stmt and creates a new GdaSqlStatement where all the variables which are to a DEFAULT value (as returned by gda_holder_value_is_default()) are either removed from the statement (if remove is TRUE) or replaced by the "DEFAULT" keyword (if remove is FALSE).

This function is only useful for database providers' implementations which have to deal with default values when executing statements, and is only relevant in the case of INSERT or UPDATE statements (in the latter case an error is returned if remove is TRUE).

For example the

INSERT INTO mytable (id, name) VALUES (23, ##name::string)

is re-written into

INSERT INTO mytable (id, name) VALUES (23, DEFAULT)

if remove is FALSE and into

INSERT INTO mytable (id) VALUES (23)

if remove is TRUE.

Parameters

stmt

a GdaStatement object

 

params

a GdaSet containing the variable's values to be bound when executing stmt

 

remove

set to TRUE if DEFAULT fields are removed, of FALSE if the "DEFAULT" keyword is used

 

error

a place to store errors, or NULL

 

Returns

a new GdaSqlStatement, or NULL if an error occurred

Since: 4.2


gda_text_to_alphanum ()

gchar *
gda_text_to_alphanum (const gchar *text);

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

Parameters

text

the text to convert

 

Returns

a new string


gda_alphanum_to_text ()

gchar *
gda_alphanum_to_text (gchar *text);

Does the opposite of gda_text_to_alphanum(), in the same string

Parameters

text

a string

 

Returns

text if conversion succeeded or NULL if an error occurred


gda_compute_unique_table_row_condition ()

GdaSqlExpr *
gda_compute_unique_table_row_condition
                               (GdaSqlStatementSelect *stsel,
                                GdaMetaTable *mtable,
                                gboolean require_pk,
                                GError **error);

Computes a GdaSqlExpr expression which can be used in the WHERE clause of an UPDATE or DELETE statement when a row from the result of the stsel statement has to be modified.

Parameters

stsel

a GdaSqlSelectStatement

 

mtable

a GdaMetaTable

 

require_pk

set to TRUE if a primary key ir required

 

error

a place to store errors, or NULL

 

Returns

a new GdaSqlExpr, or NULL if an error occurred.


gda_compute_unique_table_row_condition_with_cnc ()

GdaSqlExpr *
gda_compute_unique_table_row_condition_with_cnc
                               (GdaConnection *cnc,
                                GdaSqlStatementSelect *stsel,
                                GdaMetaTable *mtable,
                                gboolean require_pk,
                                GError **error);

Computes a GdaSqlExpr expression which can be used in the WHERE clause of an UPDATE or DELETE statement when a row from the result of the stsel statement has to be modified.

If require_pk is TRUE then this function will return a non NULL GdaSqlExpr only if it can use a primary key of mtable . If require_pk is FALSE, then it will try to use a primary key of mtable , and if none is available, it will use all the columns of mtable to compute a condition statement.

Parameters

cnc

a GdaConnection, or NULL.

[allow-none]

stsel

a GdaSqlSelectStatement

 

mtable

a GdaMetaTable

 

require_pk

set to TRUE if a primary key is required

 

error

a place to store errors, or NULL

 

Returns

a new GdaSqlExpr, or NULL if an error occurred.

Since: 4.0.3


gda_compute_dml_statements ()

gboolean
gda_compute_dml_statements (GdaConnection *cnc,
                            GdaStatement *select_stmt,
                            gboolean require_pk,
                            GdaStatement **insert_stmt,
                            GdaStatement **update_stmt,
                            GdaStatement **delete_stmt,
                            GError **error);

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.

Parameters

cnc

a GdaConnection

 

select_stmt

a SELECT GdaStatement (compound statements not handled)

 

require_pk

TRUE if the created statement have to use a primary key

 

insert_stmt

a place to store the created INSERT statement, or NULL.

[allow-none][transfer full]

update_stmt

a place to store the created UPDATE statement, or NULL.

[allow-none][transfer full]

delete_stmt

a place to store the created DELETE statement, or NULL.

[allow-none][transfer full]

error

a place to store errors, or NULL.

[allow-none]

Returns

TRUE if no error occurred


gda_compute_select_statement_from_update ()

GdaSqlStatement *
gda_compute_select_statement_from_update
                               (GdaStatement *update_stmt,
                                GError **error);

Computes a SELECT statement which selects all the rows the update_stmt would update. Beware however that this GdaSqlStatement does not select anything (ie it would be rendered as "SELECT FROM ... WHERE ...") and before being usable, one needs to add some fields to actually select.

Parameters

update_stmt

an UPDATE statement

 

error

a place to store errors, or NULL

 

Returns

a new GdaStatement if no error occurred, or NULL otherwise


gda_rewrite_sql_statement_for_null_parameters ()

GdaSqlStatement *
gda_rewrite_sql_statement_for_null_parameters
                               (GdaSqlStatement *sqlst,
                                GdaSet *params,
                                gboolean *out_modified,
                                GError **error);

Modifies sqlst to take into account any parameter which might be NULL: if sqlst 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.

If out_modified is not NULL, then it will be set to TRUE if sqlst has been modified by this function, and to FALSE otherwise.

This function is used by provider's implementations to make sure one can use parameters with NULL values in statements without having to rewrite statements, as database usually don't consider that "xxx = NULL" is the same as "xxx IS NULL" when using parameters.

Parameters

sqlst

a GdaSqlStatement.

[transfer full]

params

a GdaSet to be used as parameters when executing stmt

 

out_modified

a place to store the boolean which tells if stmt has been modified or not, or NULL.

[allow-none]

error

a place to store errors, or NULL

 

Returns

the modified sqlst statement, or NULL if an error occurred.

[transfer full]

Since: 4.2.9


gda_rewrite_statement_for_null_parameters ()

gboolean
gda_rewrite_statement_for_null_parameters
                               (GdaStatement *stmt,
                                GdaSet *params,
                                GdaStatement **out_stmt,
                                GError **error);

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.

For example the following SELECT:

SELECT * FROM data WHERE id = ##id::int::null AND name = ##name::string

in case the "id" parameter is set to NULL, is converted to:

SELECT * FROM data WHERE id IS NULL AND name = ##name::string

if out_stmt is not NULL, then it will contain:

  • the modified statement if some modifications were required and no error occured (the function returns TRUE)

  • NULL if no modification to stmt were required and no erro occurred (the function returns FALSE)

  • NULL if an error occured (the function returns TRUE)

This function is used by provider's implementations to make sure one can use parameters with NULL values in statements without having to rewrite statements, as database usually don't consider that "xxx = NULL" is the same as "xxx IS NULL" when using parameters.

Parameters

stmt

a GdaStatement.

[transfer none]

params

a GdaSet to be used as parameters when executing stmt

 

out_stmt

a place to store the new GdaStatement, or NULL.

[transfer full][allow-none]

error

a place to store errors, or NULL

 

Returns

TRUE if stmt needs to be transformed to handle NULL parameters, and FALSE otherwise

Since: 4.2.9


gda_rfc1738_encode ()

gchar *
gda_rfc1738_encode (const gchar *string);

Encodes string using the RFC 1738 recommendations: the

<>"#%{}|\^~[]'`;/?:@=& and space characters are replaced by "%ab" where ab is the hexadecimal number corresponding to the character.

Parameters

string

a string to encode

 

Returns

a new string.

[transfer full]


gda_rfc1738_decode ()

gboolean
gda_rfc1738_decode (gchar *string);

Decodes string using the RFC 1738 recommendations: the

<>"#%{}|\^~[]'`;/?:@=& and space characters are replaced by "%ab" where ab is the hexadecimal number corresponding to the character.

string should respect the RFC 1738 encoding. If this is not the case (for example if there is a "2z" because 2z is not an hexadecimal value), then the part with the problem is not decoded, and the function returns FALSE.

string is decoded in place, no new string gets created.

Parameters

string

a string to decode

 

Returns

TRUE if no error occurred.


gda_dsn_split ()

void
gda_dsn_split (const gchar *string,
               gchar **out_dsn,
               gchar **out_username,
               gchar **out_password);

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.

out_username and out_password may be set to NULL depending on string 's format.

Parameters

string

a string in the "[<username>[:<password>]@]<DSN>" form

 

out_dsn

a place to store the new string containing the <DSN> part

 

out_username

a place to store the new string containing the <username> part

 

out_password

a place to store the new string containing the <password> part

 

gda_connection_string_split ()

void
gda_connection_string_split (const gchar *string,
                             gchar **out_cnc_params,
                             gchar **out_provider,
                             gchar **out_username,
                             gchar **out_password);

Extract the provider, connection parameters, 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 provider, username and password strings are correctly decoded.

For example all the following connection strings:

PostgreSQL://meme:pass@DB_NAME=mydb;HOST=server
PostgreSQL://meme@DB_NAME=mydb;HOST=server;PASSWORD=pass
PostgreSQL://meme@DB_NAME=mydb;PASSWORD=pass;HOST=server
PostgreSQL://meme@PASSWORD=pass;DB_NAME=mydb;HOST=server
PostgreSQL://DB_NAME=mydb;HOST=server;USERNAME=meme;PASSWORD=pass
PostgreSQL://DB_NAME=mydb;HOST=server;PASSWORD=pass;USERNAME=meme
PostgreSQL://DB_NAME=mydb;USERNAME=meme;PASSWORD=pass;HOST=server
PostgreSQL://PASSWORD=pass;USERNAME=meme;DB_NAME=mydb;HOST=server
PostgreSQL://:pass@USERNAME=meme;DB_NAME=mydb;HOST=server
PostgreSQL://:pass@DB_NAME=mydb;HOST=server;USERNAME=meme

will return the following new strings (double quotes added here to delimit strings):

out_cnc_params: "DB_NAME=mydb;HOST=server"
out_provider: "PostgreSQL"
out_username: "meme"
out_password: "pass"

Parameters

string

a string in the "&lt;provider&gt;://@]<connection_params>" form

 

out_cnc_params

a place to store the new string containing the <connection_params> part

 

out_provider

a place to store the new string containing the <provider> part

 

out_username

a place to store the new string containing the <username> part

 

out_password

a place to store the new string containing the <password> part, or NULL.

[allow-none]

gda_parse_iso8601_date ()

gboolean
gda_parse_iso8601_date (GDate *gdate,
                        const gchar *value);

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

Accepted date format is "YYYY-MM-DD" (more or less than 4 digits for years and less than 2 digits for month and day are accepted). Years must be in the 1-65535 range, a limitation imposed by GDate.

Parameters

gdate

a pointer to a GDate structure which will be filled

 

value

a string

 

Returns

TRUE if value has been sucessfuly parsed as a valid date (see g_date_valid()).


gda_parse_iso8601_time ()

gboolean
gda_parse_iso8601_time (GdaTime *timegda,
                        const gchar *value);

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

Accepted date format is "HH:MM:SS.ms" where TZ is +hour or -hour

Parameters

timegda

a pointer to a GdaTime structure which will be filled

 

value

a string

 

Returns

TRUE if no error occurred


gda_parse_iso8601_timestamp ()

GDateTime *
gda_parse_iso8601_timestamp (const gchar *value);

gda_parse_iso8601_timestamp is deprecated and should not be used in newly-written code.

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

Accepted date format is "YYYY-MM-DDTHH:MM:SS.ms" where TZ is +hour or -hour

Parameters

value

a string

 

Returns

a new GDateTime if value has been successfully parsed as a valid timestamp (see g_date_valid()). The returned instance should be freed using g_date_time_unref().


gda_parse_formatted_date ()

gboolean
gda_parse_formatted_date (GDate *gdate,
                          const gchar *value,
                          GDateDMY first,
                          GDateDMY second,
                          GDateDMY third,
                          gchar sep);

This function is similar to gda_parse_iso8601_date() (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.

Parameters

gdate

a pointer to a GDate structure which will be filled

 

value

a string to be parsed

 

first

a GDateDMY specifying which of year, month or day appears first (in the first bytes) in value

 

second

a GDateDMY specifying which of year, month or day appears second (in the first bytes) in value

 

third

a GDateDMY specifying which of year, month or day appears third (in the first bytes) in value

 

sep

spcifies the expected separator character bewteen year, month and day (for example '-')

 

Returns

TRUE if value has been sucessfuly parsed as a valid date (see g_date_valid()).

Since: 5.2


gda_parse_formatted_time ()

gboolean
gda_parse_formatted_time (GdaTime *timegda,
                          const gchar *value,
                          gchar sep);

Parameters

timegda

a pointer to a GdaTime structure which will be filled

 

value

a string

 

sep

the time separator, usually ':'. If equal to 0 , then the expexted format will be HHMMSS...

 

Returns

TRUE if no error occurred

Since: 5.2


gda_parse_formatted_timestamp ()

GDateTime *
gda_parse_formatted_timestamp (const gchar *value,
                               GDateDMY first,
                               GDateDMY second,
                               GDateDMY third,
                               gchar sep);

This function is similar to gda_parse_iso8601_timestamp() (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.

Parameters

value

a string to be parsed

 

first

a GDateDMY specifying which of year, month or day appears first (in the first bytes) in value

 

second

a GDateDMY specifying which of year, month or day appears second (in the first bytes) in value

 

third

a GDateDMY specifying which of year, month or day appears third (in the first bytes) in value

 

sep

specifies the expected separator character between year, month and day (for example '-')

 

Returns

a new GDateTime if value has been successfully parsed as a valid date (see g_date_valid()).

[nullable]

Since: 5.2

Types and Values