You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.3 KiB

12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
  1. #include "branch_tier.hpp"
  2. #include "fmt/core.h"
  3. #include "fs_glob.hpp"
  4. namespace l
  5. {
  6. static
  7. void
  8. load_branch_literal(toml::table const &v_,
  9. std::vector<Branch2> &branches_)
  10. {
  11. branches_.emplace_back(v_);
  12. }
  13. static
  14. void
  15. load_branch_glob(toml::table const &v_,
  16. std::vector<Branch2> &branches_)
  17. {
  18. std::string pattern;
  19. std::vector<std::string> paths;
  20. pattern = v_.at("path").as_string();
  21. fs::glob(pattern,&paths);
  22. auto table = v_;
  23. branches_.resize(branches_.size() + paths.size());
  24. for(auto &path : paths)
  25. {
  26. table["path"] = path;
  27. branches_.emplace_back(table);
  28. }
  29. pause();
  30. }
  31. static
  32. void
  33. load_branch_scan(toml::table const &v_,
  34. std::vector<Branch2> &branches_)
  35. {
  36. }
  37. }
  38. BranchTier::BranchTier()
  39. {
  40. }
  41. BranchTier::BranchTier(toml::value const &v_)
  42. {
  43. auto const &branches = toml::find(v_,"branch").as_array();
  44. for(auto const &branch : branches)
  45. {
  46. std::string type;
  47. auto const &table = branch.as_table();
  48. type = table.at("type").as_string();
  49. if(type == "literal")
  50. l::load_branch_literal(table,_branches);
  51. else if(type == "glob")
  52. l::load_branch_glob(table,_branches);
  53. else if(type == "scan")
  54. l::load_branch_scan(table,_branches);
  55. }
  56. }