Top |
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".
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 GDA_TYPE_TIMESTAMP
"boolean" for G_TYPE_BOOLEAN
"blob" for GDA_TYPE_BLOB
"binary" for GDA_TYPE_BINARY
"null" for GDA_TYPE_NULL
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 "\"
gchar *
gda_default_unescape_string (const gchar *string
);
Do the reverse of gda_default_escape_string()
: transforms any "''" into "'", any
"\" into "\" and any "\'" into "'".
guint
gda_identifier_hash (const gchar *id
);
computes a hash string from id
, to be used in hash tables as a GHashFunc
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.
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.
cnc |
a GdaConnection object |
|
sql |
a partial SQL statement which is the context of the completion proposal |
|
start |
starting position within |
|
end |
ending position within |
a new array of strings, or NULL
(use g_strfreev()
to free the returned array).
[transfer full][array zero-terminated=1][nullable]
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.
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.
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.
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"
string |
a string in the "<provider>://@]<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 |
[nullable] |
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.
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
gboolean gda_parse_iso8601_timestamp (GdaTimestamp *timestamp
,const gchar *value
);
Extracts date and time parts from value
, and sets timestamp
's contents
Accepted date format is "YYYY-MM-DD HH:MM:SS.ms" where TZ is +hour or -hour
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.
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 |
|
second |
a GDateDMY specifying which of year, month or day appears second (in the first bytes) in |
|
third |
a GDateDMY specifying which of year, month or day appears third (in the first bytes) in |
|
sep |
spcifies the expected separator character bewteen year, month and day (for example '-') |
Since: 5.2
gboolean gda_parse_formatted_time (GdaTime *timegda
,const gchar *value
,gchar sep
);
timegda |
a pointer to a GdaTime structure which will be filled |
|
value |
a string |
|
sep |
the time separator, usually ':'. If equal to |
Since: 5.2
gboolean gda_parse_formatted_timestamp (GdaTimestamp *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.
timestamp |
a pointer to a GdaTimeStamp 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 |
|
second |
a GDateDMY specifying which of year, month or day appears second (in the first bytes) in |
|
third |
a GDateDMY specifying which of year, month or day appears third (in the first bytes) in |
|
sep |
spcifies the expected separator character bewteen year, month and day (for example '-') |
Since: 5.2