rdbModel::Column Class Reference

#include <Column.h>

List of all members.

Public Types

 FROMdefault = 1
 FROMautoIncrement
 FROMnow
 FROMprogram
 FROMendUser
 CONTENTSunspecified = 0
 CONTENTSserviceName = 1
 CONTENTSusername = 2
 CONTENTSinsertTime = 3
 CONTENTSupdateTime = 4
enum  FROM {
  FROMdefault = 1, FROMautoIncrement, FROMnow, FROMprogram,
  FROMendUser
}
enum  CONTENTS {
  CONTENTSunspecified = 0, CONTENTSserviceName = 1, CONTENTSusername = 2, CONTENTSinsertTime = 3,
  CONTENTSupdateTime = 4
}
 Hints to program in case FROM field is FROMprogram. More...

Public Member Functions

 Column (Table *myTable=0)
 ~Column ()
const std::stringgetName () const
const std::stringgetComment () const
const std::stringgetDefault () const
const std::stringgetTableName () const
DatatypegetDatatype () const
EnumgetEnum () const
bool okValue (const std::string &val, bool set=true) const
bool isCompatible (const Column *otherCol) const
 Return true if otherCol and this have compatible datatypes.
bool nullAllowed () const
 Returns true if column may take on value NULL.
bool stickyInsert () const
bool isPrimaryKey () const
bool isAutoIncrement () const
FROM getSourceType () const
CONTENTS getContentsType () const
bool interpret (const std::string &interpType, std::string &val)
Visitor::VisitorState accept (Visitor *v)

Private Attributes

Tablem_myTable
std::string m_name
std::string m_comment
Datatypem_type
std::string m_default
FROM m_from
CONTENTS m_contents
bool m_null
 Can this field have the value NULL?
bool m_stickyInsert
bool m_isPrimaryKey
 Is this column a primary key?

Friends

class rdbModel::XercesBuilder


Detailed Description

rdbModel representation of a(n SQL-like) table description

Definition at line 23 of file Column.h.


Member Enumeration Documentation

enum rdbModel::Column::CONTENTS

Hints to program in case FROM field is FROMprogram.

Enumerator:
CONTENTSunspecified 
CONTENTSserviceName 
CONTENTSusername 
CONTENTSinsertTime 
CONTENTSupdateTime 

Definition at line 39 of file Column.h.

00039                   {
00040       CONTENTSunspecified = 0,
00041       CONTENTSserviceName = 1,
00042       CONTENTSusername    = 2,
00043       CONTENTSinsertTime   = 3,
00044       CONTENTSupdateTime = 4
00045 
00046     };

enum rdbModel::Column::FROM

Source of value. Note timestamp with value current time should be indicated by contents value CONTENTSupdateTime or (if only upon insert) CONTENTS enterTime

Enumerator:
FROMdefault 
FROMautoIncrement 
FROMnow 
FROMprogram 
FROMendUser 

Definition at line 30 of file Column.h.

00030               {
00031       FROMdefault = 1,          // enduser can override default, however
00032       FROMautoIncrement,
00033       FROMnow,                  // datatype must be timestamp - deprecated
00034       FROMprogram,
00035       FROMendUser
00036     };


Constructor & Destructor Documentation

rdbModel::Column::Column ( Table myTable = 0  )  [inline]

Definition at line 48 of file Column.h.

References CONTENTSunspecified, m_contents, m_default, and deljobs::string.

00048                              : m_myTable(myTable), m_type(0), 
00049                                m_isPrimaryKey(false) {
00050       m_contents = CONTENTSunspecified;
00051       m_default = std::string("");};

rdbModel::Column::~Column (  ) 

Definition at line 11 of file Column.cxx.

References m_type.

00011                   {
00012     delete m_type;
00013   }


Member Function Documentation

Visitor::VisitorState rdbModel::Column::accept ( Visitor v  ) 

Definition at line 58 of file Column.cxx.

References v, rdbModel::Visitor::VBRANCHDONE, and rdbModel::Visitor::VCONTINUE.

00058                                                {
00059 
00060     Visitor::VisitorState state = v->visitColumn(this);
00061     if (state == Visitor::VBRANCHDONE) return Visitor::VCONTINUE;
00062     return state;
00063   }

const std::string& rdbModel::Column::getComment (  )  const [inline]

Definition at line 57 of file Column.h.

References m_comment.

00057 {return m_comment;};

CONTENTS rdbModel::Column::getContentsType (  )  const [inline]

Definition at line 89 of file Column.h.

References m_contents.

00089 {return m_contents;}

Datatype* rdbModel::Column::getDatatype (  )  const [inline]

Definition at line 63 of file Column.h.

References m_type.

Referenced by main(), and rdbModel::MysqlConnection::visitColumn().

00063 {return m_type;};

const std::string& rdbModel::Column::getDefault (  )  const [inline]

Definition at line 59 of file Column.h.

References m_default.

Referenced by rdbModel::Table::addColumn().

00059 {return m_default;}

Enum * rdbModel::Column::getEnum (  )  const

Return pointer to Enum object associated with this column (if none, return null pointer).

Definition at line 15 of file Column.cxx.

References rdbModel::Datatype::getEnum(), and m_type.

00015 {return m_type->getEnum();}

const std::string& rdbModel::Column::getName (  )  const [inline]

Definition at line 56 of file Column.h.

References m_name.

Referenced by rdbModel::ColCompare::operator()(), tryQuick(), and rdbModel::MysqlConnection::visitColumn().

