zoukankan      html  css  js  c++  java
  • CFileEngine

     1 #ifndef _FILE_ENGINE_H_031104_
     2 #define _FILE_ENGINE_H_031104_
     3 
     4 #include "DataEngine.h"
     5 
     6 enum fileengine_type
     7 {
     8     ISAM,
     9     TIANWANG,
    10     LINK4SE
    11 };
    12 
    13 class CUrl;
    14 class CPage;
    15 
    16 struct file_arg
    17 {
    18     CUrl *pUrl;
    19     CPage *pPage;
    20 };
    21 
    22 class CFileEngine : public CDataEngine//仍然只能用作基类
    23 {
    24 public:
    25     ofstream m_ofsFile;
    26 
    27 public:
    28     CFileEngine();
    29     CFileEngine(string str);
    30     virtual ~CFileEngine();
    31 
    32     int GetEngineType() { return FILE_ENGINE; }
    33     virtual int GetFileType() = 0;
    34 
    35     bool Open(string str);
    36 
    37     inline void Close() { m_ofsFile.close(); }
    38 
    39 };
    40 
    41 #endif /* _FILE_ENGINE_H_031104_ */
     1 #include "FileEngine.h"
     2 
     3 CFileEngine::CFileEngine()
     4 {
     5 }
     6 
     7 CFileEngine::CFileEngine(string str) : CDataEngine (str)
     8 {
     9     m_ofsFile.open(m_str.c_str(), ios::out|ios::app|ios::binary);
    10 
    11     if( !m_ofsFile ){
    12         cerr << "cannot open " << m_str << "for output" << endl;
    13     }
    14 }
    15 
    16 CFileEngine::~CFileEngine()
    17 {
    18     m_ofsFile.close();
    19 }
    20 
    21 bool CFileEngine::Open(string str)
    22 {
    23     m_str = str;
    24 
    25     m_ofsFile.open(m_str.c_str(), ios::out|ios::app|ios::binary);
    26 
    27     if( !m_ofsFile )
    28     {
    29         cerr << "cannot open " << m_str << "for output" << endl;
    30         return false;
    31     } 
    32     else
    33     {
    34         return true;
    35     }
    36 }
  • 相关阅读:
    每个人在公司都有自己的品牌--如何做一名优秀的管理者
    ios 逆向
    游戏整理
    Mac 开发装机必备
    php整理
    mongodb 学习
    python 学习
    pdf 下载整理
    C# 整理
    微服务学习
  • 原文地址:https://www.cnblogs.com/kakamilan/p/2580703.html
Copyright © 2011-2022 走看看