// ScanFile.cpp : Implementation of CScanFile #include "stdafx.h" #include "ScanFile.h" #include ".\scanfile.h" using namespace std; using namespace Scanner; // CScanFile STDMETHODIMP CScanFile::putFile(BSTR file) { CComBSTR bstr(file); const char* name = (COLE2T)bstr; in.open(name); if(!in.good()) { MessageBox(0,"open failed",name,MB_OK); return E_FAIL; } return S_OK; } STDMETHODIMP CScanFile::get(ULONG* size, BSTR** semiExp) { if(pToker == 0 || pSemi == 0) { pToker = new CToker(&in); pToker->registerDefaultFilters(); pSemi = new CSemiExp(pToker); pSemi->registerDefaultFilters(); } pSemi->get(); pSemi->stripLeadingNewLines(); *size = (ULONG)(pSemi->length()); *semiExp = (BSTR*)CoTaskMemAlloc(pSemi->length() * sizeof(BSTR)); for(unsigned int i=0; ilength(); ++i) { CComBSTR temp((LPCSTR)(*pSemi)[i].c_str()); (*semiExp)[i] = SysAllocString(temp); } return S_OK; }