CONZEPT 16 C++ API
C16::BinaryDirectory Class Reference

Binary directory buffer to operate on binary directories. More...

#include "C16/Binary.hpp"

Inheritance diagram for C16::BinaryDirectory:
C16::Binary

Detailed Description

Binary directory buffer to operate on binary directories.

Public Member Functions

 BinaryDirectory ()
 Constructs a binary directory buffer. More...
 
Result read (const BinaryDirectory &directory, const std::string &name, Place place=Place::KEY, Locking locking=Locking::NONE) override
 Reads a binary by means of a base binary directory, a reference name and a place into the binary buffer. More...
 
Result read (const BinaryDirectory &directory, Place place, Locking locking=Locking::NONE) override
 Reads a binary by means of a base binary directory and a place into the binary buffer. More...
 
Result read (const BinaryDirectory &directory, const std::string &path, Locking locking=Locking::LOCK_SHARED) override
 Reads a binary by means of a base binary directory and a path into the binary buffer. More...
 
void unload () override
 Unloads the loaded binary. More...
 
Result write () const override
 Writes the loaded binary. More...
 
Result create (const BinaryDirectory &directory, const std::string &path, Locking locking=Locking::LOCK_SHARED, bool overwrite=false) override
 Creates and loads a binary. More...
 
Result erase_directory (const std::string &path) const
 Deletes a binary directory within the loaded binary directory. More...
 
Result erase_object (const std::string &path) const
 Deletes a binary object within the loaded binary directory. More...
 
Result clear_object (const std::string &path) const
 Clears a binary object within the loaded binary directory. More...
 
- Public Member Functions inherited from C16::Binary
const Databasedatabase () const
 Gets the database of the loaded binary. More...
 
Databasedatabase ()
 Gets the database of the loaded binary. More...
 
bool loaded () const
 Gets if a binary is loaded into the binary buffer. More...
 
bool locked () const
 Gets if the loaded binary is locked by the user accessing the database. More...
 
long long int id () const
 Gets the id of the loaded binary. More...
 
const std::string & name () const
 Gets the name of the loaded binary. More...
 
const std::string & path () const
 Gets the path of the loaded binary. More...
 
const std::string & custom () const
 Gets the custom property of the loaded binary. More...
 
virtual void custom_set (const std::string &custom)
 Sets the custom property of the loaded binary. More...
 
virtual Result rename (const std::string &name)
 Renames the loaded binary. More...
 
virtual Result move_to (const BinaryDirectory &directory)
 Moves the loaded binary to another directory. More...
 

Additional Inherited Members

- Public Types inherited from C16::Binary
enum  Error { Error::CONTENT_EMPTY = 1, Error::CIPHER_KEY_INCORRECT, Error::OPERATION_UNAVAILABLE }
 Error of an operation on a binary. More...
 
- Static Public Attributes inherited from C16::Binary
static const int NAME_LENGTH_LIMIT = 60
 Name length limit. More...
 
static const int CUSTOM_LENGTH_LIMIT = 255
 Custom property length limit. More...
 

Constructor & Destructor Documentation

◆ BinaryDirectory()

C16::BinaryDirectory::BinaryDirectory ( )

Constructs a binary directory buffer.

Member Function Documentation

◆ read() [1/3]

Result C16::BinaryDirectory::read ( const BinaryDirectory directory,
const std::string &  name,
Place  place = Place::KEY,
Locking  locking = Locking::NONE 
)
overridevirtual

Reads a binary by means of a base binary directory, a reference name and a place into the binary buffer.

Parameters
directoryBase binary directory buffer
nameReference name (case insensitive, 0 to NAME_LENGTH_LIMIT characters)
placePlace of the binary
Place::KEYReads the binary with the same name as the reference name.
Place::NEXTReads the binary with the name following the reference name.
Place::PREVIOUSReads the binary with the name preceding the reference name.
lockingLocking to apply to the binary
Locking::NONEDoes not lock the binary.
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the binary.
Locking::LOCK_SINGLEApplies an exclusive, singulary lock to the binary.
Locking::LOCK_SHAREDApplies a shared lock to the binary.
Returns
Result
Return values
Result::OKBinary loaded and locking applied.
Result::LOCKEDBinary already locked. No binary loaded.
Result::NO_RECBinary inexistent or base binary directory buffer not loaded.
Result::NO_LOCKBase binary directory not locked.
Exceptions
Exception::InvalidityName invalid.
Exception::InvalidityPlace invalid.
Exception::InvalidityLocking invalid.
ExceptionOperation unavailable.
This is a root directory.
Note
Binaries are ordered by name (lexographicaly).

Implements C16::Binary.

◆ read() [2/3]

Result C16::BinaryDirectory::read ( const BinaryDirectory directory,
Place  place,
Locking  locking = Locking::NONE 
)
overridevirtual

Reads a binary by means of a base binary directory and a place into the binary buffer.

