]> Nishi Git Mirror - dataworks.git/commitdiff
add record value type
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 29 May 2024 02:21:54 +0000 (02:21 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 29 May 2024 02:21:54 +0000 (02:21 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@132 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

FORMATv1.md
Library/database_record.c
Library/dw_database.h
Library/exec.c

index f1f97dca79d8d3a981d0aa0a72d0a9e729d2d7ec..85a0dfd9e06960c2834dabbfb5728d8ae9f2bc06 100644 (file)
@@ -46,7 +46,7 @@ There are 5 types for `indexentry`:
 | ---- | --------- | ---- | ---- |
 | String | `S` | ASCII | |
 | Integer | `I` | int64\_t | |
-| Double | `D` | double | |
+| Floating | `F` | double | |
 | Logical | `L` | uint8\_t | 0 for false, other value for true |
 | Help | `?` | ASCII | Should be just ignored |
 
index e412110e4167a889dd676b7384180ce16628b9db..6efe8308c2fcd35a46ca858e8c174140c110fb78 100644 (file)
@@ -124,7 +124,7 @@ struct dataworks_db_result* dataworks_database_insert_record(struct dataworks_db
                        entsize = strlen(fields[i]);
                } else if(types[i] == DW_RECORD_INTEGER) {
                        entsize = 8;
-               } else if(types[i] == DW_RECORD_DOUBLE) {
+               } else if(types[i] == DW_RECORD_FLOATING) {
                        entsize = sizeof(double);
                } else if(types[i] == DW_RECORD_LOGICAL) {
                        entsize = 1;
index d14d134057964746d5250bb41021f58622fc0237..52c8b2ecf71d32410e5b7a47e9d4110abede4cba 100644 (file)
@@ -187,10 +187,10 @@ enum DW_RECORD_TYPES {
 
        /**
         * @~english
-        * @brief Double
+        * @brief Floating
         *
         */
-       DW_RECORD_DOUBLE = 'D',
+       DW_RECORD_FLOATING = 'F',
 
        /**
         * @~english
@@ -373,6 +373,69 @@ struct dataworks_db_infoentry {
        uint64_t mtime;
 };
 
+/**
+ * @~english
+ * @brief Record value
+ *
+ */
+union dataworks_db_result_value {
+       /**
+        * @~english
+        * @brief Integer
+        *
+        */
+       int64_t integer;
+
+       /**
+        * @~english
+        * @brief Floating
+        *
+        */
+       double floating;
+
+       /**
+        * @~english
+        * @brief String
+        *
+        */
+       char* string;
+
+       /**
+        * @~english
+        * @brief Logical
+        *
+        */
+       uint8_t logical;
+
+       /**
+        * @~english
+        * @brief Help
+        *
+        */
+       char* help;
+};
+
+/**
+ * @~english
+ * @brief Database Record.
+ *
+ */
+struct dataworks_db_record {
+       /**
+        * @~english
+        * @brief Record value
+        *
+        */
+       union dataworks_db_result_value value;
+
+       /**
+        * @~english
+        * @brief Type. See DW_RECORD_TYPES.
+        *
+        */
+       char type;
+};
+
 /**
  * @~english
  * @brief Creates the database.
@@ -545,6 +608,7 @@ struct dataworks_db_result* dataworks_database_insert_record(struct dataworks_db
 
 /**
  * @~english
+ * @brief Select the table.
  * @param db Database
  * @param table Table name
  * @return Result
@@ -554,6 +618,7 @@ int dataworks_database_use_table(struct dataworks_db* db, const char* table);
 
 /**
  * @~english
+ * @brief Get the table count.
  * @param db Database
  * @param table Table name
  * @return Count
@@ -563,6 +628,7 @@ uint64_t dataworks_database_get_table_count(struct dataworks_db* db, const char*
 
 /**
  * @~english
+ * @brief Set the table count.
  * @param db Database
  * @param table Table name
  * @param count Count
index 910ae053b42f391997f95df95fd095be88afe211..d38fc7f787dfb3c88307513f5ce03dcdc5864bd9 100644 (file)
@@ -117,15 +117,15 @@ struct dataworks_db_result* __dataworks_database_execute_code(struct dataworks_d
                                                        if(val[k] == ':') {
                                                                val[k] = 0;
                                                                if(__dw_strcaseequ(val, "string")) {
-                                                                       fieldtypes[argc] = 'S';
+                                                                       fieldtypes[argc] = DW_RECORD_STRING;
                                                                } else if(__dw_strcaseequ(val, "integer")) {
-                                                                       fieldtypes[argc] = 'I';
-                                                               } else if(__dw_strcaseequ(val, "double")) {
-                                                                       fieldtypes[argc] = 'D';
+                                                                       fieldtypes[argc] = DW_RECORD_INTEGER;
+                                                               } else if(__dw_strcaseequ(val, "floating")) {
+                                                                       fieldtypes[argc] = DW_RECORD_FLOATING;
                                                                } else if(__dw_strcaseequ(val, "logical")) {
-                                                                       fieldtypes[argc] = 'L';
+                                                                       fieldtypes[argc] = DW_RECORD_LOGICAL;
                                                                } else if(__dw_strcaseequ(val, "help")) {
-                                                                       fieldtypes[argc] = '?';
+                                                                       fieldtypes[argc] = DW_RECORD_HELP;
                                                                }
                                                                fields[argc] = __dw_strdup(val + k + 1);
                                                                argc++;