⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 files.h

📁 通訊保密編碼library project code.完整library project code!
💻 H
字号:
#ifndef FILES_H
#define FILES_H

#include <fstream.h>

#include "cryptlib.h"
#include "filters.h"

class FileErr {};
class OpenErr : public FileErr {};
class ReadErr : public FileErr {};
class WriteErr : public FileErr {};

class FileSource : public Source
{
public:
    FileSource(istream &in=cin, boolean pumpAndClose=FALSE,
               BufferedTransformation *outQueue = new ByteQueue);
    FileSource(const char *filename, boolean pumpAndClose=FALSE,
               BufferedTransformation *outQueue = new ByteQueue);

    istream& GetStream() {return in;}

    unsigned int Pump(unsigned int size);
    unsigned long PumpAll();

private:
    ifstream file;
    istream& in;
};

class FileSink : public Sink
{
public:
    FileSink(ostream &out=cout);
    FileSink(const char *filename);

    ostream& GetStream() {return out;}

    void InputFinished();
    void Put(byte inByte)
    {
        out.put(inByte);
#ifdef THROW_EXCEPTIONS
        if (out.bad())
          throw WriteErr();
#endif
    }

    void Put(const byte *inString, unsigned int length);

private:
    ofstream file;
    ostream& out;
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -