diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-09-08 07:47:41 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-09-08 07:47:41 (GMT) |
commit | fbb80d00d8ac456451963d52af24fcccbbc1d751 (patch) | |
tree | 232d2f63378bf30db17c33c399cedc28fc13d4f9 /src/analysis/db/items | |
parent | 1a85f36e0505d75a51ab7b7f2c5078da7ef6bd98 (diff) |
Updated the database protocol for bookmarks.
Diffstat (limited to 'src/analysis/db/items')
-rw-r--r-- | src/analysis/db/items/bookmark.c | 59 | ||||
-rw-r--r-- | src/analysis/db/items/bookmark.h | 30 |
2 files changed, 52 insertions, 37 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c index 1dc299b..266b04c 100644 --- a/src/analysis/db/items/bookmark.c +++ b/src/analysis/db/items/bookmark.c @@ -266,12 +266,47 @@ static void g_db_bookmark_finalize(GDbBookmark *bookmark) GDbBookmark *g_db_bookmark_new(const vmpa2t *addr, const char *comment) { GDbBookmark *result; /* Instance à retourner */ + bool status; /* Bilan de l'initialisation */ result = g_object_new(G_TYPE_DB_BOOKMARK, NULL); - copy_vmpa(&result->addr, addr); + status = g_db_bookmark_fill(result, addr, comment); + if (!status) goto error; - g_db_bookmark_set_comment(result, comment); + return result; + + error: + + g_object_unref(G_OBJECT(result)); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : bookmark = signet à initialiser. * +* addr = adresse inamovible localisant une position donnée.* +* comment = commentaire construit ou NULL. * +* * +* Description : Initialise la définition d'un signet dans une zone de texte. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_db_bookmark_fill(GDbBookmark *bookmark, const vmpa2t *addr, const char *comment) +{ + bool result; /* Bilan à retourner */ + + result = true; + + copy_vmpa(&bookmark->addr, addr); + + dup_into_rle_string(&bookmark->comment, comment); return result; @@ -601,26 +636,6 @@ const char *g_db_bookmark_get_comment(const GDbBookmark *bookmark) } -/****************************************************************************** -* * -* Paramètres : bookmark = informations à consulter. * -* comment = commentaire construit ou NULL. * -* * -* Description : Définit le commentaire associé à un signet. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_db_bookmark_set_comment(GDbBookmark *bookmark, const char *comment) -{ - dup_into_rle_string(&bookmark->comment, comment); - -} - - /* ---------------------------------------------------------------------------------- */ /* DEFINITION DE LA COLLECTION ASSOCIEE */ diff --git a/src/analysis/db/items/bookmark.h b/src/analysis/db/items/bookmark.h index a8526f7..47a7955 100644 --- a/src/analysis/db/items/bookmark.h +++ b/src/analysis/db/items/bookmark.h @@ -36,12 +36,12 @@ /* --------------------- ELABORATION D'UN ELEMENT DE COLLECTION --------------------- */ -#define G_TYPE_DB_BOOKMARK g_db_bookmark_get_type() -#define G_DB_BOOKMARK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_db_bookmark_get_type(), GDbBookmark)) -#define G_IS_DB_BOOKMARK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_db_bookmark_get_type())) -#define G_DB_BOOKMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DB_BOOKMARK, GDbBookmarkClass)) -#define G_IS_DB_BOOKMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DB_BOOKMARK)) -#define G_DB_BOOKMARK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DB_BOOKMARK, GDbBookmarkClass)) +#define G_TYPE_DB_BOOKMARK g_db_bookmark_get_type() +#define G_DB_BOOKMARK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DB_BOOKMARK, GDbBookmark)) +#define G_IS_DB_BOOKMARK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DB_BOOKMARK)) +#define G_DB_BOOKMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DB_BOOKMARK, GDbBookmarkClass)) +#define G_IS_DB_BOOKMARK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DB_BOOKMARK)) +#define G_DB_BOOKMARK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DB_BOOKMARK, GDbBookmarkClass)) /* Signet à l'intérieur d'une zone de texte (instance) */ @@ -57,26 +57,26 @@ GType g_db_bookmark_get_type(void); /* Crée une définition d'un signet dans une zone de texte. */ GDbBookmark *g_db_bookmark_new(const vmpa2t *, const char *); +/* Initialise la définition d'un signet dans une zone de texte. */ +bool g_db_bookmark_fill(GDbBookmark *, const vmpa2t *, const char *); + /* Fournit l'adresse associée à un signet. */ const vmpa2t *g_db_bookmark_get_address(GDbBookmark *); /* Fournit le commentaire associé à un signet. */ const char *g_db_bookmark_get_comment(const GDbBookmark *); -/* Définit le commentaire associé à un signet. */ -void g_db_bookmark_set_comment(GDbBookmark *, const char *); - /* ---------------------- DEFINITION DE LA COLLECTION ASSOCIEE ---------------------- */ -#define G_TYPE_BM_COLLECTION g_bookmark_collection_get_type() -#define G_BM_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_bookmark_collection_get_type(), GBookmarkCollection)) -#define G_IS_BM_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_bookmark_collection_get_type())) -#define G_BM_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BM_COLLECTION, GBookmarkCollectionClass)) -#define G_IS_BM_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BM_COLLECTION)) -#define G_BM_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BM_COLLECTION, GBookmarkCollectionClass)) +#define G_TYPE_BM_COLLECTION g_bookmark_collection_get_type() +#define G_BM_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BM_COLLECTION, GBookmarkCollection)) +#define G_IS_BM_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_BM_COLLECTION)) +#define G_BM_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BM_COLLECTION, GBookmarkCollectionClass)) +#define G_IS_BM_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BM_COLLECTION)) +#define G_BM_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BM_COLLECTION, GBookmarkCollectionClass)) /* Collection dédiée aux signets (instance) */ |