TMyBuffer.cpp
上传用户:haiweijt
上传日期:2018-02-23
资源大小:8195k
文件大小:1k
- // TMyBuffer.cpp: implementation of the TMyBuffer class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "TMyBuffer.h"
- #include <stdio.h>
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- TMyBuffer::TMyBuffer()
- {
- m_Offset = 0;
- }
- TMyBuffer::~TMyBuffer()
- {
- }
- void TMyBuffer::WriteString(char *str)
- {
- FILE* fp = fopen("c:\1.txt","at");
- fprintf(fp, "%s",str);
- fclose(fp);
- }
- void TMyBuffer::Write(char *buf, int size)
- {
- if (size == 0)
- return;
- unsigned char tmpc = *(unsigned char *)buf;
- switch(tmpc)
- {
- case 8:
- m_Offset --;
- break;
- case 13:
- m_Buffer[m_Offset++] = 'x0d';
- break;
- case 10:
- m_Buffer[m_Offset++] = 'x0a';
- m_Buffer[m_Offset] = ' ';
- WriteString(m_Buffer);
- m_Offset = 0;
- break;
- default:
- m_Buffer[m_Offset++] = buf[0];
- break;
- }
- Write(buf+1, size-1);
- }