Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

FormEntry.h

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /*
00003  *  $Id: FormEntry_8h-source.html,v 1.1.1.3 2004/06/19 04:36:23 chrisb Exp $
00004  *
00005  *  Copyright (C) 1996 - 2003 Stephen F. Booth
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Lesser General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Lesser General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Lesser General Public
00018  *  License along with this library; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 namespace cgicc {
00048   
00049   // ============================================================
00050   // Class FormEntry
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 std::string& name, 
00095               const std::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     /* Dummy operator for MSVC++ */
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 std::string
00179     getName()                                           const
00180     { return fName; }
00181     
00188     inline std::string
00189     getValue()                                          const
00190     { return fValue; }
00191     
00198     inline std::string
00199     operator* ()                                        const
00200     { return getValue(); }
00201     
00210     inline std::string
00211     getValue(std::string::size_type maxChars)           const
00212     { return makeString(maxChars, true); }
00213     
00220     inline std::string
00221     getStrippedValue()                                  const
00222     { return getStrippedValue(INT_MAX); }
00223     
00233     inline std::string
00234     getStrippedValue(std::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     
00259     long
00260     getIntegerValue(long min, 
00261                     long max,
00262                     bool& bounded)                      const;
00263     
00272     double 
00273     getDoubleValue(double min = -DBL_MAX, 
00274                    double max = DBL_MAX)                const;
00275     
00286     double 
00287     getDoubleValue(double min, 
00288                    double max,
00289                    bool& bounded)                       const;
00290     
00291     
00298     inline std::string::size_type
00299     length()                                            const
00300     { return fValue.length(); }
00301     
00308     inline bool 
00309     isEmpty()                                           const
00310     { return (length() == 0); }
00312     
00313   private:  
00314     // utility function
00315     std::string
00316     makeString(std::string::size_type maxLen, 
00317                bool allowNewlines)                      const;
00318     
00319     std::string fName;          // the name of this form element
00320     std::string fValue;         // the value of this form element
00321   };
00322   
00323 } // namespace cgicc
00324 
00325 #endif /* ! _FORMENTRY_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2004 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Sat Jun 19 00:36:23 2004 for cgicc by doxygen 1.3.6