Skip to content

Commit 6911937

Browse files
committed
Update toml11 to v4.3.0
1 parent 05959b0 commit 6911937

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

scripts/build.alpine.release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cmake -DCMAKE_BUILD_TYPE=Release .
3434
make libcron install -j3
3535
cd ..
3636

37-
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
37+
git clone https://github.com/ToruNiina/toml11 --branch="v4.3.0" --depth=1
3838
cd toml11
3939
cmake -DCMAKE_CXX_STANDARD=11 .
4040
make install -j4

scripts/build.macos.release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sudo install -d /usr/local/include/date/
4141
sudo install -m644 libcron/externals/date/include/date/* /usr/local/include/date/
4242
cd ..
4343

44-
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
44+
git clone https://github.com/ToruNiina/toml11 --branch="v4.3.0" --depth=1
4545
cd toml11
4646
cmake -DCMAKE_CXX_STANDARD=11 .
4747
sudo make install -j6 > /dev/null

scripts/build.windows.release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cmake -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD
3838
make install -j4
3939
cd ..
4040

41-
git clone https://github.com/ToruNiina/toml11 --branch v3.8.1 --depth=1
41+
git clone https://github.com/ToruNiina/toml11 --branch "v4.3.0" --depth=1
4242
cd toml11
4343
cmake -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=11 .
4444
make install -j4

src/config/binding.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ namespace toml
1717
static ProxyGroupConfig from_toml(const value& v)
1818
{
1919
ProxyGroupConfig conf;
20-
conf.Name = toml::find<String>(v, "name");
21-
String type = toml::find<String>(v, "type");
22-
String strategy = toml::find_or<String>(v, "strategy", "");
20+
conf.Name = find<String>(v, "name");
21+
String type = find<String>(v, "type");
22+
String strategy = find_or<String>(v, "strategy", "");
2323
switch(hash_(type))
2424
{
2525
case "select"_hash:
2626
conf.Type = ProxyGroupType::Select;
2727
break;
2828
case "url-test"_hash:
2929
conf.Type = ProxyGroupType::URLTest;
30-
conf.Url = toml::find<String>(v, "url");
31-
conf.Interval = toml::find<Integer>(v, "interval");
32-
conf.Tolerance = toml::find_or<Integer>(v, "tolerance", 0);
30+
conf.Url = find<String>(v, "url");
31+
conf.Interval = find<Integer>(v, "interval");
32+
conf.Tolerance = find_or<Integer>(v, "tolerance", 0);
3333
if(v.contains("lazy"))
34-
conf.Lazy = toml::find_or<bool>(v, "lazy", false);
34+
conf.Lazy = find_or<bool>(v, "lazy", false);
3535
if(v.contains("evaluate-before-use"))
36-
conf.EvaluateBeforeUse = toml::find_or(v, "evaluate-before-use", conf.EvaluateBeforeUse.get());
36+
conf.EvaluateBeforeUse = find_or(v, "evaluate-before-use", conf.EvaluateBeforeUse.get());
3737
break;
3838
case "load-balance"_hash:
3939
conf.Type = ProxyGroupType::LoadBalance;
40-
conf.Url = toml::find<String>(v, "url");
41-
conf.Interval = toml::find<Integer>(v, "interval");
40+
conf.Url = find<String>(v, "url");
41+
conf.Interval = find<Integer>(v, "interval");
4242
switch(hash_(strategy))
4343
{
4444
case "consistent-hashing"_hash:
@@ -49,14 +49,14 @@ namespace toml
4949
break;
5050
}
5151
if(v.contains("persistent"))
52-
conf.Persistent = toml::find_or(v, "persistent", conf.Persistent.get());
52+
conf.Persistent = find_or(v, "persistent", conf.Persistent.get());
5353
break;
5454
case "fallback"_hash:
5555
conf.Type = ProxyGroupType::Fallback;
56-
conf.Url = toml::find<String>(v, "url");
57-
conf.Interval = toml::find<Integer>(v, "interval");
56+
conf.Url = find<String>(v, "url");
57+
conf.Interval = find<Integer>(v, "interval");
5858
if(v.contains("evaluate-before-use"))
59-
conf.EvaluateBeforeUse = toml::find_or(v, "evaluate-before-use", conf.EvaluateBeforeUse.get());
59+
conf.EvaluateBeforeUse = find_or(v, "evaluate-before-use", conf.EvaluateBeforeUse.get());
6060
break;
6161
case "relay"_hash:
6262
conf.Type = ProxyGroupType::Relay;
@@ -66,24 +66,24 @@ namespace toml
6666
break;
6767
case "smart"_hash:
6868
conf.Type = ProxyGroupType::Smart;
69-
conf.Url = toml::find<String>(v, "url");
70-
conf.Interval = toml::find<Integer>(v, "interval");
71-
conf.Tolerance = toml::find_or<Integer>(v, "tolerance", 0);
69+
conf.Url = find<String>(v, "url");
70+
conf.Interval = find<Integer>(v, "interval");
71+
conf.Tolerance = find_or<Integer>(v, "tolerance", 0);
7272
if(v.contains("lazy"))
73-
conf.Lazy = toml::find_or<bool>(v, "lazy", false);
73+
conf.Lazy = find_or<bool>(v, "lazy", false);
7474
if(v.contains("evaluate-before-use"))
75-
conf.EvaluateBeforeUse = toml::find_or(v, "evaluate-before-use", conf.EvaluateBeforeUse.get());
75+
conf.EvaluateBeforeUse = find_or(v, "evaluate-before-use", conf.EvaluateBeforeUse.get());
7676
break;
7777
default:
78-
throw toml::syntax_error("Proxy Group has incorrect type, should be one of following:\n select, url-test, load-balance, fallback, relay, ssid", v.at("type").location());
78+
throw serialization_error(format_error("Proxy Group has unsupported type!", v.at("type").location(), "should be one of following: select, url-test, load-balance, fallback, relay, ssid"), v.at("type").location());
7979
}
80-
conf.Timeout = toml::find_or(v, "timeout", 5);
81-
conf.Proxies = toml::find_or<StrArray>(v, "rule", {});
82-
conf.UsingProvider = toml::find_or<StrArray>(v, "use", {});
80+
conf.Timeout = find_or(v, "timeout", 5);
81+
conf.Proxies = find_or<StrArray>(v, "rule", {});
82+
conf.UsingProvider = find_or<StrArray>(v, "use", {});
8383
if(conf.Proxies.empty() && conf.UsingProvider.empty())
84-
throw toml::syntax_error("Proxy Group must contains at least one of proxy match rule or provider", v.location());
84+
throw serialization_error(format_error("Proxy Group must contains at least one of proxy match rule or provider!", v.location(), "here"), v.location());
8585
if(v.contains("disable-udp"))
86-
conf.DisableUdp = toml::find_or(v, "disable-udp", conf.DisableUdp.get());
86+
conf.DisableUdp = find_or(v, "disable-udp", conf.DisableUdp.get());
8787
return conf;
8888
}
8989
};
@@ -94,8 +94,8 @@ namespace toml
9494
static RulesetConfig from_toml(const value& v)
9595
{
9696
RulesetConfig conf;
97-
conf.Group = toml::find<String>(v, "group");
98-
String type = toml::find_or<String>(v, "type", "surge-ruleset");
97+
conf.Group = find<String>(v, "group");
98+
String type = find_or<String>(v, "type", "surge-ruleset");
9999
switch(hash_(type))
100100
{
101101
/*
@@ -132,10 +132,10 @@ namespace toml
132132
conf.Url = type + ":";
133133
break;
134134
default:
135-
throw toml::syntax_error("Ruleset has incorrect type, should be one of following:\n surge-ruleset, quantumultx, clash-domain, clash-ipcidr, clash-classic", v.at("type").location());
135+
throw serialization_error(format_error("Ruleset has unsupported type!", v.at("type").location(), "should be one of following: surge-ruleset, quantumultx, clash-domain, clash-ipcidr, clash-classic"), v.at("type").location());
136136
}
137-
conf.Url += toml::find<String>(v, "ruleset");
138-
conf.Interval = toml::find_or<Integer>(v, "interval", 86400);
137+
conf.Url += find<String>(v, "ruleset");
138+
conf.Interval = find_or<Integer>(v, "interval", 86400);
139139
return conf;
140140
}
141141
};
@@ -148,14 +148,14 @@ namespace toml
148148
RegexMatchConfig conf;
149149
if(v.contains("script"))
150150
{
151-
conf.Script = toml::find<String>(v, "script");
151+
conf.Script = find<String>(v, "script");
152152
return conf;
153153
}
154-
conf.Match = toml::find<String>(v, "match");
154+
conf.Match = find<String>(v, "match");
155155
if(v.contains("emoji"))
156-
conf.Replace = toml::find<String>(v, "emoji");
156+
conf.Replace = find<String>(v, "emoji");
157157
else
158-
conf.Replace = toml::find<String>(v, "replace");
158+
conf.Replace = find<String>(v, "replace");
159159
return conf;
160160
}
161161
};
@@ -166,10 +166,10 @@ namespace toml
166166
static CronTaskConfig from_toml(const value& v)
167167
{
168168
CronTaskConfig conf;
169-
conf.Name = toml::find<String>(v, "name");
170-
conf.CronExp = toml::find<String>(v, "cronexp");
171-
conf.Path = toml::find<String>(v, "path");
172-
conf.Timeout = toml::find_or<Integer>(v, "timeout", 0);
169+
conf.Name = find<String>(v, "name");
170+
conf.CronExp = find<String>(v, "cronexp");
171+
conf.Path = find<String>(v, "path");
172+
conf.Timeout = find_or<Integer>(v, "timeout", 0);
173173
return conf;
174174
}
175175
};

src/handler/settings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,13 @@ void readYAMLConf(YAML::Node &node)
567567
}
568568

569569
template <class T, class... U>
570-
void find_if_exist(const toml::value &v, const toml::key &k, T& target, U&&... args)
570+
void find_if_exist(const toml::value &v, const toml::value::key_type &k, T& target, U&&... args)
571571
{
572572
if(v.contains(k)) target = toml::find<T>(v, k);
573573
if constexpr (sizeof...(args) > 0) find_if_exist(v, std::forward<U>(args)...);
574574
}
575575

576-
void operate_toml_kv_table(const std::vector<toml::table> &arr, const toml::key &key_name, const toml::key &value_name, std::function<void (const toml::value&, const toml::value&)> binary_op)
576+
void operate_toml_kv_table(const std::vector<toml::table> &arr, const toml::value::key_type &key_name, const toml::value::key_type &value_name, std::function<void (const toml::value&, const toml::value&)> binary_op)
577577
{
578578
for(const toml::table &table : arr)
579579
{
@@ -803,7 +803,7 @@ void readConf()
803803
return readYAMLConf(yaml);
804804
}
805805
toml::value conf = parseToml(prefdata, global.prefPath);
806-
if(!conf.is_uninitialized() && toml::find_or<int>(conf, "version", 0))
806+
if(!conf.is_empty() && toml::find_or<int>(conf, "version", 0))
807807
return readTOMLConf(conf);
808808
}
809809
catch (YAML::Exception &e)
@@ -1213,7 +1213,7 @@ int loadExternalConfig(std::string &path, ExternalConfig &ext)
12131213
if(yaml.size() && yaml["custom"].IsDefined())
12141214
return loadExternalYAML(yaml, ext);
12151215
toml::value conf = parseToml(base_content, path);
1216-
if(!conf.is_uninitialized() && toml::find_or<int>(conf, "version", 0))
1216+
if(!conf.is_empty() && toml::find_or<int>(conf, "version", 0))
12171217
return loadExternalTOML(conf, ext);
12181218
}
12191219
catch (YAML::Exception &e)

0 commit comments

Comments
 (0)