cee::vtfx::File Class Reference

A VTFx file. More...

Public Member Functions

 File ()
 Constructs an empty file object. More...
 
bool open (const Str &filename)
 Opens an existing file. More...
 
bool create (const Str &filename, const FileSettings &fileSettings)
 Creates a file with the given file name and file settings and prepares it for writing. More...
 
bool openForAppend (const Str &filename)
 Opens a VTFx file with the given file name and file settings for appending databases and cases. More...
 
bool close ()
 Closes the file. More...
 
size_t userTextFileCount () const
 Returns the number of user created text files in the VTFx file. More...
 
Str userTextFileName (size_t textFileIndex) const
 Returns the name of the user text file with index textFileIndex. More...
 
Str userTextFileContent (size_t textFileIndex) const
 Returns the content of the user text file with index textFileIndex. More...
 
bool addUserTextFile (const Str &filename, const Str &content)
 Adds a the string in content as a file into the VTFx archive. More...
 
size_t databaseCount () const
 Returns the number of databases in the VTFx file. More...
 
int unusedDatabaseId () const
 Returns an available database id to create a new database. More...
 
Databasedatabase (size_t databaseIndex)
 Returns the database at the given index. More...
 
size_t fileCaseCount () const
 Returns the number of cases in the VTFx file. More...
 
int unusedFileCaseId () const
 Returns an available case id to create a new case. More...
 
const CasefileCase (size_t caseIndex) const
 Returns the case at the given index. More...
 
CasefileCase (size_t caseIndex)
 Returns the case at the given index. More...
 
const FileSettingssettings () const
 Returns the file settings for this file. More...
 
- Public Member Functions inherited from cee::RefCountedObject
void addRef () const
 Increments the reference count for this object. More...
 
void release () const
 Decrements the reference count for this object. More...
 
int refCount () const
 Returns the reference count for this object. More...
 
void setRefCountZero () const
 Sets the ref count to zero, but DOES NOT delete the object. More...
 

Static Public Member Functions

static bool isVTFxFile (const Str &filename)
 Returns the content of the user text file with index textFileIndex. More...
 
Inheritance diagram for cee::vtfx::File:
cee::RefCountedObject

Detailed Description

A VTFx file.

The class creates or opens a VTFx file for adding databases and cases.

A VTFx file is a collection of databases and cases. Each database contains blocks for storing data. A block has a block type and an id. The id must be unique amongst all blocks of the same type within a database. The order of blocks in a database is arbitrary, so one can write blocks to a database at any time. However, the user has to take special care in using block types correctly and assigning block ids correctly, since the library does not validate these.

Cases reference databases and define a visualization of database contents using so-called case properties. Moreover, cases store auxiliary data such as a vendor logo, a visualization snapshot (if available), and HTML text to describe a case, for instance with further information on the database and the visualization.

The minimal contents of a VTFx file are :

  • One database with
  • One case with
    • A reference to the database

Constructor & Destructor Documentation

cee::vtfx::File::File ( )

Constructs an empty file object.

Member Function Documentation

bool cee::vtfx::File::addUserTextFile ( const Str filename,
const Str content 
)

Adds a the string in content as a file into the VTFx archive.

The name of the file is filename. The file will be stored in the "UserData" VTFx directory.

Previously added files with the same name will be overwritten.

Returns false if an error occurred.

bool cee::vtfx::File::close ( )

Closes the file.

Final writing of data is done by this method, thus it is important to check the return value.

Note: The destructor File::~File() does not close the file.

Returns false if the file could not be closed properly. See the log for more information on the error.

bool cee::vtfx::File::create ( const Str filename,
const FileSettings fileSettings 
)

Creates a file with the given file name and file settings and prepares it for writing.

An existing file with the same file name will be overwritten without notice.

Returns false if an error occurred. See the log for more information on the error.

Database * cee::vtfx::File::database ( size_t  databaseIndex)

Returns the database at the given index.

Returns NULL if the index is not valid.

size_t cee::vtfx::File::databaseCount ( ) const

Returns the number of databases in the VTFx file.

const Case * cee::vtfx::File::fileCase ( size_t  caseIndex) const

Returns the case at the given index.

Returns NULL if the case index is not valid.

Case * cee::vtfx::File::fileCase ( size_t  caseIndex)

Returns the case at the given index.

Returns NULL if the case index is not valid.

size_t cee::vtfx::File::fileCaseCount ( ) const

Returns the number of cases in the VTFx file.

bool cee::vtfx::File::isVTFxFile ( const Str filename)
static

Returns the content of the user text file with index textFileIndex.

bool cee::vtfx::File::open ( const Str filename)

Opens an existing file.

Returns true if the file was opened successfully.

bool cee::vtfx::File::openForAppend ( const Str filename)

Opens a VTFx file with the given file name and file settings for appending databases and cases.

New cases may reference existing databases within the VTFx file.

The user has to take care that appended databases and cases do not clash with existing ones, i.e. case and database ids need to be unique.

Returns false if an error occurred. See the log for more information on the error.

const FileSettings * cee::vtfx::File::settings ( ) const

Returns the file settings for this file.

int cee::vtfx::File::unusedDatabaseId ( ) const

Returns an available database id to create a new database.

Returns -1 if no file was opened for writing or appending.

int cee::vtfx::File::unusedFileCaseId ( ) const

Returns an available case id to create a new case.

Returns -1 if no file was opened for writing or appending.

cee::Str cee::vtfx::File::userTextFileContent ( size_t  textFileIndex) const

Returns the content of the user text file with index textFileIndex.

size_t cee::vtfx::File::userTextFileCount ( ) const

Returns the number of user created text files in the VTFx file.

cee::Str cee::vtfx::File::userTextFileName ( size_t  textFileIndex) const

Returns the name of the user text file with index textFileIndex.