#ifndef _DBStruct_CPP_ #define _DBStruct_CPP_ // INCLUDES // #include "db/DBStruct.H" //#include "../DBStruct.H" // for datetest // NAME: DBStruct.CPP // TYPE: C++ SOURCE FILE // SYNOPSIS: // DESCRIPTION: Implementation of the DBStruct class // BUGS: // SEE ALSO: //--------------------------------------------------------------------------- ////////////////////// // DBStruct::DBStruct(); // // Description: default constructor // /////// DBStruct::DBStruct() : called(), toCall() { } ////////////////////// // DBStruct::DBStruct(char*, char*, char*, char*, char*, char*, char*, char*); // // Description: string constructor // /////// DBStruct::DBStruct( char* com, char* cnt ="Contact", char* dpt ="Department", char* add ="Address", char* cty ="City", char* pst ="PostCode", char* tel ="Tel No", char* mem ="Memo" ) { strcpy(coName, com); strcpy(contact, cnt); strcpy(department, dpt); strcpy(address, add); strcpy(city, cty); strcpy(post, pst); strcpy(telephone, tel); strcpy(memo, mem); } ////////////////////// DEBUG ONLY DEBUG ONLY DEBUG ONLY DEBUG ONLY // DBStruct::DBStruct(char*); // // Description: int constructor // /////// /*DBStruct::DBStruct( int i) : coName(i) { }*/ ////////////////////// // DBStruct::DBStruct(const DBStruct& ) // // Description: Copy constructor // /////// // DBStruct::DBStruct(const DBStruct&) //{ //...;) //} ////////////////////// // DBStruct::~DBStruct(); // // Description: Destructor // /////// //DBStruct::~DBStruct() //{ //...;) //} ////////////////////// // DBStruct& DBStruct::operator=(const DBStruct& x) // // Description: Overloaded assignment operator // /////// //DBStruct& //DBStruct::operator=(const DBStruct& x) //{ // if(this !=&x) // avoids self assignment x =x //{ //...; //} //return *this; //} ////////////////////// // inline bool // DBStruct::operator == ( const DBStruct&, const DBStruct& ) // // Description: Overloaded equality operator // /////// // string version /*inline bool operator == ( const DBStruct& lhs, const DBStruct& rhs) { return lhs.coName == rhs.coName; };*/ inline bool // char* version operator == ( const DBStruct& lhs, const DBStruct& rhs) { if( strcmp(lhs.coName, rhs.coName) ) return true; return false; }; ////////////////////// // inline bool // DBStruct::operator < ( const DBStruct&, const DBStruct& ) // // Description: Overloaded less operator // /////// inline bool // char* version operator < ( const DBStruct& lhs, const DBStruct& rhs) { if( strcmp(lhs.coName, rhs.coName) <0 ) return true; return false; }; /*inline bool // string version operator < ( const DBStruct& lhs, const DBStruct& rhs) { return lhs.coName < rhs.coName; }*/ ////////////////////// // inline bool // DBStruct::operator << ( ostream& os, const DBStruct& ) // // Description: Overloaded stream insertion // /////// ostream& operator << ( ostream& os, const DBStruct& dbs ) { os << dbs.coName << '\t' << dbs.contact << '\t' << dbs.department << '\t' << dbs.address << '\t' << dbs.city << '\t' << dbs.post << '\t' << dbs.telephone << '\t' << dbs.memo << '\t' << dbs.called << '\t' << dbs.toCall << '\t' ; return os; }; ////////////////////// // inline bool // DBStruct::operator >> ( istream& is, const DBStruct& ) // // Description: overloaded stream extraction // /////// istream& operator >> ( istream& is, DBStruct& dbs ) { is.getline(dbs.coName,100,'\t'); is.getline(dbs.contact,50,'\t'); is.getline(dbs.department,30,'\t'); is.getline(dbs.address,100,'\t'); is.getline(dbs.city,30,'\t'); is.getline(dbs.post,13,'\t'); is.getline(dbs.telephone,13,'\t'); is.getline(dbs.memo,256,'\t'); /* is>>dbs.called.day; is.ignore(); // '\t' is>>dbs.called.month; is.ignore(); is>>dbs.called.year; is.ignore(); is>>dbs.toCall.day; is.ignore(); is>>dbs.toCall.month; is.ignore(); is>>dbs.toCall.year; is.ignore();*/ return is; }; #endif // _DBStruct_CPP_