tomlplusplus/examples/example.toml
Mark Gillard de07ba7187 string value serialization now emits literals where possible (closes #43)
also added support for wide strings on Windows (closes #42):
- added wide-string path arg overloads of `parse()` and `parse_file()`
- added wide-string support to all relevant `table` and `array` ops
- added `std::wstring` support to `node::value()` and `node::value_or()`
- added `std::wstring` support to `node_view::value()` and `node_view::value_or()`
- added wide-string overloads of `table::operator[]`
- added wide-string overloads of `node_view::operator[]`
- added `source_region::wide_path()`
- added `TOML_WINDOWS_COMPAT` switch for explicitly enabling/disabling this stuff

also:
- fixed internal macro `assert_or_assume` leaking out of `toml_parser.hpp`
- deprecated `node_view::get()` in favour of `node_view::node()`
- minor documentation fixes
- minor cleanup
2020-07-14 20:50:24 +03:00

103 lines
1.8 KiB
TOML

# This is a TOML document. Boom.
title = "TOML Example"
# plain signed integers
int1 = -9223372036854775808
int2 = 9223372036854775807
# floats
flt1 = 0.00000000001
flt2 = 1e-11
flt3 = 11.0
flt4 = +1.0
# hexadecimal with prefix `0x`
hex1 = 0xDEADBEEF
hex2 = 0xdeadbeef
hex3 = 0xdead_beef
# octal with prefix `0o`
oct1 = 0o01234567
oct2 = 0o755 # useful for Unix file permissions
# binary with prefix `0b`
bin1 = 0b11010110 # 214
# local dates and times
tim1 = 07:32:00
tim2 = 00:32:00.100000000
dat1 = 1979-05-27
# offset date-times
odt1 = 1979-05-27T07:32:00Z
odt2 = 1979-05-27T00:32:00-07:00
odt3 = 1979-05-27T00:32:00.999999-07:00
# strings
str1 = """
This is a
multi-line
string.
"""
str2 = "This is also\na multi-line\nstring."
str3 = 'C:\highway\to\the\danger\zone'
kosme = "κόσμε" # unicode!
arr = [ 'this', 'is', 'a', 'long', 'array', 'with', 16, 'elements.', 'it', 'should', 'be', 'printed', 'as', 'a', 'multiline', 'array.']
tab = { this = 'is', an = 'inline', table = 'yay'}
dotted.keys.are = "supported"
dotted.and = "implemented as tables"
[owner]
name = "Mark Gillard"
dob = 1987-03-16 10:20:00+09:30
[[owner.pets]]
name = "Brian"
species = "cat"
[[owner.pets]]
name = "Skippy"
species = "kangaroo"
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8002 ]
connection_max = 5000
enabled = true
[servers]
# You can indent as you please. Tabs or spaces. TOML don't care.
[servers.alpha]
ip = "10.0.0.1"
dc = "eqdc10"
[servers.beta]
ip = "10.0.0.2"
dc = "eqdc10"
country = "中国" # This should be parsed as UTF-8
[clients]
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
# Line breaks are OK when inside arrays
hosts = [
"alpha",
"omega"
]
# Products
[[products]]
name = "Hammer"
sku = 738594937
[[products]]
name = "Nail"
sku = 284758393
color = "gray"