SVCS - English Documentation
Loading...
Searching...
No Matches
svcs::core Namespace Reference

Core VCS data structures and object model. More...

Classes

class  Blob
 Represents the content of a file (Binary Large Object). More...
class  BranchManager
 Core service for managing version control branches (creation, deletion, switching). More...
class  Commit
 Represents a single, immutable historical point (snapshot) in the repository's history. More...
struct  CommitInfo
 Structure containing essential metadata for a single commit. More...
class  Index
 Manages the Staging Area (Index) of the VCS repository. More...
struct  IndexEntry
 Represents a single file entry in the staging area (Index). More...
class  ObjectStorage
 Manages the version control object database, including persistence and object restoration. More...
class  Repository
 Manages the version control directory structure and core operations. More...
class  RepositoryManager
 Manages all physical file and directory operations within the SVCS repository. More...
class  TestableObject
 Helper class for testing the non-abstract methods of VcsObject. More...
class  Tree
 Represents the state of a directory in the VCS, implementing the VcsObject contract. More...
struct  TreeEntry
 Represents a single item (file or subdirectory) within a Tree object. More...
class  VcsObject
 Abstract base class representing any storable, addressable object within the VCS. More...

Functions

TreeEntry createEntry (std::string name, std::string hash_id)
 Creating tree entry.
std::string read_file_to_string (const fs::path &full_path)
 Reads the entire content of a file into a single std::string.
std::string binary_to_hex_string (const unsigned char *binary_data, size_t length)
 Converts a binary buffer (e.g., a raw SHA-1 hash) into its hexadecimal string representation.
std::string hex_to_binary_string (const std::string &hex_string)
 Converts a hexadecimal string (e.g., 40 chars) into its raw binary byte representation (e.g., 20 bytes).
std::string compute_sha256 (const std::string &input)
 Computes the SHA-256 hash of the given input data.

Variables

const size_t CHUNK_SIZE = 16384
constexpr size_t HASH_BYTE_SIZE = 32

Detailed Description

Core VCS data structures and object model.

Contains fundamental VCS object types like Blob, Tree, Commit that form the building blocks of the version control system.

Function Documentation

◆ binary_to_hex_string()

std::string svcs::core::binary_to_hex_string ( const unsigned char * binary_data,
size_t length )

Converts a binary buffer (e.g., a raw SHA-1 hash) into its hexadecimal string representation.

Parameters
binary_dataPointer to the raw binary data.
lengthThe length of the binary data in bytes (e.g., 20 for SHA-1).
Returns
A std::string containing the hexadecimal representation (e.g., 40 characters for SHA-1).

◆ compute_sha256()

std::string svcs::core::compute_sha256 ( const std::string & input)

Computes the SHA-256 hash of the given input data.

Parameters
inputThe input data to hash.
Returns
std::string The SHA-256 hash as a hexadecimal string.

◆ createEntry()

TreeEntry svcs::core::createEntry ( std::string name,
std::string hash_id )

Creating tree entry.

Returns
Returns finished TreeEntry.
Parameters
nameName of file or subdirectory.
hash_idThe hash ID (SHA-256).

◆ hex_to_binary_string()

std::string svcs::core::hex_to_binary_string ( const std::string & hex_string)

Converts a hexadecimal string (e.g., 40 chars) into its raw binary byte representation (e.g., 20 bytes).

Parameters
hex_stringThe input hexadecimal string. Must have an even length.
Returns
A std::string containing the raw binary bytes.
Exceptions
std::runtime_errorif the input string has an odd length or contains invalid hex characters.

◆ read_file_to_string()

std::string svcs::core::read_file_to_string ( const fs::path & full_path)

Reads the entire content of a file into a single std::string.

This utility function is designed for reading small to medium-sized files and is crucial for creating VcsObject contents (e.g., Blobs). It opens the file in binary mode to ensure all characters are read correctly across platforms.

Parameters
full_pathThe full, absolute path to the file on disk.
Returns
The entire content of the file as a single std::string.
Exceptions
std::runtime_errorIf the file cannot be opened for reading.