Parameters
directoryBase binary directory buffer
placePlace of the binary
Place::FIRSTReads the first binary.
Place::LASTReads the last binary.
Place::NEXTReads the binary with the name following the name of the loaded binary.
Place::PREVIOUSReads binary text with the name preceding the name of the loaded binary.
lockingLock to apply to the binary
Locking::NONEDoes not lock the binary.
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the binary.
Locking::LOCK_SINGLEApplies an exclusive, singulary lock to the binary.
Locking::LOCK_SHAREDApplies a shared lock to the binary.
Returns
Result
Return values
Result::OKBinary loaded and locking applied.
Result::LOCKEDBinary already locked. No binary loaded.
Result::NO_RECBinary inexistent or base binary directory buffer not loaded.
Result::NO_LOCKBase binary directory not locked.
Exceptions
Exception::InvalidityPlace invalid.
Exception::InvalidityLocking invalid.
ExceptionOperation unavailable.
This is a root directory.
Note
Binaries are ordered by name (lexographicaly).

Implements C16::Binary.

◆ read() [3/3]

Result C16::BinaryDirectory::read ( const BinaryDirectory directory,
const std::string &  path,
Locking  locking = Locking::LOCK_SHARED 
)
overridevirtual

Reads a binary by means of a base binary directory and a path into the binary buffer.

Parameters
directoryBase binary directory buffer
pathPath to the binary relative to the base binary directory
lockingLocking to apply to the binary
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the binary.
Locking::LOCK_SINGLEApplies an exclusive, singulary lock to the binary.
Locking::LOCK_SHAREDApplies a shared lock to the binary.
Returns
Result
Return values
Result::OKBinary loaded and locking applied.
Result::NO_KEYBinary inexistent but following binary existent and loaded.
Result::LAST_RECBinary and following binary inexistent but preceding binary existent and loaded.
Result::NO_RECBinary inexistent or base binary directory buffer not loaded.
Result::NO_LOCKBase binary directory not locked.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InvalidityName invalid.
Exception::InvalidityLocking invalid.
ExceptionOperation unavailable.
This is a root directory.

Implements C16::Binary.

◆ unload()

void C16::BinaryDirectory::unload ( )
overridevirtual

Unloads the loaded binary.

Exceptions
ExceptionOperation unavailable.
This is a root directory.

Implements C16::Binary.

◆ write()

Result C16::BinaryDirectory::write ( ) const
overridevirtual

Writes the loaded binary.

Returns
Result
Return values
Result::OKBinary written.
Result::NO_RECNo binary loaded.
Result::NO_LOCKBinary not exclusively locked.
Result::DEADLOCKDeadlock occurred.
Exceptions
ExceptionOperation unavailable.
This is a root directory.

Implements C16::Binary.

◆ create()

Result C16::BinaryDirectory::create ( const BinaryDirectory directory,
const std::string &  path,
Locking  locking = Locking::LOCK_SHARED,
bool  overwrite = false 
)
overridevirtual

Creates and loads a binary.

Parameters
directoryBase binary directory buffer
pathPath to the binary relative to the base binary directory
lockingLocking to apply to the binary
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the binary.
Locking::LOCK_SINGLEApplies an exclusive, singulary lock to the binary.
Locking::LOCK_SHAREDApplies a shared lock to the binary.
overwriteOption to overwrite a binary with the same name (case insensitive)
Returns
Result
Return values
Result::OKBinary created, loaded and locking applied.
Result::NO_RECNo binary loaded.
Result::EXISTSBinary with same name (case insensitive) already existent.
Result::NO_LOCKBinary not exclusively locked or base binary directory not locked.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InvalidityName invalid.
ExceptionOperation unavailable.
Possible reasons:
  • This is a root directory.
  • This is an object and the destination directory is a root directory.
  • Nesting too deep.

Implements C16::Binary.

◆ erase_directory()

Result C16::BinaryDirectory::erase_directory ( const std::string &  path) const

Deletes a binary directory within the loaded binary directory.

Parameters
pathPath relative to the binary directory
Returns
Result
Return values
Result::OKBinary directory deleted.
Result::LOCKEDBinary directory locked.
Result::NO_RECNo binary directory loaded or binary directory inexistent.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InvalidityName invalid.

◆ erase_object()

Result C16::BinaryDirectory::erase_object ( const std::string &  path) const

Deletes a binary object within the loaded binary directory.

Parameters
pathPath relative to the binary directory
Returns
Result
Return values
Result::OKBinary object deleted.
Result::LOCKEDBinary object locked.
Result::NO_RECNo binary object loaded or binary object inexistent.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InvalidityName invalid.

◆ clear_object()

Result C16::BinaryDirectory::clear_object ( const std::string &  path) const

Clears a binary object within the loaded binary directory.

Parameters
pathPath relative to the binary directory
Returns
Result
Return values
Result::OKBinary object deleted.
Result::LOCKEDBinary object locked.
Result::NO_RECNo binary object loaded or binary object inexistent.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InvalidityName invalid.