navid/veins / a56780e67a9f56f836d7eb6b7a3efdaef3293ab43821e75000eda3a2d346ff27 / xveins/src/worktree/attributes.h
attributes.h
← xveins/src/worktree · 1149 bytes · raw · download
#pragma once
#include "core/common.h"
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
namespace vn {
enum class AttributeEol : std::uint8_t {
None = 0,
Lf = 1,
Crlf = 2,
Cr = 3,
};
enum class AttributeText : std::uint8_t {
Auto = 0,
Text = 1,
Binary = 2,
};
struct PathAttributes {
bool generated = false;
AttributeText text = AttributeText::Auto;
AttributeEol eol = AttributeEol::None;
};
class AttributeRules {
public:
static AttributeRules load(const fs::path& root);
PathAttributes lookup(std::string_view path) const;
bool changed_since(std::int64_t cache_written_ms) const;
private:
struct Rule {
std::string pattern;
bool has_slash = false;
bool generated_set = false;
bool generated = false;
bool text_set = false;
AttributeText text = AttributeText::Auto;
bool eol_set = false;
AttributeEol eol = AttributeEol::None;
};
std::vector<Rule> rules_;
std::int64_t mtime_ns_ = 0;
};
std::vector<std::uint8_t> normalize_eol(Bytes data, AttributeEol eol);
} // namespace vn