138 std::vector<TreeEntry> entries;
152 explicit Tree(std::vector<TreeEntry> entries);
166 [[nodiscard]] std::string
getType()
const override;
180 [[nodiscard]] std::string
serialize()
const override;
232 [[nodiscard]] std::optional<TreeEntry>
findEntry(
const std::string& name)
const;
243 [[nodiscard]]
const std::vector<TreeEntry>&
getEntries()
const;
Definition of the abstract base class for all Version Control System objects.
Represents the state of a directory in the VCS, implementing the VcsObject contract.
Definition Tree.hxx:84
void addEntry(const TreeEntry &entry)
Adds a new entry to the Tree or updates an existing entry if the name matches.
Definition Tree.cxx:107
Tree(std::vector< TreeEntry > entries)
Constructor for the Tree object.
Definition Tree.cxx:29
const std::vector< TreeEntry > & getEntries() const
Returns the list of entries stored in the Tree.
Definition Tree.cxx:146
bool removeEntry(const std::string &name)
Removes an entry (file or subdirectory) from the Tree by name.
Definition Tree.cxx:119
std::string getType() const override
Returns the type of the VCS object.
Definition Tree.cxx:130
std::optional< TreeEntry > findEntry(const std::string &name) const
Searches for a specific entry within the Tree by name.
Definition Tree.cxx:134
static Tree deserialize(const std::string &raw_content)
Creates a Tree object from a serialized string read from the object database.
Definition Tree.cxx:61
std::string serialize() const override
Serializes the Tree content into a standardized string format for hashing and storage.
Definition Tree.cxx:45
Abstract base class representing any storable, addressable object within the VCS.
Definition VcsObject.hxx:33
Core VCS data structures and object model.
TreeEntry createEntry(std::string name, std::string hash_id)
Creating tree entry.
Definition Tree.cxx:25
Represents a single item (file or subdirectory) within a Tree object.
Definition Tree.hxx:34
std::string type
The type of the referenced object ("blob" or "tree").
Definition Tree.hxx:57
std::string name
The name of the file or subdirectory.
Definition Tree.hxx:45
std::string mode
File mode (permissions) and type identifier (e.g., "100644" for a blob, "040000" for a tree).
Definition Tree.hxx:39
bool operator<(const TreeEntry &other) const
Comparison operator required for sorting.
Definition Tree.cxx:21
std::string hash_id
The hash ID (SHA-256) of the referenced object (Blob or Tree).
Definition Tree.hxx:51