2024-01-28 22:45:38 -06:00
|
|
|
#include "branch_tier.hpp"
|
|
|
|
|
|
|
|
|
|
#include "fmt/core.h"
|
|
|
|
|
|
2024-01-31 22:18:40 -06:00
|
|
|
#include "fs_glob.hpp"
|
2024-02-01 23:22:58 -06:00
|
|
|
|
2024-02-01 23:22:50 -06:00
|
|
|
#include <cassert>
|
2024-01-31 22:18:40 -06:00
|
|
|
|
2024-01-31 22:18:41 -06:00
|
|
|
|
2024-01-28 23:23:50 -06:00
|
|
|
namespace l
|
|
|
|
|
{
|
|
|
|
|
static
|
|
|
|
|
void
|
2024-01-28 23:31:07 -06:00
|
|
|
load_branch_literal(toml::table const &v_,
|
|
|
|
|
std::vector<Branch2> &branches_)
|
2024-01-28 23:23:50 -06:00
|
|
|
{
|
2024-01-31 21:04:14 -06:00
|
|
|
branches_.emplace_back(v_);
|
2024-01-28 23:23:50 -06:00
|
|
|
}
|
2024-01-28 23:31:30 -06:00
|
|
|
|
|
|
|
|
static
|
|
|
|
|
void
|
|
|
|
|
load_branch_glob(toml::table const &v_,
|
|
|
|
|
std::vector<Branch2> &branches_)
|
|
|
|
|
{
|
2024-02-01 23:16:13 -06:00
|
|
|
toml::table table;
|
2024-01-31 22:17:30 -06:00
|
|
|
std::string pattern;
|
2024-01-31 22:18:26 -06:00
|
|
|
std::vector<std::string> paths;
|
2024-01-28 23:31:31 -06:00
|
|
|
|
2024-01-31 22:17:30 -06:00
|
|
|
pattern = v_.at("path").as_string();
|
2024-01-31 22:18:26 -06:00
|
|
|
fs::glob(pattern,&paths);
|
2024-01-31 22:19:35 -06:00
|
|
|
|
2024-02-01 23:16:18 -06:00
|
|
|
table = v_;
|
2024-02-01 23:15:02 -06:00
|
|
|
branches_.resize(branches_.size() + paths.size());
|
2024-01-31 22:19:35 -06:00
|
|
|
for(auto &path : paths)
|
2024-01-31 22:40:44 -06:00
|
|
|
{
|
|
|
|
|
table["path"] = path;
|
2024-01-31 23:14:55 -06:00
|
|
|
branches_.emplace_back(table);
|
2024-01-31 22:40:44 -06:00
|
|
|
}
|
2024-01-28 23:31:30 -06:00
|
|
|
}
|
2024-01-28 23:31:31 -06:00
|
|
|
|
2024-01-28 23:31:30 -06:00
|
|
|
static
|
|
|
|
|
void
|
|
|
|
|
load_branch_scan(toml::table const &v_,
|
|
|
|
|
std::vector<Branch2> &branches_)
|
|
|
|
|
{
|
2024-02-01 23:28:13 -06:00
|
|
|
printf("foo\n");
|
2024-02-01 23:27:46 -06:00
|
|
|
assert("not currently supported" == NULL);
|
2024-01-28 23:31:31 -06:00
|
|
|
}
|
2024-01-28 23:23:50 -06:00
|
|
|
}
|
|
|
|
|
|
2024-01-28 22:45:38 -06:00
|
|
|
BranchTier::BranchTier()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BranchTier::BranchTier(toml::value const &v_)
|
|
|
|
|
{
|
|
|
|
|
auto const &branches = toml::find(v_,"branch").as_array();
|
|
|
|
|
|
|
|
|
|
for(auto const &branch : branches)
|
|
|
|
|
{
|
2024-01-28 23:31:31 -06:00
|
|
|
std::string type;
|
2024-01-28 22:45:38 -06:00
|
|
|
auto const &table = branch.as_table();
|
|
|
|
|
|
2024-01-28 23:03:45 -06:00
|
|
|
type = table.at("type").as_string();
|
2024-01-28 23:19:24 -06:00
|
|
|
if(type == "literal")
|
2024-01-28 23:29:59 -06:00
|
|
|
l::load_branch_literal(table,_branches);
|
2024-01-28 23:19:24 -06:00
|
|
|
else if(type == "glob")
|
2024-01-28 23:29:59 -06:00
|
|
|
l::load_branch_glob(table,_branches);
|
2024-01-28 23:19:24 -06:00
|
|
|
else if(type == "scan")
|
2024-01-28 23:29:59 -06:00
|
|
|
l::load_branch_scan(table,_branches);
|
2024-01-28 22:45:38 -06:00
|
|
|
}
|
|
|
|
|
}
|