Block Class Reference

Public class that represents a data block, that contains tables. More...

`#include <TableFile.h>`

Collaboration diagram for Block:

## Public Member Functions

| Block (const string &name, Serializer *serP, const eFileMode fileMode=READ_MODE, const Char::eCompareType caseSense=Char::eCASE_SENSITIVE)
| ~Block ()
vector< pair< string, ISTable::eTableDiff > > | operator== (Block &inBlock)
void | SetName (const string &name)
const string & | GetName () const
ISTable & | AddTable (const std::string &name=string(), const Char::eCompareType colCaseSense=Char::eCASE_SENSITIVE)
void | AddTable (const string &name, const int indexInFile=0, ISTable *isTableP=NULL)
void | RenameTable (const string &oldName, const string &newName)
void | GetTableNames (vector< string > &tableNames)
bool | IsTablePresent (const string &tableName)
ISTable & | GetTable (const string &tableName)
ISTable * | GetTablePtr (const string &tableName)
void | DeleteTable (const string &tableName)
void | WriteTable (ISTable &isTable)
void | WriteTable (ISTable *isTableP)
void | Print ()

## Public Attributes

mapped_ptr_vector< ISTable, StringLess > | _tables

## Detailed Description

Public class that represents a data block, that contains tables.

This class represents a data block, that can come from DDL, dictionary or CIF files. Data block is a container of tables. This class provides methods for construction and destruction, tables manipulation (addition, retrieval, deleting, writing), data blocks comparison.

## Constructor & Destructor Documentation

## Block()

Block::Block | ( | const string & | name,
|  | Serializer * | serP,
|  | const eFileMode | fileMode = `READ_MODE`,
|  | const Char::eCompareType | caseSense = `Char::eCASE_SENSITIVE`
| ) |  |

Utility method, not part of users public API, and will soon be removed.

Constructs a data block.

Parameters

  [in] | name | - the name of the data block
  [in] | serP | - pointer to the File Navigator object
  [in] | fileMode | - optional parameter that indicates data block mode. Possible values are read-only, create, update and virtual.
  [in] | caseSense | - optional parameter that indicates case sensitivity of table names. Possible values are case sensitive and case in-sensitive. If not specified, case sensitive table names are assumed.

Returns
  Not applicable

Precondition
  None

Postcondition
  None

Exceptions

## ~Block()

Block::~Block | ( |  | ) |

Utility method, not part of users public API, and will soon be removed.

Destructs a data block.

Parameters

## Member Function Documentation

## AddTable() [1/2]

ISTable& Block::AddTable | ( | const std::string & | name = `string()`,
|  | const Char::eCompareType | colCaseSense = `Char::eCASE_SENSITIVE`
| ) |  |

Adds a table to the block. If a table with the specified name already exists, it will be overwritten.

Parameters

  [in] | name | - optional parameter that indicates the name of the table to be added
  [in] | colCaseSense | - optional parameter that indicates case sensitivity of column names. Possible values are case sensitive and case in-sensitive. If not specified, a table with case sensitive column names is constructed.

Returns
  Reference to the table

Precondition
  None

Postcondition
  None

Exceptions

## AddTable() [2/2]

void Block::AddTable | ( | const string & | name,
|  | const int | indexInFile = `0`,
|  | ISTable * | isTableP = `NULL`
| ) |  |

Utility method, not part of users public API, and will soon be removed.

## DeleteTable()

void Block::DeleteTable | ( | const string & | tableName | ) |

Deletes a table from a data block.

Parameters

  [in] | tableName | - table name

Returns
  None

Precondition
  None

Postcondition
  None

Exceptions

## GetName()

const string & Block::GetName | ( |  | ) | const

inline

Retrieves data block name.

Parameters

## GetTable()

ISTable& Block::GetTable | ( | const string & | tableName | ) |

Retrieves a table reference.

Parameters

  [in] | tableName | - table name

Returns
  Reference to the table, if table was found

Precondition
  None

Postcondition
  None

