WORM 0.2
A C++ DAL/ORM code generation framework
|
WSqlTable is an abstraction for a single table, collection or view in a database. More...
#include <wsqltable.h>
Public Types | |
enum | Type { NORMAL, VIEW, JOIN, TYPETABLE } |
A flag indicating the type of table this is Tables can be of various types: More... | |
Public Member Functions | |
WSqlTable () | |
WSqlTable (const std::string name) | |
WSqlTable (const WSqlTable &other) | |
virtual | ~WSqlTable () |
virtual WSqlTable & | operator= (const WSqlTable &other) |
virtual bool | operator== (const WSqlTable &other) const |
bool | operator!= (const WSqlTable &other) const |
const std::string & | name () const |
const std::string & | className () const |
bool | isEmpty () const |
bool | isValid () const |
int | count () const |
int | indexOf (const std::string &columnname) const |
const Type | type () const |
const std::string | columnName (int i) const |
WSqlColumn | column (int i) const |
WSqlColumn | column (const std::string &name) const |
const std::vector< WSqlColumn > & | columns () const |
std::vector< std::string > | columnNames () const |
void | setName (const std::string &n) |
void | setClassName (const std::string &n) |
void | setIsValid (bool b) |
void | setType (Type t) |
void | append (const WSqlColumn &column) |
void | replace (int pos, const WSqlColumn &column) |
void | insert (int pos, const WSqlColumn &column, bool replace=false) |
void | remove (int pos) |
void | addForeignKey (const WSqlForeignKey &fk) |
void | removeForeignKey (const WSqlForeignKey &fk) |
void | removeForeignKey (int pos) |
void | removeForeignKey (const std::string &columnname) |
void | addReferencedKey (const WSqlReferencedKey &rk) |
void | removeReferencedKey (const WSqlReferencedKey &rk) |
void | removeReferencedKey (int pos) |
void | removeReferencedKey (const std::string &columnname) |
bool | hasForeignKeys () const |
bool | hasReferencedKeys () const |
WSqlForeignKey | foreignKey (const std::string columnname) const |
WSqlReferencedKey | referencedKey (const std::string columnname) const |
const std::vector < WSqlForeignKey > & | foreignKeys () const |
const std::vector < WSqlReferencedKey > & | referencedKeys () const |
Protected Attributes | |
std::vector< WSqlColumn > | _columns |
std::vector< WSqlForeignKey > | _foreignKeys |
std::vector< WSqlReferencedKey > | _referencedKeys |
std::string | _name |
std::string | _className |
bool | _isValid |
Type | _type |
WSqlTable is an abstraction for a single table, collection or view in a database.
WSqlTable is an abstraction for a single table, collection or view in a database. It contains meta information about the columns as they exist in the database itself. It also contains information about indices, foriegn keys, primary keys, etc. It is used primarily by the ORM generator.
Tables to be generated may have any naming schema - but it is recommended that this is at least consistant. Worm will not alter the names but rather takes them exactly as they are from the the names in the database - so "my_table" will produce a class object "class my_table", a column named firstName will be generated as firstName, First_Name as First_Name, etc. If you are designing a schema this may be taken into consideration as it will effect the style of the generated code.
Note: For NoSQL databases this class may not be useful for column metadata.
Definition at line 32 of file wsqltable.h.
A flag indicating the type of table this is Tables can be of various types:
Definition at line 36 of file wsqltable.h.
WSql::WSqlTable::WSqlTable | ( | ) |
Constructs an empty table object.
Definition at line 71 of file wsqltable.cpp.
WSql::WSqlTable::WSqlTable | ( | const std::string | name | ) |
Constructs an empty table object with the name name..
Definition at line 81 of file wsqltable.cpp.
WSql::WSqlTable::WSqlTable | ( | const WSqlTable & | other | ) |
Constructs a copy of other.
Definition at line 91 of file wsqltable.cpp.
WSql::WSqlTable::~WSqlTable | ( | ) | [virtual] |
Destroys the object and frees any allocated resources.
Definition at line 118 of file wsqltable.cpp.
void WSql::WSqlTable::addForeignKey | ( | const WSqlForeignKey & | fk | ) |
Definition at line 322 of file wsqltable.cpp.
void WSql::WSqlTable::addReferencedKey | ( | const WSqlReferencedKey & | rk | ) |
Definition at line 380 of file wsqltable.cpp.
void WSql::WSqlTable::append | ( | const WSqlColumn & | column | ) |
Definition at line 272 of file wsqltable.cpp.
const std::string& WSql::WSqlTable::className | ( | ) | const [inline] |
Definition at line 52 of file wsqltable.h.
WSqlColumn WSql::WSqlTable::column | ( | int | index | ) | const |
Returns the WSqlColumn at postion index If the index is out of range it returns an empty WSqlColumn object.
Definition at line 198 of file wsqltable.cpp.
WSqlColumn WSql::WSqlTable::column | ( | const std::string & | fldname | ) | const |
Returns the WSqlColumn with (column) name fldname If the index is out of range it returns an empty WSqlColumn object.
Definition at line 213 of file wsqltable.cpp.
const std::string WSql::WSqlTable::columnName | ( | int | index | ) | const |
Returns the name of the column at postion index, ie. the column name in the database. If the index is out of range it returns an empty string.
Definition at line 183 of file wsqltable.cpp.
std::vector< std::string > WSql::WSqlTable::columnNames | ( | ) | const |
Returns a list containing all the names of the columns in the table (which may be empty).
Definition at line 241 of file wsqltable.cpp.
const std::vector< WSqlColumn > & WSql::WSqlTable::columns | ( | ) | const |
Returns a list containing all the WSqlColumns in the table (which may be empty).
Definition at line 234 of file wsqltable.cpp.
int WSql::WSqlTable::count | ( | ) | const |
Definition at line 250 of file wsqltable.cpp.
WSqlForeignKey WSql::WSqlTable::foreignKey | ( | const std::string | columnname | ) | const |
Definition at line 309 of file wsqltable.cpp.
const std::vector< WSqlForeignKey > & WSql::WSqlTable::foreignKeys | ( | ) | const |
Definition at line 327 of file wsqltable.cpp.
bool WSql::WSqlTable::hasForeignKeys | ( | ) | const [inline] |
Definition at line 84 of file wsqltable.h.
bool WSql::WSqlTable::hasReferencedKeys | ( | ) | const [inline] |
Definition at line 85 of file wsqltable.h.
int WSql::WSqlTable::indexOf | ( | const std::string & | columnname | ) | const |
Definition at line 255 of file wsqltable.cpp.
void WSql::WSqlTable::insert | ( | int | pos, |
const WSqlColumn & | column, | ||
bool | replace = false |
||
) |
Definition at line 282 of file wsqltable.cpp.
bool WSql::WSqlTable::isEmpty | ( | ) | const |
Definition at line 304 of file wsqltable.cpp.
bool WSql::WSqlTable::isValid | ( | ) | const [inline] |
Definition at line 54 of file wsqltable.h.
const std::string& WSql::WSqlTable::name | ( | ) | const [inline] |
Definition at line 51 of file wsqltable.h.
bool WSql::WSqlTable::operator!= | ( | const WSqlTable & | other | ) | const [inline] |
Returns true if this object is not identical to other; otherwise returns false.
Definition at line 49 of file wsqltable.h.
Sets this table equal to other.
Definition at line 104 of file wsqltable.cpp.
bool WSql::WSqlTable::operator== | ( | const WSqlTable & | other | ) | const [virtual] |
Returns true if this object is identical to other (i.e., has the same columns in the same order); otherwise returns false.
Definition at line 139 of file wsqltable.cpp.
WSqlReferencedKey WSql::WSqlTable::referencedKey | ( | const std::string | columnname | ) | const |
Definition at line 371 of file wsqltable.cpp.
const std::vector< WSqlReferencedKey > & WSql::WSqlTable::referencedKeys | ( | ) | const |
Definition at line 385 of file wsqltable.cpp.
void WSql::WSqlTable::remove | ( | int | pos | ) |
Definition at line 294 of file wsqltable.cpp.
void WSql::WSqlTable::removeForeignKey | ( | const std::string & | columnname | ) |
Definition at line 355 of file wsqltable.cpp.
void WSql::WSqlTable::removeForeignKey | ( | const WSqlForeignKey & | fk | ) |
Definition at line 332 of file wsqltable.cpp.
void WSql::WSqlTable::removeForeignKey | ( | int | pos | ) |
Definition at line 345 of file wsqltable.cpp.
void WSql::WSqlTable::removeReferencedKey | ( | const std::string & | columnname | ) |
Definition at line 413 of file wsqltable.cpp.
void WSql::WSqlTable::removeReferencedKey | ( | int | pos | ) |
Definition at line 403 of file wsqltable.cpp.
void WSql::WSqlTable::removeReferencedKey | ( | const WSqlReferencedKey & | rk | ) |
Definition at line 390 of file wsqltable.cpp.
void WSql::WSqlTable::replace | ( | int | pos, |
const WSqlColumn & | column | ||
) |
Definition at line 277 of file wsqltable.cpp.
void WSql::WSqlTable::setClassName | ( | const std::string & | n | ) | [inline] |
Definition at line 66 of file wsqltable.h.
void WSql::WSqlTable::setIsValid | ( | bool | b | ) | [inline] |
Definition at line 67 of file wsqltable.h.
void WSql::WSqlTable::setName | ( | const std::string & | n | ) |
Definition at line 429 of file wsqltable.cpp.
void WSql::WSqlTable::setType | ( | Type | t | ) | [inline] |
Definition at line 68 of file wsqltable.h.
const Type WSql::WSqlTable::type | ( | ) | const [inline] |
Definition at line 57 of file wsqltable.h.
std::string WSql::WSqlTable::_className [protected] |
Definition at line 96 of file wsqltable.h.
std::vector<WSqlColumn> WSql::WSqlTable::_columns [protected] |
Definition at line 92 of file wsqltable.h.
std::vector<WSqlForeignKey> WSql::WSqlTable::_foreignKeys [protected] |
Definition at line 93 of file wsqltable.h.
bool WSql::WSqlTable::_isValid [protected] |
Definition at line 97 of file wsqltable.h.
std::string WSql::WSqlTable::_name [protected] |
Definition at line 95 of file wsqltable.h.
std::vector<WSqlReferencedKey> WSql::WSqlTable::_referencedKeys [protected] |
Definition at line 94 of file wsqltable.h.
Type WSql::WSqlTable::_type [protected] |
Definition at line 98 of file wsqltable.h.