lib/cgi/cgi-args.h
changeset 0 6f7a81934006
child 2 b3afb9f1e801
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/cgi/cgi-args.h	Wed Jan 16 22:39:43 2008 +0100
@@ -0,0 +1,52 @@
+#ifndef CHECKVPW__CGI_ARGS__H__
+#define CHECKVPW__CGI_ARGS__H__
+
+#include "mystring/mystring.h"
+
+class CGIArgs 
+{
+private:
+  struct arg
+  {
+    arg* next;
+    const mystring var;
+    const mystring val;
+    arg(mystring r, mystring l)
+      : next(0), var(r), val(l)
+      {
+      }
+    ~arg()
+      {
+	delete next;
+      }
+  };
+  arg* head;
+  arg* tail;
+  unsigned argc;
+  mystring errstr;
+protected:
+  void init();
+  void append(mystring, mystring);
+public:
+  CGIArgs() : head(0), tail(0), argc(0)
+    {
+      init();
+    }
+  ~CGIArgs();
+  bool error() const 
+    {
+      return !errstr.empty();
+    }
+  mystring errorstr() const
+    {
+      return errstr;
+    }
+  bool exists(mystring) const;
+  mystring get(mystring var, mystring dflt = 0) const;
+  mystring operator[](mystring var) const
+    {
+      return get(var);
+    }
+};
+
+#endif