打印本文 打印本文 关闭窗口 关闭窗口
用Delphi的思想初步构建C++的ADO对象
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3707  更新时间:2009/4/23 10:43:17  文章录入:mintao  责任编辑:mintao
      

       //重载隐式转换操作符

       operator ValueType()

       {

              assert(m_cObject != NULL);

              assert(Get != NULL);

              return (m_cObject->*Get)();

       }

      

private:

       Container* m_cObject;                                     //属性的拥有者

       void (Container::*Set)(ValueType value);      //set函数指针

       ValueType (Container::*Get)();                           //get函数指针

};

 

 

 

class CAdoConnection

{

public:

       CAdoConnection();

       ~CAdoConnection();

       //隐式的转换操作,不推荐使用,只是暂时类没有封装好,给客户一个方便

       //使用时请确保指针在类的生命期内使用

       operator _ConnectionPtr();

 

public:

       CProperty<CAdoConnection, BOOL, READ_WRITE> Connected;

       string ConnectingString;

       string UserName, PassWord;

 

private:

       void SetConnected(BOOL ConnectFlag);

       BOOL GetConnected();

 

private:

       _ConnectionPtr m_ptrConn;

 

friend class CAdoCommand;

friend class CAdoQuery;

 

 

};

 

 

class CAdoCommand

{

public:

       CAdoCommand();

       ~CAdoCommand();

       void Execute();

       operator _CommandPtr();

 

public:

       CommandTypeEnum CommandType;

       string CommandText;

       CAdoConnection * m_AdoConnection;

 

private:

       _CommandPtr m_ptrComm;

 

};

 

 

//CAdoConnection

CAdoConnection::CAdoConnection()

{

       Connected.setContainer(this);&nbs

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口