File indexing completed on 2024-04-28 15:35:14
0001 /*************************************************************************** 0002 * Copyright (C) 2004 by Tomas Mecir * 0003 * kmuddy@kmuddy.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU Library General Public License as * 0007 * published by the Free Software Foundation; either version 2 of the * 0008 * License, or (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU Library General Public License for more details. * 0014 ***************************************************************************/ 0015 0016 #ifndef CENTITYMANAGER_H 0017 #define CENTITYMANAGER_H 0018 0019 #include <map> 0020 #include <string> 0021 0022 using namespace std; 0023 /** 0024 This class manages entities and provides a method for expanding them in a string. 0025 0026 @author Tomas Mecir 0027 */ 0028 0029 class cEntityManager { 0030 public: 0031 cEntityManager (bool noStdEntities = false); 0032 ~cEntityManager (); 0033 0034 /** add or update entity */ 0035 void addEntity (const string &name, const string &value); 0036 /** delete entity */ 0037 void deleteEntity (const string &name); 0038 string entity (const string &name); 0039 bool exists (const string &name) { return (entities.count (name) != 0); }; 0040 /** expand entities in a string */ 0041 string expandEntities (const string &s, bool finished = true); 0042 bool needMoreText (); 0043 void reset (bool noStdEntities = false); 0044 protected: 0045 /** empty string, to speed up some things a little bit */ 0046 string empty_string; 0047 /** partial entity */ 0048 string partent; 0049 /** are we in an entity? */ 0050 bool inEntity; 0051 map <string, string> entities; 0052 }; 0053 0054 #endif