Re: [gnome-db] inverse of gda_server_operation_op_type_to_string



Il giorno ven 02 lug 2010 14:34:51 CEST, Vivien Malerba ha scritto:

On 2 July 2010 12:51, Andrea Zagli <azagli libero it> wrote:
as the subject: what's the inverse function of
gda_server_operation_op_type_to_string? to get the GdaServerOperationType
from the string (for example "GdaServerOperationType
gda_server_operation_string_to_op_type (const gchar *type)")


There is none, but it could be easy to add one, I suppose it it could
be usefull for serialization/deserialization.

i'm using this very simple code (attached)
GdaServerOperationType
gda_server_operation_string_to_op_type (const gchar *str_operation_type)
{
	GdaServerOperationType operation_type = GDA_SERVER_OPERATION_LAST;

	if (g_strcmp0 (str_operation_type, "CREATE_DB") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_DB;
	if (g_strcmp0 (str_operation_type, "DROP_DB") == 0) operation_type = GDA_SERVER_OPERATION_DROP_DB;
	if (g_strcmp0 (str_operation_type, "CREATE_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_TABLE;
	if (g_strcmp0 (str_operation_type, "DROP_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_DROP_TABLE;
	if (g_strcmp0 (str_operation_type, "CREATE_INDEX") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_INDEX;
	if (g_strcmp0 (str_operation_type, "DROP_INDEX") == 0) operation_type = GDA_SERVER_OPERATION_DROP_INDEX;
	if (g_strcmp0 (str_operation_type, "RENAME_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_RENAME_TABLE;
	if (g_strcmp0 (str_operation_type, "COMMENT_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_COMMENT_TABLE;
	if (g_strcmp0 (str_operation_type, "ADD_COLUMN") == 0) operation_type = GDA_SERVER_OPERATION_ADD_COLUMN;
	if (g_strcmp0 (str_operation_type, "DROP_COLUMN") == 0) operation_type = GDA_SERVER_OPERATION_DROP_COLUMN;
	if (g_strcmp0 (str_operation_type, "COMMENT_COLUMN") == 0) operation_type = GDA_SERVER_OPERATION_COMMENT_COLUMN;
	if (g_strcmp0 (str_operation_type, "CREATE_VIEW") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_VIEW;
	if (g_strcmp0 (str_operation_type, "DROP_VIEW") == 0) operation_type = GDA_SERVER_OPERATION_DROP_VIEW;
	if (g_strcmp0 (str_operation_type, "CREATE_USER") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_USER;
	if (g_strcmp0 (str_operation_type, "DROP_USER") == 0) operation_type = GDA_SERVER_OPERATION_DROP_USER;
	if (g_strcmp0 (str_operation_type, "ALTER_USER") == 0) operation_type = GDA_SERVER_OPERATION_ALTER_USER;

	if (operation_type == GDA_SERVER_OPERATION_LAST)
		{
			g_warning ("Operation type \"%s\" not supported.\n%s\n", str_operation_type,
					   error && error->message ? error->message : "No detail");
		}

	return operation_type;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]