aboutsummaryrefslogtreecommitdiff
path: root/lib/data_types
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2024-03-14 08:26:58 +0100
committerSébastien Dailly <sebastien@dailly.me>2024-03-14 08:26:58 +0100
commit6b377719c10d5ab3343fd5221f99a4a21008e25a (patch)
treea7c1e9a820d339a2f161af3e09cf9e3161286796 /lib/data_types
Initial commitmain
Diffstat (limited to 'lib/data_types')
-rw-r--r--lib/data_types/dune10
-rw-r--r--lib/data_types/path.ml15
-rw-r--r--lib/data_types/readme.rst4
-rw-r--r--lib/data_types/table.ml19
-rw-r--r--lib/data_types/types.ml15
5 files changed, 63 insertions, 0 deletions
diff --git a/lib/data_types/dune b/lib/data_types/dune
new file mode 100644
index 0000000..e38310b
--- /dev/null
+++ b/lib/data_types/dune
@@ -0,0 +1,10 @@
+(library
+ (name importDataTypes)
+ (libraries
+ importCSV
+ )
+
+ (preprocess (pps ppx_deriving.ord))
+ )
+
+
diff --git a/lib/data_types/path.ml b/lib/data_types/path.ml
new file mode 100644
index 0000000..6684b5a
--- /dev/null
+++ b/lib/data_types/path.ml
@@ -0,0 +1,15 @@
+type column = int [@@deriving ord]
+
+type t = {
+ alias : string option;
+ (* External file to load, when the information is missing, load in
+ the current file *)
+ column : column;
+}
+[@@deriving ord]
+
+let repr { alias; column } =
+ let column_text = ImportCSV.Csv.column_to_string column in
+ match alias with
+ | None -> ":" ^ column_text
+ | Some value -> ":" ^ value ^ "." ^ column_text
diff --git a/lib/data_types/readme.rst b/lib/data_types/readme.rst
new file mode 100644
index 0000000..ac609d2
--- /dev/null
+++ b/lib/data_types/readme.rst
@@ -0,0 +1,4 @@
+This module contains all the types used in the application.
+
+It does not depends on any other library, and does not cause any dependency
+cycle.
diff --git a/lib/data_types/table.ml b/lib/data_types/table.ml
new file mode 100644
index 0000000..d807c5c
--- /dev/null
+++ b/lib/data_types/table.ml
@@ -0,0 +1,19 @@
+open StdLabels
+
+type t = {
+ file : string;
+ tab : int;
+ name : string;
+}
+
+(** Get the internal name for the given table.
+
+ This value may differ from the association name given in the configuration. *)
+let name : t -> string =
+ fun source ->
+ let file_name =
+ source.file |> Filename.basename |> Filename.remove_extension
+ in
+ match source.tab with
+ | 1 -> file_name
+ | _ -> String.concat ~sep:"_" [ file_name; string_of_int source.tab ]
diff --git a/lib/data_types/types.ml b/lib/data_types/types.ml
new file mode 100644
index 0000000..37fd90f
--- /dev/null
+++ b/lib/data_types/types.ml
@@ -0,0 +1,15 @@
+type t =
+ | Number
+ | String
+ | Bool
+ | None
+ | Extern
+ | Float
+
+let string_of_t : t -> string = function
+ | Number -> "Number"
+ | String -> "String"
+ | Bool -> "Bool"
+ | None -> "None"
+ | Extern -> "Extern"
+ | Float -> "Float"