From 148248846f2bb89cdbb060ef0cefdb56eb1a1bb1 Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Mon, 13 Sep 2021 12:52:49 +0200 Subject: [PATCH] ada_toml 0.3.0 (#343) * ada_toml: minor pasto fix in descriptions * Add ada_toml 0.3.0 --- index/ad/ada_toml/ada_toml-0.1.0.toml | 2 +- index/ad/ada_toml/ada_toml-0.2.0.toml | 2 +- index/ad/ada_toml/ada_toml-0.3.0.toml | 110 ++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 index/ad/ada_toml/ada_toml-0.3.0.toml diff --git a/index/ad/ada_toml/ada_toml-0.1.0.toml b/index/ad/ada_toml/ada_toml-0.1.0.toml index 50966c22..82d50373 100644 --- a/index/ad/ada_toml/ada_toml-0.1.0.toml +++ b/index/ad/ada_toml/ada_toml-0.1.0.toml @@ -1,4 +1,4 @@ -description = "TOML parser for Ada " +description = "TOML parser for Ada" name = "ada_toml" version = "0.1.0" authors = ["AdaCore", "Pierre-Marie de Rodat "] diff --git a/index/ad/ada_toml/ada_toml-0.2.0.toml b/index/ad/ada_toml/ada_toml-0.2.0.toml index f8a98293..f0e64f69 100644 --- a/index/ad/ada_toml/ada_toml-0.2.0.toml +++ b/index/ad/ada_toml/ada_toml-0.2.0.toml @@ -1,4 +1,4 @@ -description = "TOML parser for Ada " +description = "TOML parser for Ada" name = "ada_toml" version = "0.2.0" authors = ["AdaCore", "Pierre-Marie de Rodat "] diff --git a/index/ad/ada_toml/ada_toml-0.3.0.toml b/index/ad/ada_toml/ada_toml-0.3.0.toml new file mode 100644 index 00000000..b4106d63 --- /dev/null +++ b/index/ad/ada_toml/ada_toml-0.3.0.toml @@ -0,0 +1,110 @@ +description = "TOML parser for Ada" +name = "ada_toml" +version = "0.3.0" +authors = ["AdaCore", "Pierre-Marie de Rodat "] +licenses = "BSD-3-Clause" +maintainers = ["pmderodat@kawie.fr"] +maintainers-logins = ["pmderodat"] +project-files = ["ada_toml.gpr"] +long-description = """ +ada-toml: TOML parser for Ada +============================= + +`ada-toml` is a pure Ada library for parsing and creating +[TOML](https://github.com/toml-lang/toml#toml) documents. It conforms to the +[version 1.0.0](https://toml.io/en/v1.0.0) of the format standard. + + +Quick tutorial +-------------- + +All basic types and subprograms are in the `TOML` package. All "nodes" in a +TOML documents are materialized using the `TOML.TOML_Value` type. Since TOML +values make up a tree, this type has reference semantics. This means that +modifying a TOML node does not modify the corresponding `TOML_Value` value +itself, but rather the TOML value that is referenced. + +Parsing a TOML file is as easy as using the `TOML.File_IO.Load_File` function: + +```ada +declare + Result : constant TOML.Read_Result := + TOML.File_IO.Load_File ("config.toml"); +begin + if Result.Success then + Ada.Text_IO.Put_Line ("config.toml loaded with success!"); + else + Ada.Text_IO.Put_Line ("error while loading config.toml:"); + Ada.Text_IO.Put_Line + (Ada.Strings.Unbounded.To_String (Result.Message)); + end if; +end; +``` + +Each TOML value has kind, defining which data it contains (a boolean, an +integer, a string, a table, ...). To each kind, one or several primitives are +associated to let one process the underlying data: + +```ada +case Result.Kind is + when TOML.TOML_Boolean => + Ada.Text_IO.Put_Line ("Boolean: " & Result.As_Boolean'Image); + + when TOML.TOML_Integer => + Ada.Text_IO.Put_Line ("Boolean: " & Result.As_Integer'Image); + + when TOML.TOML_String => + Ada.Text_IO.Put_Line ("Boolean: " & Result.As_String); + + when TOML.TOML_Array => + Ada.Text_IO.Put_Line ("Array of " & Result.Length & " elements"); + + when others => + null; +end case; +``` + +There are also primitives to build TOML values: + +```ada +declare + Bool : constant TOML.TOML_Value := TOML.Create_Boolean (False); + Int : constant TOML.TOML_Value := TOML.Create_Integer (10); + Str : constant TOML.TOML_Value := TOML.Create_String ("Hello, world"); + + Table : constant TOML.TOML_Value := TOML.Create_Table; +begin + Table.Set ("bool_field", Bool); + Table.Set ("int_field", Int); + Table.Set ("str_field", Str); +end; +``` + +And finally one can turn a tree of TOML nodes back in text form: + +```ada +Ada.Text_IO.Put_Line ("TOML document:"); +Ada.Text_IO.Put_Line (Table.Dump_As_String); +``` + + +Contributing +------------ + +The development of `ada-toml` happens on +[GitHub](https://github.com/pmderodat/ada-toml). Everyone is welcome to +contribute to this project: please read our [contribution +rules](https://github.com/pmderodat/ada-toml/tree/master/CONTRIBUTING.rst) if +you consider doing so. +""" + +[gpr-externals] +ADA_TOML_BUILD_MODE = ["dev", "prod"] +LIBRARY_TYPE = ["static", "relocatable", "static-pic"] + +[gpr-set-externals] +ADA_TOML_BUILD_MODE = "prod" + +[origin] +url = "https://github.com/pmderodat/ada-toml/archive/v0.3.tar.gz" +hashes = ["sha512:862d230bf28c393243b01425b259a2fd5d1cf33d3da521eea5f5533691efb46cd3fa335941bcd768b5da635896737b5ee51cbd593d84df58785db6d4c836afd2"]