Source-highlight Library
|
00001 /* 00002 * Copyright (C) 1999-2009 Lorenzo Bettini, http://www.lorenzobettini.it 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 * 00018 */ 00019 00020 #ifndef _CHARTRANSLATOR_H 00021 #define _CHARTRANSLATOR_H 00022 00023 #define NUM_OF_CHARS 256 00024 00025 #include <string> 00026 #include <boost/regex.hpp> 00027 00028 #include "preformatter.h" 00029 00030 namespace srchilite { 00031 00039 class CharTranslator: public PreFormatter { 00040 protected: 00042 unsigned int counter; 00044 std::string translation_exp; 00046 std::string translation_format; 00048 boost::regex *reg_exp; 00050 bool bol; 00051 00057 virtual const std::string doPreformat(const std::string &text); 00058 00059 public: 00063 CharTranslator(PreFormatterPtr f = PreFormatterPtr()); 00064 virtual ~CharTranslator(); 00065 00071 void set_translation(const std::string &s1, const std::string &s2); 00072 00077 const std::string toString() const { 00078 return translation_exp + " -> " + translation_format; 00079 } 00080 }; 00081 00082 typedef boost::shared_ptr<CharTranslator> CharTranslatorPtr; 00083 00084 } 00085 00086 #endif // _CHARTRANSLATOR_H