麦兜仔仔

    1. 求对txt文件进行删除行操作代码 20/11512 嵌入式系统 2010-06-02
      把分给我吧, 正好写过一个过滤的应用 #include "stdafx.h" #include #include #pragma warning(disable:4244 4267) //////////////////////////////////////////////////////////////////////////////////////////////////////// template struct Str_LookupA;                                                // ANSI字符集字符串查找模板 template struct Str_LookupW;                                                // UNICODE 字符集字串查找模板 template struct Str_Filter_Word;        // 字符串过滤模板框架 -- 只过滤输入单词 template struct Str_Filter_Line;        // 字符串过滤模板框架 -- 过滤包含输入单词段落 //////////////////////////////////////////////////////////////////////////////////////////////////////// // // 模板参数 t_fMatch, 指明查找字串是否区分大小写。 //                        t_fMatch = true,查找函数将不区分大小写 //                        t_fMatch = false, 默认方式,按照输入查找字串进行匹配 // template struct Str_LookupA {         enum { TYPE_SIZE = sizeof(CHAR)};         typedef CHAR*                _Type;         typedef const CHAR* _constType;         typedef _Type                _ReturnType;         _ReturnType operator()(_Type pSrc,_constType pSearch)         {                 return t_fMatch ? StrStrIA(pSrc,pSearch) : StrStrA(pSrc,pSearch);         }         _ReturnType LineStart(_Type pSrc,_Type pLast)         {                 _Type pStart = StrRStrIA(pSrc,pLast,"\r\n");                 return pStart ? pStart + 2 : pSrc;         }         _ReturnType LineEnd(_Type pSrc)         {                 _Type pEnd = StrStrA(pSrc,"\r\n");                 return pEnd ? pEnd + 2 : NULL;         }         DWORD Length(_constType pStr)         {                 return lstrlenA(pStr);         } }; template struct Str_LookupW {         enum { TYPE_SIZE = sizeof(WCHAR)};         typedef WCHAR*                _Type;         typedef _Type                _ReturnType;         typedef const WCHAR* _constType;         _ReturnType operator()(_Type pSrc, _constType pSearch)         {                 return t_fMatch ? StrStrIW(pSrc,pSearch) : StrStrW(pSrc,pSearch);         }         _ReturnType LineStart(_Type pSrc,_Type pLast)         {                 _Type pStart = StrRStrIW(pSrc,pLast,L"\r\n");                 return pStart ? pStart + 2 : pSrc;         }         _ReturnType LineEnd(_Type pSrc)         {                 _Type pEnd = StrStrW(pSrc,L"\r\n");                 return pEnd ? pEnd + 2 : NULL;         }         DWORD Length(_constType pStr)         {                 return lstrlenW(pStr);         } }; template struct Str_Filter_Word {         typedef typename _RT::_Type                        _Type;         typedef typename _RT::_constType        _constType;         typedef typename _RT::_ReturnType        _ReturnType;         _ReturnType operator()(_Type pBuffer, DWORD cbSize, _constType *pWord, DWORD cbCount, DWORD* pcbRemoved = NULL)         {                 ATLASSERT(pBuffer && pWord && cbSize && cbCount);                 _RT Str_Lookup;                 DWORD dwRemoved = 0;                 DWORD cbStart = 0;                 DWORD cbEnd = cbSize;                 for (DWORD i = 0; i < cbCount; i++)                 {                         _Type pStart = pBuffer;                         _Type pEnd = pBuffer + cbEnd;                         _constType pSearch = pWord[i];                         DWORD cbLength = Str_Lookup.Length(pSearch);                         if (!pSearch)                                 break;                         for (;;)                         {                                 _Type p = Str_Lookup(pStart,pSearch);                                 if (!p)        break;                                 dwRemoved++;                                 _Type pNext = p + cbLength;                                 if (pNext && pNext

最近访客

< 1/1 >

统计信息

已有82人来访过

  • 芯积分:--
  • 好友:--
  • 主题:4
  • 回复:1

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言