Skip to content

Commit

Permalink
Fix deprecations, update version in code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kripth committed Aug 11, 2021
1 parent a806807 commit aa09903
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.dub/
.idea
.dub
*.sln
*.exe
*.obj
*.dproj
*.sln
*.userprefs
*.lst
*.lib
Expand Down
2 changes: 1 addition & 1 deletion src/toml/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
*
* Tom's Obvious, Minimal Language (v0.4.0).
* Tom's Obvious, Minimal Language (v1.0.0).
*
* License: $(HTTP https://github.com/Kripth/toml/blob/master/LICENSE, MIT)
* Authors: Kripth
Expand Down
23 changes: 12 additions & 11 deletions src/toml/toml.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
*
* Tom's Obvious, Minimal Language (v0.4.0).
* Tom's Obvious, Minimal Language (v1.0.0).
*
* License: $(HTTP https://github.com/Kripth/toml/blob/master/LICENSE, MIT)
* Authors: Kripth
Expand Down Expand Up @@ -144,47 +144,47 @@ struct TOMLValue {
/**
* Throws: TOMLException if type is not TOML_TYPE.OFFSET_DATETIME
*/
public @property ref SysTime offsetDatetime() {
public @property ref SysTime offsetDatetime() return {
enforce!TOMLException(this.type == TOML_TYPE.OFFSET_DATETIME, "TOMLValue is not an offset datetime");
return this.store.offsetDatetime;
}

/**
* Throws: TOMLException if type is not TOML_TYPE.LOCAL_DATETIME
*/
public @property @trusted ref DateTime localDatetime() {
public @property @trusted ref DateTime localDatetime() return {
enforce!TOMLException(this._type == TOML_TYPE.LOCAL_DATETIME, "TOMLValue is not a local datetime");
return this.store.localDatetime;
}

/**
* Throws: TOMLException if type is not TOML_TYPE.LOCAL_DATE
*/
public @property @trusted ref Date localDate() {
public @property @trusted ref Date localDate() return {
enforce!TOMLException(this._type == TOML_TYPE.LOCAL_DATE, "TOMLValue is not a local date");
return this.store.localDate;
}

/**
* Throws: TOMLException if type is not TOML_TYPE.LOCAL_TIME
*/
public @property @trusted ref TimeOfDay localTime() {
public @property @trusted ref TimeOfDay localTime() return {
enforce!TOMLException(this._type == TOML_TYPE.LOCAL_TIME, "TOMLValue is not a local time");
return this.store.localTime;
}

/**
* Throws: TOMLException if type is not TOML_TYPE.ARRAY
*/
public @property @trusted ref TOMLValue[] array() {
public @property @trusted ref TOMLValue[] array() return {
enforce!TOMLException(this._type == TOML_TYPE.ARRAY, "TOMLValue is not an array");
return this.store.array;
}

/**
* Throws: TOMLException if type is not TOML_TYPE.TABLE
*/
public @property @trusted ref TOMLValue[string] table() {
public @property @trusted ref TOMLValue[string] table() return {
enforce!TOMLException(this._type == TOML_TYPE.TABLE, "TOMLValue is not a table");
return this.store.table;
}
Expand Down Expand Up @@ -940,7 +940,8 @@ unittest {
assert(doc["database"]["ports"] == [8001, 8001, 8002]);
assert(doc["database"]["connection_max"] == 5000);
assert(doc["database"]["enabled"] == true);
//TODO
assert(doc["servers"]["alpha"]["ip"] == "10.0.0.1");
assert(doc["servers"]["alpha"]["dc"] == "eqdc10");
assert(doc["clients"]["data"][0] == ["gamma", "delta"]);
assert(doc["clients"]["data"][1] == [1, 2]);
assert(doc["clients"]["hosts"] == ["alpha", "omega"]);
Expand All @@ -953,7 +954,7 @@ unittest {
assert(doc["key"].type == TOML_TYPE.STRING);
assert(doc["key"].str == "value");

foreach (k, v; doc) {
foreach(k, v; doc) {
assert(k == "key");
assert(v.type == TOML_TYPE.STRING);
assert(v.str == "value");
Expand Down Expand Up @@ -1520,8 +1521,8 @@ trimmed in raw strings.
immutable table = TOMLValue(["a": 0, "b": 1]).toString();
assert(table == "{ a = 0, b = 1 }" || table == "{ b = 1, a = 0 }");

foreach(key, value; TOMLValue(["0": 0, "1": 1])) {
assert(value == key.to!int);
foreach(k, v; TOMLValue(["0": 0, "1": 1])) {
assert(v == k.to!int);
}

value = 42;
Expand Down

0 comments on commit aa09903

Please sign in to comment.