CONZEPT 16 C++ API
C16::Binary Class Referenceabstract

Generic binary buffer to operate on binaries. More...

#include "C16/Binary.hpp"

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

Detailed Description

Generic binary buffer to operate on binaries.

Classes

class  Exception
 Exception of an operation on a binary. More...
 

Public Types

enum  Error { Error::CONTENT_EMPTY = 1, Error::CIPHER_KEY_INCORRECT, Error::OPERATION_UNAVAILABLE }
 Error of an operation on a binary. More...
 

Static Public Attributes

static const int NAME_LENGTH_LIMIT = 60
 Name length limit. More...
 
static const int CUSTOM_LENGTH_LIMIT = 255
 Custom property length limit. More...
 

Public Member Functions

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 read (const BinaryDirectory &directory, const std::string &name, Place place=Place::KEY, Locking locking=Locking::NONE)=0
 Reads a binary by means of a base binary directory, a reference name and a place into the binary buffer. More...
 
virtual Result read (const BinaryDirectory &directory, Place place, Locking locking=Locking::NONE)=0
 Reads a binary by means of a base binary directory and a place into the binary buffer. More...
 
virtual Result read (const BinaryDirectory &directory, const std::string &path, Locking locking=Locking::LOCK_SHARED)=0
 Reads a binary by means of a base binary directory and a path into the binary buffer. More...
 
virtual void unload ()=0
 Unloads the loaded binary. More...
 
virtual Result write () const =0
 Writes the loaded binary. More...
 
virtual Result create (const BinaryDirectory &directory, const std::string &path, Locking locking=Locking::LOCK_SHARED, bool overwrite=false)=0
 Creates and loads a 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...
 

Member Enumeration Documentation

◆ Error

enum C16::Binary::Error
strong

Error of an operation on a binary.

Enumerator
CONTENT_EMPTY 

Content empty.

CIPHER_KEY_INCORRECT 

Cipher key incorrect.

OPERATION_UNAVAILABLE 

Operation unavailable.

Member Data Documentation

◆ NAME_LENGTH_LIMIT

const int C16::Binary::NAME_LENGTH_LIMIT = 60
static

Name length limit.

◆ CUSTOM_LENGTH_LIMIT

const int C16::Binary::CUSTOM_LENGTH_LIMIT = 255
static

Custom property length limit.

Member Function Documentation

◆ database() [1/2]

const Database* C16::Binary::database ( ) const

Gets the database of the loaded binary.

◆ database() [2/2]

Database* C16::Binary::database ( )

Gets the database of the loaded binary.

◆ loaded()

bool C16::Binary::loaded ( ) const

Gets if a binary is loaded into the binary buffer.

◆ locked()

bool C16::Binary::locked ( ) const

Gets if the loaded binary is locked by the user accessing the database.

◆ id()

long long int C16::Binary::id ( ) const

Gets the id of the loaded binary.

◆ name()

const std::string& C16::Binary::name ( ) const

Gets the name of the loaded binary.

◆ path()

const std::string& C16::Binary::path ( ) const

Gets the path of the loaded binary.

◆ custom()

const std::string& C16::Binary::custom ( ) const

Gets the custom property of the loaded binary.

◆ custom_set()

virtual void C16::Binary::custom_set ( const std::string &  custom)
virtual

Sets the custom property of the loaded binary.

Parameters
customCustom property of binary (0 to CUSTOM_LENGTH_LIMIT characters)
Exceptions
Exception::InvalidityCustom invalid.
ExceptionOperation unavailable.
This is a root directory.
Note
The modification will be applied after writing the binary.

◆ read() [1/3]

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

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).

Implemented in C16::BinaryObject, and C16::BinaryDirectory.

◆ read() [2/3]

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

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).

Implemented in C16::BinaryObject, and C16::BinaryDirectory.

◆ read() [3/3]

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

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.

Implemented in C16::BinaryObject, and C16::BinaryDirectory.

◆ unload()

virtual void C16::Binary::unload ( )
pure virtual

Unloads the loaded binary.

Exceptions
ExceptionOperation unavailable.
This is a root directory.

Implemented in C16::BinaryObject, and C16::BinaryDirectory.

◆ write()

virtual Result C16::Binary::write ( ) const
pure virtual

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.

Implemented in C16::BinaryObject, and C16::BinaryDirectory.

◆ create()

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

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.

Implemented in C16::BinaryObject, and C16::BinaryDirectory.

◆ rename()

virtual Result C16::Binary::rename ( const std::string &  name)
virtual

Renames the loaded binary.

Parameters
nameName (1 to NAME_LENGTH_LIMIT characters)
Returns
Result
Return values
Result::OKBinary renamed.
Result::NO_RECNo binary loaded.
Result::EXISTSBinary with same name (case insensitive) already existent.
Result::NO_LOCKBinary not exclusively locked.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InvalidityName invalid.
ExceptionOperation unavailable.
This is a root directory.

◆ move_to()

virtual Result C16::Binary::move_to ( const BinaryDirectory directory)
virtual

Moves the loaded binary to another directory.

Parameters
directoryDestination binary directory buffer
Returns
Result
Return values
Result::OKBinary moved.
Result::NO_RECNo binary loaded.
Result::EXISTSBinary with same name (case insensitive) already existent.
Result::NO_LOCKBinary not exclusively locked or destination binary directory not locked.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::DifferenceDatabase different.
Database of this binary is different to database of the destination directory.
ExceptionOperation unavailable.
Possible reasons:
  • This is a root directory.
  • This is an object and the destination directory is a root directory.
  • Nesting too deep.
  • This is a directory and the destination directory is subdirectory of the directory.