summaryrefslogtreecommitdiff
path: root/src/analysis/db/items/comment.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-25 22:20:25 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-25 22:20:25 (GMT)
commit6ed1e4110eb19b78f76154aa095a74414531f04c (patch)
treed1c3562cb6e180baff3c388a3bb3574b0a02213b /src/analysis/db/items/comment.c
parent3dc843b3f7991dcd738a30821ff56c7fe13f1094 (diff)
Prepared history for database items.
Diffstat (limited to 'src/analysis/db/items/comment.c')
-rw-r--r--src/analysis/db/items/comment.c78
1 files changed, 11 insertions, 67 deletions
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index a987464..a231749 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -183,9 +183,6 @@ static void g_comment_collection_finalize(GCommentCollection *);
/* Crée la table des commentaires dans une base de données. */
static bool g_comment_collection_create_db_table(const GCommentCollection *, sqlite3 *);
-/* Décrit les colonnes utiles à un chargement de données. */
-static bool g_comment_collection_setup_load(GCommentCollection *, bound_value **, size_t *);
-
/* Détermine si un élément est déjà présent ou non. */
static GDbItem *g_comment_collection_has_key(GCommentCollection *, va_list);
@@ -995,7 +992,7 @@ static bool g_db_comment_load(GDbComment *comment, const bound_value *values, si
if (result)
{
- value = find_bound_value(values, count, "flags");
+ value = find_bound_value(values, count, "lflags");
result = (value != NULL && value->type == SQLITE_INTEGER);
if (result)
@@ -1072,16 +1069,20 @@ static bool g_db_comment_store(GDbComment *comment, bound_value **values, size_t
value = &(*values)[*count - 1];
- value->cname = "flags";
+ value->cname = "lflags";
value->built_name = false;
value->type = SQLITE_INTEGER;
- value->integer = comment->flags;
- value->delete = NULL;
value->has_value = (comment != NULL);
if (value->has_value)
{
+ value->integer = comment->flags;
+ value->delete = NULL;
+ }
+
+ if (value->has_value)
+ {
init_dynamic_rle_string(&text, g_db_comment_get_text(comment));
status = store_rle_string(&text, "text", values, count);
exit_rle_string(&text);
@@ -1514,7 +1515,6 @@ static void g_comment_collection_class_init(GCommentCollectionClass *klass)
collec = G_DB_COLLECTION_CLASS(klass);
collec->create_table = (collec_create_db_table_fc)g_comment_collection_create_db_table;
- collec->setup_load = (collec_setup_load_fc)g_comment_collection_setup_load;
collec->has_key = (collec_has_key_fc)g_comment_collection_has_key;
}
@@ -1626,7 +1626,7 @@ static bool g_comment_collection_create_db_table(const GCommentCollection *colle
sql = "CREATE TABLE Comments (" \
SQLITE_DB_ITEM_CREATE ", " \
"%s, " \
- "flags INTEGER, " \
+ "lflags INTEGER, " \
SQLITE_RLESTR_CREATE("text") ", " \
"inlined INTEGER, " \
"repeatable INTEGER" \
@@ -1655,64 +1655,6 @@ static bool g_comment_collection_create_db_table(const GCommentCollection *colle
/******************************************************************************
* *
* Paramètres : collec = ensemble d'éléments à consulter. *
-* values = tableau d'éléments à compléter. [OUT] *
-* count = nombre de descriptions renseignées. [OUT] *
-* *
-* Description : Décrit les colonnes utiles à un chargement de données. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_comment_collection_setup_load(GCommentCollection *collec, bound_value **values, size_t *count)
-{
- bool status; /* Bilan d'une préparation */
- bound_value *value; /* Valeur à éditer / définir */
-
- status = G_DB_COLLECTION_CLASS(g_comment_collection_parent_class)->setup_load(G_DB_COLLECTION(collec), \
- values, count);
- if (!status) return false;
-
- if (!store_vmpa(NULL, NULL, values, count))
- return false;
-
- *count += 1;
- *values = realloc(*values, *count * sizeof(bound_value));
-
- value = &(*values)[*count - 1];
-
- value->cname = "flags";
- value->built_name = false;
- value->type = SQLITE_INTEGER;
-
- if (!store_rle_string(NULL, "text", values, count))
- return false;
-
- *count += 2;
- *values = realloc(*values, *count * sizeof(bound_value));
-
- value = &(*values)[*count - 2];
-
- value->cname = "inlined";
- value->built_name = false;
- value->type = SQLITE_BOOLEAN;
-
- value = &(*values)[*count - 1];
-
- value->cname = "repeatable";
- value->built_name = false;
- value->type = SQLITE_BOOLEAN;
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : collec = ensemble d'éléments à consulter. *
* ap = clef identifiant de manière unique un élément. *
* *
* Description : Détermine si un élément est déjà présent ou non. *
@@ -1735,6 +1677,7 @@ static GDbItem *g_comment_collection_has_key(GCommentCollection *collec, va_list
ref = va_arg(ap, vmpa2t *);
+#if 0
items = g_db_collection_get_items(G_DB_COLLECTION(collec));
for (iter = g_list_first(items); iter != NULL && result == NULL; iter = g_list_next(iter))
@@ -1751,6 +1694,7 @@ static GDbItem *g_comment_collection_has_key(GCommentCollection *collec, va_list
result = G_DB_ITEM(bm);
}
+#endif
return result;