00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #ifndef _FORMENTRY_H_
00023 #define _FORMENTRY_H_ 1
00024 
00025 #ifdef __GNUG__
00026 #  pragma interface
00027 #endif
00028 
00039 #include <iostream>
00040 #include <string>
00041 #include <climits>
00042 #include <cfloat>
00043 
00044 #include "cgicc/CgiDefs.h"
00045 #include "cgicc/CgiUtils.h"
00046 
00047 CGICC_BEGIN_NAMESPACE
00048 
00049 
00050 
00051 
00052 
00068 class CGICC_API FormEntry
00069 {
00070 public:
00071   
00072   
00073 
00076 
00082   inline
00083   FormEntry()
00084     {}
00085   
00093   inline
00094   FormEntry(const STDNS string& name, 
00095             const STDNS string& value)
00096     : fName(name), fValue(value)
00097     {}
00098   
00105   inline
00106   FormEntry(const FormEntry& entry)
00107     { operator=(entry); }
00108   
00114   inline
00115   ~FormEntry()
00116     {}
00118 
00119   
00120 
00123 
00131   inline bool 
00132   operator== (const FormEntry& entry)                   const
00133     { return stringsAreEqual(fName, entry.fName); }
00134   
00142   inline bool
00143   operator!= (const FormEntry& entry)                   const
00144     { return ! operator==(entry); }
00145 
00146 #ifdef WIN32
00147   
00148   inline bool
00149   operator< (const FormEntry& entry)                    const
00150   { return false; }
00151 #endif
00152 
00160   FormEntry& 
00161   operator= (const FormEntry& entry);
00163   
00164   
00165 
00170 
00178   inline STDNS string
00179   getName()                                             const
00180     { return fName; }
00181   
00188   inline STDNS string
00189   getValue()                                            const
00190     { return fValue; }
00191   
00198   inline STDNS string
00199   operator* ()                                          const
00200     { return getValue(); }
00201   
00210   inline STDNS string
00211   getValue(STDNS string::size_type maxChars)                    const
00212     { return makeString(maxChars, true); }
00213   
00220   inline STDNS string
00221   getStrippedValue()                                    const
00222     { return getStrippedValue(INT_MAX); }
00223   
00233   inline STDNS string
00234   getStrippedValue(STDNS string::size_type maxChars)            const
00235     { return makeString(maxChars, false); }
00236   
00245   long
00246   getIntegerValue(long min = LONG_MIN, 
00247                   long max = LONG_MAX)                  const;
00248   
00257   double 
00258   getDoubleValue(double min = DBL_MIN, 
00259                  double max = DBL_MAX)                  const;
00260   
00267   inline STDNS string::size_type
00268   length()                                              const
00269     { return fValue.length(); }
00270   
00277   inline bool 
00278   isEmpty()                                             const
00279     { return (length() == 0); }
00281 
00282 private:  
00283   
00284   STDNS string
00285   makeString(STDNS string::size_type maxLen, 
00286              bool allowNewlines)                        const;
00287   
00288   STDNS string fName;           
00289   STDNS string fValue;          
00290 };
00291 
00292 CGICC_END_NAMESPACE
00293 
00294 #endif