mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +00:00
Complete refactor of project file structure
Fix incorrect handing of default node parameters in SSD subscription. Fix unable to parse some Clash rule-providers (#289). Fix not filtering inline comments in some Surge rulesets. (#285) Add Cron task options. Add clean context option for persisting a JS context across the whole request. Replace JS engine with QuickJS.
This commit is contained in:
88 files changed
+9404
-6356
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#ifndef YAMLCPP_EXTRA_H_INCLUDED
|
||||
#define YAMLCPP_EXTRA_H_INCLUDED
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
template <typename T> void operator >> (const YAML::Node& node, T& i)
|
||||
{
|
||||
if(node.IsDefined() && !node.IsNull()) //fail-safe
|
||||
i = node.as<T>();
|
||||
};
|
||||
|
||||
template <typename T> T safe_as (const YAML::Node& node)
|
||||
{
|
||||
if(node.IsDefined() && !node.IsNull())
|
||||
return node.as<T>();
|
||||
return T();
|
||||
};
|
||||
|
||||
template <typename T> void operator >>= (const YAML::Node& node, T& i)
|
||||
{
|
||||
i = safe_as<T>(node);
|
||||
};
|
||||
|
||||
using string_array = std::vector<std::string>;
|
||||
|
||||
inline std::string dump_to_pairs (const YAML::Node &node, const string_array &exclude = string_array())
|
||||
{
|
||||
std::string result;
|
||||
for(auto iter = node.begin(); iter != node.end(); iter++)
|
||||
{
|
||||
if(iter->second.Type() != YAML::NodeType::Scalar)
|
||||
continue;
|
||||
std::string key = iter->first.as<std::string>();
|
||||
if(std::find(exclude.cbegin(), exclude.cend(), key) != exclude.cend())
|
||||
continue;
|
||||
std::string value = iter->second.as<std::string>();
|
||||
result += key + "=" + value + ",";
|
||||
}
|
||||
return result.erase(result.size() - 1);
|
||||
}
|
||||
|
||||
#endif // YAMLCPP_EXTRA_H_INCLUDED
|
||||
Reference in new issue
Block a user