MLBookProc 1.1
 
Loading...
Searching...
No Matches
AddBook Class Reference

The AddBook class. More...

#include <AddBook.h>

Public Member Functions

 AddBook (const std::shared_ptr< AuxFunc > &af, const std::string &collection_name, const bool &remove_sources, const std::shared_ptr< BookMarks > &bookmarks)
 AddBook constructor.
 
void simple_add (const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > &books)
 Adds single book files.
 
void simple_add_dir (const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > &books)
 Adds directories containing book files to collection.
 
void overwrite_archive (const std::filesystem::path &archive_path, const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > &books)
 Removes archive from collection and replaces it by new one.
 
void overwrite_archive_dir (const std::filesystem::path &archive_path, const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > &books)
 Removes archive from collection and replaces it by new one.
 
void add_to_existing_archive (const std::filesystem::path &archive_path, const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > &books)
 Adds books to existing archive.
 
void add_to_existing_archive_dir (const std::filesystem::path &archive_path, const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > &books)
 Adds books to existing archive.
 

Static Public Member Functions

static std::vector< std::string > archive_filenames (const std::filesystem::path &archive_path, const std::shared_ptr< AuxFunc > &af)
 Lists all files in archive.
 

Detailed Description

The AddBook class.

AddBook contains various methods to add books to collections.

Constructor & Destructor Documentation

◆ AddBook()

AddBook::AddBook ( const std::shared_ptr< AuxFunc > & af,
const std::string & collection_name,
const bool & remove_sources,
const std::shared_ptr< BookMarks > & bookmarks )

AddBook constructor.

Parameters
afAuxFunc object.
collection_namename of collection book to be added to.
remove_sourcesif true, MLBookProc will remove source file after book has been added.
bookmarksBookMarks object.

Member Function Documentation

◆ add_to_existing_archive()

void AddBook::add_to_existing_archive ( const std::filesystem::path & archive_path,
const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > & books )

Adds books to existing archive.

Unpacks existing archive and packs it again with old and new books inside.

Parameters
archive_pathabsolute path to archive in collection.
booksvector, containing absolute paths to source books files (first tuple element) and relative paths to books in archive (second tuple element).

◆ add_to_existing_archive_dir()

void AddBook::add_to_existing_archive_dir ( const std::filesystem::path & archive_path,
const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > & books )

Adds books to existing archive.

Same as add_to_existing_archive(), but adds directories to existing archive.

Parameters
archive_pathabsolute path to archive in collection.
booksvector, containing absolute paths to source directories (first tuple element) and relative paths to directories in archive (second tuple element).

◆ archive_filenames()

static std::vector< std::string > AddBook::archive_filenames ( const std::filesystem::path & archive_path,
const std::shared_ptr< AuxFunc > & af )
static

Lists all files in archive.

Parameters
archive_pathabsolute path to archive.
afsmart pointer to AuxFunc object.
Returns
Vector containing relative paths of archive files.

◆ overwrite_archive()

void AddBook::overwrite_archive ( const std::filesystem::path & archive_path,
const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > & books )

Removes archive from collection and replaces it by new one.

Removes archive from collection (if it exists) and creates new archive with the same name, containing books from books vector.

Parameters
archive_pathabsolute path to archive file in collection.
booksvector, containing absolute paths to source books files (first tuple element) and relative paths to books files in archive (second tuple element).

◆ overwrite_archive_dir()

void AddBook::overwrite_archive_dir ( const std::filesystem::path & archive_path,
const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > & books )

Removes archive from collection and replaces it by new one.

Same as overwrite_archive(), but creates new archive, containing directories from books vector.

Parameters
archive_pathabsolute path to archive file in collection.
booksvector, containing absolute paths to source directories (first tuple element) and relative paths to directories in archive (second tuple element).

◆ simple_add()

void AddBook::simple_add ( const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > & books)

Adds single book files.

Adds books, listed in vector, to collection and parse them. User must set both paths manually.

Warning
Second tuples paths must not be outside collection books directory.
Parameters
booksvector, containing absolute paths to source files (first tuple element) and absolute paths of books files in collection (second tuple element).

◆ simple_add_dir()

void AddBook::simple_add_dir ( const std::vector< std::tuple< std::filesystem::path, std::filesystem::path > > & books)

Adds directories containing book files to collection.

Same as simple_add(), but adds directories containing books to collection.

Warning
Second tuples paths must not be outside collection books directory.
Parameters
booksvector, containing absolute paths to source directories (first tuple element) and absolute paths of directories in collection (second tuple element).