00056 {return m_name; };

FROM rdbModel::Column::getSourceType (  )  const [inline]

Definition at line 88 of file Column.h.

References m_from.

Referenced by rdbModel::Table::addColumn().

00088 {return m_from;}

const std::string & rdbModel::Column::getTableName (  )  const

Definition at line 17 of file Column.cxx.

References rdbModel::Table::getName(), and m_myTable.

00017                                               {
00018     return m_myTable->getName();
00019   }

bool rdbModel::Column::interpret ( const std::string interpType,
std::string val 
)

Handle special literal values, depending loosely on column datatype. Most Column objects won't do any interpretation, but, for example, timestamp-like columns may substitute for "NOW" Return true if any substitution was done

Definition at line 41 of file Column.cxx.

References rdbModel::Datatype::getType(), m_type, deljobs::string, rdbModel::Datatype::TYPEdatetime, and rdbModel::Datatype::TYPEtimestamp.

Referenced by rdbModel::Table::doInterUpdate(), and rdbModel::Table::supersedeRow().

00041                                                                     {
00042     // Currently only interpretation is for timestamp-like columns.
00043     // Value of interpType must be "time" and val must be "NOW".
00044     // In this case, substitute ascii current time
00045     if (interpType.compare(std::string("time")) != 0) return false;
00046 
00047     Datatype::TYPES dtype = m_type->getType();
00048     if ((dtype != Datatype::TYPEdatetime) && 
00049         (dtype != Datatype::TYPEtimestamp)) {
00050       return false;
00051     }
00052     if (val.compare(std::string("NOW")) != 0) return false;
00053 
00054     val = facilities::Timestamp().getString();
00055     return true;
00056   }

bool rdbModel::Column::isAutoIncrement (  )  const

Definition at line 37 of file Column.cxx.

References FROMautoIncrement, and m_from.

Referenced by rdbModel::MysqlConnection::visitColumn().

00037                                      {
00038     return (m_from == FROMautoIncrement);
00039   }

bool rdbModel::Column::isCompatible ( const Column otherCol  )  const

Return true if otherCol and this have compatible datatypes.

Definition at line 32 of file Column.cxx.

References rdbModel::Datatype::isCompatible(), and m_type.

Referenced by rdbModel::Assertion::Operator::validCompareOp().

00032                                                         {
00033     return m_type->isCompatible(otherCol->m_type);
00034   }

bool rdbModel::Column::isPrimaryKey (  )  const [inline]

Definition at line 84 of file Column.h.

References m_isPrimaryKey.

Referenced by main().

00084 {return m_isPrimaryKey;}

bool rdbModel::Column::nullAllowed (  )  const [inline]

Returns true if column may take on value NULL.

Definition at line 80 of file Column.h.

References m_null.

Referenced by rdbModel::Table::addColumn(), and rdbModel::MysqlConnection::visitColumn().

00080 { return m_null;}

bool rdbModel::Column::okValue ( const std::string val,
bool  set = true 
) const

See if supplied value meets constraints of column definition

Definition at line 21 of file Column.cxx.

References FROMautoIncrement, FROMnow, m_from, m_type, and rdbModel::Datatype::okValue().

Referenced by rdbModel::Assertion::Operator::validCompareOp().

00021                                                            {
00022     // auto increment and datetime values are established by rdbms
00023     if (set) {
00024 
00025       if ( (m_from == FROMautoIncrement) || 
00026            (m_from == FROMnow)) return false;
00027     }
00028 
00029     return m_type->okValue(val);
00030   }

bool rdbModel::Column::stickyInsert (  )  const [inline]

Definition at line 82 of file Column.h.

References m_stickyInsert.

00082 { return m_stickyInsert;}


Friends And Related Function Documentation

friend class rdbModel::XercesBuilder [friend]

Definition at line 102 of file Column.h.


Member Data Documentation

std::string rdbModel::Column::m_comment [private]

Definition at line 107 of file Column.h.

Referenced by getComment().

CONTENTS rdbModel::Column::m_contents [private]

Definition at line 112 of file Column.h.

Referenced by Column(), and getContentsType().

std::string rdbModel::Column::m_default [private]

Definition at line 110 of file Column.h.

Referenced by Column(), and getDefault().

FROM rdbModel::Column::m_from [private]

Definition at line 111 of file Column.h.

Referenced by getSourceType(), isAutoIncrement(), and okValue().

bool rdbModel::Column::m_isPrimaryKey [private]

Is this column a primary key?

Definition at line 121 of file Column.h.

Referenced by isPrimaryKey().

Table* rdbModel::Column::m_myTable [private]

Definition at line 104 of file Column.h.

Referenced by getTableName().

std::string rdbModel::Column::m_name [private]

Definition at line 106 of file Column.h.

Referenced by getName().

bool rdbModel::Column::m_null [private]

Can this field have the value NULL?

Definition at line 115 of file Column.h.

Referenced by nullAllowed().

bool rdbModel::Column::m_stickyInsert [private]

For multi-insert, does this column normally keep same value for all the inserts?

Definition at line 118 of file Column.h.

Referenced by stickyInsert().

Datatype* rdbModel::Column::m_type [private]

Definition at line 108 of file Column.h.

Referenced by getDatatype(), getEnum(), interpret(), isCompatible(), okValue(), and ~Column().


Generated on Tue Nov 29 23:36:36 2016 for BOSS_7.0.2 by  doxygen 1.4.7