Exceptions

  NotFoundException | - if table with name tableName does not exist

## GetTableNames()

void Block::GetTableNames | ( | vector< string > & | tableNames | ) |

Retrieves names of all tables in a data block.

Parameters

  [out] | tableNames | - retrieved table names

Returns
  None

Precondition
  None

Postcondition
  None

Exceptions

## GetTablePtr()

ISTable* Block::GetTablePtr | ( | const string & | tableName | ) |

Retrieves a pointer to the table.

Parameters

  [in] | tableName | - table name

Returns
  Pointer to the table, if table was found
  NULL, if table was not found

Precondition
  None

Postcondition
  None

Exceptions

## IsTablePresent()

bool Block::IsTablePresent | ( | const string & | tableName | ) |

Checks for table presence in the data block.

Parameters

  [in] | tableName | - table name

Returns
  true - if table exists
  false - if table does not exist

Precondition
  None

Postcondition
  None

Exceptions

## operator==()

vector<pair<string, ISTable::eTableDiff> > Block::operator== | ( | Block & | inBlock | ) |

Compares a data block to another data block.

Parameters

  [in] | inBlock | - reference to input data block

Returns
  vector of pairs, where the first value in a pair is a table name and the second value in a pair is one of the following indicators of table differences:
  eMISSING - table exists only in the input block and not in this block
  eEXTRA - table exists only in this block and not in the input block
  eCASE_SENSE - table exists in both blocks, but with different column name case sensitivity
  eMORE_COLS - table exists in both blocks, but the table in this block has more columns than the table in the input block
  eLESS_COLS - table exists in both blocks, but the table in this block has less columns than the table in the input block
  eCOL_NAMES - table exists in both blocks, but tables have different column names
  eMORE_ROWS - table exists in both blocks, but the table in this block has more rows than the table in the input block
  eLESS_ROWS - table exists in both blocks, but the table in this block has less rows than the table in the input block
  eCELLS - table exists in both blocks, but tables have different content

Precondition
  None

Postcondition
  None

Exceptions

## Print()

void Block::Print | ( |  | ) |

Utility method, not part of users public API, and will soon be removed.

## RenameTable()

void Block::RenameTable | ( | const string & | oldName,
|  | const string & | newName
| ) |  |

Changes the name of a table in the data block.

Parameters

  [in] | oldName | - the name of the table which is to be renamed
  [in] | newName | - the new table name

Returns
  None

Precondition
  oldName must be non-empty
  Table with name oldName must be present
  newName must be non-empty
  Table with name newName must not be present
  Block must be in create or update mode

Postcondition
  None

Exceptions

  EmptyValueException | - if oldName is empty
  NotFoundException | - if table with name oldName does not exist
  EmptyValueException | - if newName is empty
  AlreadyExistsException | - if table with name newName already exists
  FileModeException | - if block is not in create or update mode

## SetName()

void Block::SetName | ( | const string & | name | ) |

inline

Utility method, not part of users public API, and will soon be removed.

Sets the name of a data block.

Parameters

  [in] | name | - the name of the data block

Returns
  None

Precondition
  None

Postcondition
  None

Exceptions

## WriteTable() [1/2]

void Block::WriteTable | ( | ISTable & | isTable | ) |

Writes a table to the data block. In this context, writing means adding it (if it does not already exist) or updating it (if it already exists).

Parameters

  [in] | isTable | - reference to the table

Returns
  None

Precondition
  None

Postcondition
  None

Exceptions

## WriteTable() [2/2]

void Block::WriteTable | ( | ISTable * | isTableP | ) |

Writes a table to the data block. In this context, writing means adding it (if it does not already exist) or updating it (if it already exists).

Parameters

  [in] | isTableP | - pointer to the table

Returns
  None

Precondition
  None

Postcondition
  None

Exceptions

## Member Data Documentation

## _tables

mapped_ptr_vector<ISTable, StringLess> Block::_tables

The documentation for this class was generated from the following file:

- rcsb/TableFile.h