| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.99.0/library/toml/NOTES.md |
This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2026 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
toml
The toml library provides predicates for parsing and generating data in
the TOML format:
It includes parametric objects whose parameters allow selecting the
representation for parsed TOML tables (compound or curly), TOML text
strings (atom, chars, or codes) and TOML pairs (dash, equal, or
colon).
Open the [../../apis/library_index.html#toml](../../apis/library_index.html#toml) link in a web browser.
To load all entities in this library, load the loader.lgt file:
| ?- logtalk_load(toml(loader)).
To test this library predicates, load the tester.lgt file:
| ?- logtalk_load(toml(tester)).
The full TOML 1.0.0 data model is covered:
[table] headersinf and nanThe following choices of syntax have been made to represent TOML elements as terms:
toml(Pairs), where Pairs is a list using the selected pair
representation.{Pairs}, where Pairs uses the selected pair representation.chars(List), or codes(List).
The default when decoding is to use atoms when using the toml object. To
decode text strings into lists of chars or codes, use the toml/1 object
with the parameter bound to chars or codes. and @false`.@(inf), @(-inf), and @(nan).
Examples using the default toml object:
| TOML | term |
|---|---|
title = "Example" | toml([title-'Example']) |
point = {x = 1, y = 2} | toml([point-toml([x-1, y-2])]) |
[owner] name = "Tom" | toml([owner-toml([name-'Tom'])]) |
enabled = true | `toml([enabled-@true])` |
limits = [1, 2, 3] | toml([limits-[1,2,3]]) |
|?- toml::parse(atom('title = "Example"\n[owner]\nname = "Tom"\n'), TOML).
TOML = toml([title-'Example', owner-toml([name-'Tom'])]).
| ?- toml(curly,dash,atom)::parse(atom('title = "Example"\n[owner]\nname = "Tom"\n'), TOML).
TOML = {title-'Example', owner-{name-'Tom'}}.
| ?- toml::generate(atom(Atom), toml([title-'Example', owner-toml([name-'Tom'])])).
Atom = 'title = "Example"\n\n[owner]\nname = "Tom"\n'.
Generation is canonical and semantic. The current implementation does not preserve comments, original quoting style, or whether a table was originally written as an inline table or a standard table.