1 /******************************************************************************** 2 * * 3 * S t r i n g D i c t i o n a r y C l a s s * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1998,2005 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXStringDict.h,v 1.12 2005/01/16 16:06:06 fox Exp $ * 23 ********************************************************************************/ 24 #ifndef FXSTRINGDICT_H 25 #define FXSTRINGDICT_H 26 27 #ifndef FXDICT_H 28 #include "FXDict.h" 29 #endif 30 31 namespace FX { 32 33 /** 34 * String dictionary maps a character string to a character string. 35 * The inserted strings are copied when they're inserted. 36 */ 37 class FXAPI FXStringDict : public FXDict { 38 FXDECLARE(FXStringDict) 39 protected: 40 virtual void *createData(const void*); 41 virtual void deleteData(void*); 42 private: 43 FXStringDict(const FXStringDict&); 44 FXStringDict &operator=(const FXStringDict&); 45 public: 46 47 /// Construct a string dictionary 48 FXStringDict(); 49 50 /// Insert a new string indexed by key, with given mark flag 51 const FXchar* insert(const FXchar* ky,const FXchar* str,FXbool mrk=FALSE){ return (const FXchar*)FXDict::insert(ky,str,mrk); } 52 53 /// Replace or insert a new string indexed by key, unless given mark is lower that the existing mark 54 const FXchar* replace(const FXchar* ky,const FXchar* str,FXbool mrk=FALSE){ return (const FXchar*)FXDict::replace(ky,str,mrk); } 55 56 /// Remove entry indexed by key remove(const FXchar * ky)57 const FXchar* remove(const FXchar* ky){ return (const FXchar*)FXDict::remove(ky); } 58 59 /// Return the entry indexed by key, or return NULL if the key does not exist find(const FXchar * ky)60 const FXchar* find(const FXchar* ky) const { return (const FXchar*)FXDict::find(ky); } 61 62 /// Return the string at position pos data(FXuint pos)63 const FXchar* data(FXuint pos) const { return (const FXchar*)dict[pos].data; } 64 65 /// Destructor 66 virtual ~FXStringDict(); 67 }; 68 69 } 70 71 #endif 72