Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXStringDict.h
Go to the documentation of this file.
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,2006 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.16 2006/01/22 17:58:10 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 {
39 protected:
40  virtual void *createData(const void*);
41  virtual void deleteData(void*);
42 public:
43 
44  /// Construct a string dictionary
45  FXStringDict();
46 
47  /// Copy constructor
48  FXStringDict(const FXStringDict& orig);
49 
50  /// Assignment operator
51  FXStringDict &operator=(const FXStringDict& orig);
52 
53  /// Insert a new string indexed by key, with given mark flag
54  const FXchar* insert(const FXchar* ky,const FXchar* str,bool mrk=false){ return (const FXchar*)FXDict::insert(ky,str,mrk); }
55 
56  /// Replace or insert a new string indexed by key, unless given mark is lower that the existing mark
57  const FXchar* replace(const FXchar* ky,const FXchar* str,bool mrk=false){ return (const FXchar*)FXDict::replace(ky,str,mrk); }
58 
59  /// Remove entry indexed by key
60  const FXchar* remove(const FXchar* ky){ return (const FXchar*)FXDict::remove(ky); }
61 
62  /// Return the entry indexed by key, or return NULL if the key does not exist
63  const FXchar* find(const FXchar* ky) const { return (const FXchar*)FXDict::find(ky); }
64 
65  /// Return the string at position pos
66  const FXchar* data(FXuint pos) const { return (const FXchar*)dict[pos].data; }
67 
68  /// Destructor
69  virtual ~FXStringDict();
70  };
71 
72 }
73 
74 #endif
void * find(const FXchar *ky) const
Find data pointer given key.
char FXchar
Definition: fxdefs.h:387
unsigned int FXuint
Definition: fxdefs.h:396
#define FXAPI
Definition: fxdefs.h:122
void * insert(const FXchar *ky, const void *ptr, bool mrk=false)
Insert a new entry into the table given key and mark.
String dictionary maps a character string to a character string.
Definition: FXStringDict.h:37
void * remove(const FXchar *ky)
Remove data given key.
The dictionary class maintains a fast-access hash table of entities indexed by a character string...
Definition: FXDict.h:41
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
void * replace(const FXchar *ky, const void *ptr, bool mrk=false)
Replace data at key, if the entry's mark is less than or equal to the given mark. ...

Copyright © 1997-2005 Jeroen van der Zijp