00001 /* 00002 * Copyright (C) Sergey P. Derevyago, 2003-2004. 00003 * 00004 * Permission to copy, use, modify, sell and distribute this software is granted 00005 * provided this copyright notice appears in all copies. 00006 * This software is provided "as is" without express or implied warranty, and 00007 * with no claim as to its suitability for any purpose. 00008 * 00009 */ 00010 00015 #include "textfinder.hpp" 00016 00017 using namespace std; 00018 00019 namespace { 00020 00025 class TextFinderImpl : public TextFinder { 00027 string text; 00028 00032 virtual bool findIn(const std::string& line); 00033 00034 public: 00038 TextFinderImpl(const std::string& text_) : text(text_) {} 00039 }; 00040 00041 bool TextFinderImpl::findIn(const std::string& line) 00042 { 00043 return line.find(text)!=string::npos; 00044 } 00045 00046 } 00047 00048 sh_ptr<TextFinder> Factory::newTextFinder(const std::string& mask) 00049 { 00050 try { return sh_ptr<TextFinder>(new TextFinderImpl(mask)); } 00051 catch (...) { 00052 throw newCException(_FLINE_, "Can't create TextFinderImpl object", 00053 toCException(_FLINE_)); 00054 } 00055 }