/*
_____       _    _    Corso   Italia,  178
(_|__   .  (_   |_|_  56125           Pisa
(_|_) |)|(()_)()| |   tel.  +39  050 46380
  |   |               picosoft@picosoft.it

 picocpp - basic objects library for picoSQL 

 Copyright (C) Picosoft s.r.l. 1994-2002

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
# ifndef pkeybjct_h
# define pkeybjct_h "$Id$"
# include "plist.h"
# include "piteratr.h"
# include "pstring.h"

class PKeyObject : public PObject
{
   PCLASS(PKeyObject,PObject)
   PString key;
   PObject *value;
public:
   PKeyObject(const char * c) {
      key = c;
      value = 0;
   }
   PKeyObject(const PString &k, PObject *o = 0) {
      key = k;
      value = o;
   }
   PKeyObject(const PKeyObject &p) {
      key = p.key;
      value = p.value;
   }
   ~PKeyObject() {}
   const PString & getKey() {
      return key;
   }
   void changeKey(const PString &newKey) {
      key = newKey;
   }
   PObject * getValue() {
      return value;
   }
   void setValue(PObject *o) {
      value = o;
   }
};

PLIST (PKeyObject);
PITERATOR (PKeyObject);

# define PKEYOBJECT(a) \
class a##KeyObject : public PKeyObject \
{ \
public: \
   a##KeyObject(const char * c) : PKeyObject(c) { } \
   a##KeyObject(const PString &k, a *o = 0) : PKeyObject (k,o) { } \
   a * getValue() { return (a *) PKeyObject::getValue(); } \
   void setValue(a * o) { PKeyObject::setValue(o); } \
};

PKEYOBJECT(PString);
PLIST(PStringKeyObject);
PITERATOR (PStringKeyObject);

# endif
