Index: trunk/gsdl/lib/cgiargs.cpp
===================================================================
--- trunk/gsdl/lib/cgiargs.cpp	(revision 105)
+++ trunk/gsdl/lib/cgiargs.cpp	(revision 105)
@@ -0,0 +1,105 @@
+/**********************************************************************
+ *
+ * cgiargs.cpp -- 
+ * Copyright (C) 1999  The New Zealand Digital Library Project
+ *
+ * PUT COPYRIGHT NOTICE HERE
+ *
+ * $Id$
+ *
+ *********************************************************************/
+
+/*
+   $Log$
+   Revision 1.1  1999/01/08 07:50:30  rjmcnab
+
+   Moved from src/library directory to lib directory.
+
+ */
+
+static char *RCSID = "$Id$";
+
+
+#include "cgiargs.h"
+#include "gsdlunicode.h"
+
+  
+// constructors
+cgiargsclass::cgiargsclass ()
+{
+}
+
+
+// this returns NULL if there isn't an entry with a value of
+// 'key' already defined
+
+void cgiargsclass::setarg (const text_t &key, const text_t &value)
+{
+  args[key] = value;
+}
+
+void cgiargsclass::setdefaultarg (const text_t &key, const text_t &value)
+{
+  if (getarg(key) == NULL) setarg (key, value);
+}
+
+void cgiargsclass::setintarg (const text_t &key, int value)
+{
+  setarg (key, value);
+}
+
+void cgiargsclass::setdefaultintarg (const text_t &key, int value)
+{
+  if (getarg(key) == NULL) setintarg (key, value);
+}
+
+void cgiargsclass::setcarg (const text_t &key, unsigned short c)
+{
+  text_t t; 
+  t.push_back(c);
+  setarg(key,t);
+}
+
+void cgiargsclass::setdefaultcarg (const text_t &key, unsigned short c)
+{
+  if (getarg(key) == NULL) setcarg (key, c);
+}
+
+text_t *cgiargsclass::getarg (const text_t &key)
+{
+  iterator here = args.find (key);
+  if (here == args.end()) return NULL;
+
+  return &((*here).second);
+}
+
+int cgiargsclass::getintarg (const text_t &key)
+{
+  text_t *text = getarg (key);
+  if (text == NULL) return 0;
+  return text->getint();
+}
+
+
+
+// stream operators to print cgi arguments for debugging purposes
+ostream &operator<<(ostream &outs, const cgiargsclass &args)
+{
+  utf8outconvertclass text_t2utf8;
+  cgiargsclass::const_iterator here = args.begin ();
+  cgiargsclass::const_iterator end = args.end ();
+
+  outs << "*** cgiargsclass\n";
+  
+  while (here != end)
+    {
+      outs << text_t2utf8 << " \"" << (*here).first << "\"=\"" << 
+	(*here).second << "\"\n";
+      here++;
+    }
+  outs << "\n";
+
+  return outs;
+}
+
+
Index: trunk/gsdl/lib/cgiargs.h
===================================================================
--- trunk/gsdl/lib/cgiargs.h	(revision 105)
+++ trunk/gsdl/lib/cgiargs.h	(revision 105)
@@ -0,0 +1,97 @@
+/**********************************************************************
+ *
+ * cgiargs.h -- 
+ * Copyright (C) 1999  The New Zealand Digital Library Project
+ *
+ * PUT COPYRIGHT NOTICE HERE
+ *
+ * $Id$
+ *
+ *********************************************************************/
+
+
+#ifndef CGIARGS_H
+#define CGIARGS_H
+
+
+#ifdef __GNUG__
+#  include <ostream.h>
+#else
+#  ifndef USE_OBJECTSPACE
+#    include <ostream>
+#  else
+#    include <ospace\std\ostream>
+#  endif
+#endif
+
+#ifndef USE_OBJECTSPACE
+#  include <map>
+#else
+#  include <ospace\std\map>
+#endif
+
+
+#include "text_t.h"
+
+typedef map<text_t, text_t, lttext_t> textmap;
+
+
+class cgiargsclass
+{
+protected:
+  textmap args;
+
+public:
+  //type support for textmap
+  typedef textmap::iterator iterator;
+  typedef textmap::const_iterator const_iterator;
+  typedef textmap::reference reference;
+  typedef textmap::const_reference const_reference;
+  typedef textmap::size_type size_type;
+  typedef textmap::difference_type difference_type;
+  typedef textmap::const_reverse_iterator const_reverse_iterator;
+  typedef textmap::reverse_iterator reverse_iterator;
+  
+  // constructors
+  cgiargsclass ();
+
+  // basic container support
+  iterator begin () {return args.begin();}
+  const_iterator begin () const {return args.begin();}
+  iterator end () {return args.end();}
+  const_iterator end () const {return args.end();}
+
+  void erase(iterator pos) {args.erase(pos);}
+  void erase(iterator first, iterator last) {args.erase(first, last);}
+  cgiargsclass &operator=(const cgiargsclass &x) {args=x.args;return *this;}
+
+  bool empty () const {return args.empty();}
+  size_type size() const {return args.size();}
+
+
+  // added functionality
+  void clear () {args.erase(args.begin(),args.end());}
+
+  // setdefaultarg, setdefaultintarg, and setdefaultcarg will 
+  // only set the argument if it is not already set
+  // getargs NULLs if there isn't an entry with
+  // 'key' already defined, getintarg returns 0 if there wasn't an
+  // entry with 'key' defined and operator[] returns "" if
+  // 'key' wasn't already defined (and sets 'key'="").
+  void setarg (const text_t &key, const text_t &value);
+  void setdefaultarg (const text_t &key, const text_t &value); 
+  void setintarg (const text_t &key, int value);
+  void setdefaultintarg (const text_t &key, int value);
+  void setcarg (const text_t &key, unsigned short c);
+  void setdefaultcarg (const text_t &key, unsigned short c);
+  text_t *getarg (const text_t &key);
+  int getintarg (const text_t &key);
+  text_t &operator[] (const text_t &key) {return args[key];}
+};
+
+
+// stream operators to print cgi arguments for debugging purposes
+ostream &operator<<(ostream &outs, const cgiargsclass &args);
+
+
+#endif
