<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html lang="en" dir="LTR"> <head> <!-- $Id: header.html,v 1.5 2004/06/12 01:58:25 sbooth Exp $ --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>cgicc: FormEntry.h Source File</title> <link rev="made" href="mailto:bug-cgicc@gnu.org" /> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="cgicc-doc.css" rel="stylesheet" type="text/css" /> </head> <body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>FormEntry.h</h1><a href="FormEntry_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*-mode:c++; c-file-style: "gnu";-*- */</span> <a name="l00002"></a>00002 <span class="comment">/*</span> <a name="l00003"></a>00003 <span class="comment"> * $Id: FormEntry.h,v 1.14 2007/07/02 18:48:18 sebdiaz Exp $</span> <a name="l00004"></a>00004 <span class="comment"> *</span> <a name="l00005"></a>00005 <span class="comment"> * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org></span> <a name="l00006"></a>00006 <span class="comment"> * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com></span> <a name="l00007"></a>00007 <span class="comment"> * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * This library is free software; you can redistribute it and/or</span> <a name="l00010"></a>00010 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span> <a name="l00011"></a>00011 <span class="comment"> * License as published by the Free Software Foundation; either</span> <a name="l00012"></a>00012 <span class="comment"> * version 3 of the License, or (at your option) any later version.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> * This library is distributed in the hope that it will be useful,</span> <a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00017"></a>00017 <span class="comment"> * Lesser General Public License for more details.</span> <a name="l00018"></a>00018 <span class="comment"> *</span> <a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span> <a name="l00020"></a>00020 <span class="comment"> * License along with this library; if not, write to the Free Software</span> <a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA </span> <a name="l00022"></a>00022 <span class="comment"> */</span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="preprocessor">#ifndef _FORMENTRY_H_</span> <a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define _FORMENTRY_H_ 1</span> <a name="l00026"></a>00026 <span class="preprocessor"></span> <a name="l00027"></a>00027 <span class="preprocessor">#ifdef __GNUG__</span> <a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor"># pragma interface</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00030"></a>00030 <span class="preprocessor"></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <iostream></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <string></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <climits></span> <a name="l00044"></a>00044 <span class="preprocessor">#include <cfloat></span> <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="CgiDefs_8h.html" title="Platform and operating system specific macro definitions.">cgicc/CgiDefs.h</a>"</span> <a name="l00047"></a>00047 <span class="preprocessor">#include "<a class="code" href="CgiUtils_8h.html" title="A collection of utility functions.">cgicc/CgiUtils.h</a>"</span> <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="keyword">namespace </span>cgicc { <a name="l00050"></a>00050 <a name="l00051"></a>00051 <span class="comment">// ============================================================</span> <a name="l00052"></a>00052 <span class="comment">// Class FormEntry</span> <a name="l00053"></a>00053 <span class="comment">// ============================================================</span> <a name="l00054"></a>00054 <a name="l00070"></a><a class="code" href="classcgicc_1_1FormEntry.html">00070</a> <span class="keyword">class </span>CGICC_API <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a> <a name="l00071"></a>00071 { <a name="l00072"></a>00072 <span class="keyword">public</span>: <a name="l00073"></a>00073 <a name="l00074"></a>00074 <span class="comment">// ============================================================</span> <a name="l00075"></a>00075 <a name="l00078"></a>00078 <a name="l00084"></a>00084 <span class="keyword">inline</span> <a name="l00085"></a><a class="code" href="classcgicc_1_1FormEntry.html#4fe98ef071864400d758eca907cef970">00085</a> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>() <a name="l00086"></a>00086 {} <a name="l00087"></a>00087 <a name="l00095"></a>00095 <span class="keyword">inline</span> <a name="l00096"></a><a class="code" href="classcgicc_1_1FormEntry.html#bf89b26203879825966b658b82e035c8">00096</a> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>(<span class="keyword">const</span> std::string& name, <a name="l00097"></a>00097 <span class="keyword">const</span> std::string& value) <a name="l00098"></a>00098 : fName(name), fValue(value) <a name="l00099"></a>00099 {} <a name="l00100"></a>00100 <a name="l00107"></a>00107 <span class="keyword">inline</span> <a name="l00108"></a><a class="code" href="classcgicc_1_1FormEntry.html#51306a47774c09a95007749f93628f62">00108</a> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>(<span class="keyword">const</span> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>& entry) <a name="l00109"></a>00109 { operator=(entry); } <a name="l00110"></a>00110 <a name="l00116"></a>00116 <span class="keyword">inline</span> <a name="l00117"></a><a class="code" href="classcgicc_1_1FormEntry.html#2a95ff5eb17b7d565d43acb25dd78c4f">00117</a> ~<a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>() <a name="l00118"></a>00118 {} <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="comment">// ============================================================</span> <a name="l00122"></a>00122 <a name="l00125"></a>00125 <a name="l00133"></a>00133 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a name="l00134"></a><a class="code" href="classcgicc_1_1FormEntry.html#b21ccc5c526908917d82ef7b0f7a8464">00134</a> operator== (<span class="keyword">const</span> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>& entry)<span class="keyword"> const</span> <a name="l00135"></a>00135 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="namespacecgicc.html#355209b76eb905b0ae9ea3521976f8de" title="Compare two strings for equality, ignoring case.">stringsAreEqual</a>(fName, entry.fName); } <a name="l00136"></a>00136 <a name="l00144"></a>00144 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a name="l00145"></a><a class="code" href="classcgicc_1_1FormEntry.html#86cf849d036749e2cb4722ee502df068">00145</a> operator!= (<span class="keyword">const</span> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>& entry)<span class="keyword"> const</span> <a name="l00146"></a>00146 <span class="keyword"> </span>{ <span class="keywordflow">return</span> ! operator==(entry); } <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="preprocessor">#ifdef WIN32</span> <a name="l00149"></a>00149 <span class="preprocessor"></span> <span class="comment">/* Dummy operator for MSVC++ */</span> <a name="l00150"></a>00150 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a name="l00151"></a>00151 operator< (<span class="keyword">const</span> <a class="code" href="classcgicc_1_1FormEntry.html" title="Class representing a single HTML form entry.">FormEntry</a>& entry)<span class="keyword"> const</span> <a name="l00152"></a>00152 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00153"></a>00153 <span class="preprocessor">#endif</span> <a name="l00154"></a>00154 <span class="preprocessor"></span> <a name="l00162"></a>00162 FormEntry& <a name="l00163"></a>00163 operator= (<span class="keyword">const</span> FormEntry& entry); <a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="comment">// ============================================================</span> <a name="l00167"></a>00167 <a name="l00172"></a>00172 <a name="l00180"></a>00180 <span class="keyword">inline</span> std::string <a name="l00181"></a><a class="code" href="classcgicc_1_1FormEntry.html#4d70968c8f54c6485121dacb5f629c36">00181</a> getName()<span class="keyword"> const</span> <a name="l00182"></a>00182 <span class="keyword"> </span>{ <span class="keywordflow">return</span> fName; } <a name="l00183"></a>00183 <a name="l00190"></a>00190 <span class="keyword">inline</span> std::string <a name="l00191"></a><a class="code" href="classcgicc_1_1FormEntry.html#48516a8bfb2e0fd45213fd9343ac4631">00191</a> <a class="code" href="namespaceCardGameTools.html#fd019ba73719b7ce9fa3d61bffc3ecfc" title="Get all personnal information from the cookie&#39;s Id.">getValue</a>()<span class="keyword"> const</span> <a name="l00192"></a>00192 <span class="keyword"> </span>{ <span class="keywordflow">return</span> fValue; } <a name="l00193"></a>00193 <a name="l00200"></a>00200 <span class="keyword">inline</span> std::string <a name="l00201"></a><a class="code" href="classcgicc_1_1FormEntry.html#478bd6404ed6f33c70774cdc31cfbcd0">00201</a> operator* ()<span class="keyword"> const</span> <a name="l00202"></a>00202 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="namespaceCardGameTools.html#fd019ba73719b7ce9fa3d61bffc3ecfc" title="Get all personnal information from the cookie&#39;s Id.">getValue</a>(); } <a name="l00203"></a>00203 <a name="l00212"></a>00212 <span class="keyword">inline</span> std::string <a name="l00213"></a><a class="code" href="classcgicc_1_1FormEntry.html#d9c4e04f65aab2161aa3cedb64f4b390">00213</a> <a class="code" href="namespaceCardGameTools.html#fd019ba73719b7ce9fa3d61bffc3ecfc" title="Get all personnal information from the cookie&#39;s Id.">getValue</a>(std::string::size_type maxChars)<span class="keyword"> const</span> <a name="l00214"></a>00214 <span class="keyword"> </span>{ <span class="keywordflow">return</span> makeString(maxChars, <span class="keyword">true</span>); } <a name="l00215"></a>00215 <a name="l00222"></a>00222 <span class="keyword">inline</span> std::string <a name="l00223"></a><a class="code" href="classcgicc_1_1FormEntry.html#72a8808d78ba5227a87a7acf24e2911b">00223</a> getStrippedValue()<span class="keyword"> const</span> <a name="l00224"></a>00224 <span class="keyword"> </span>{ <span class="keywordflow">return</span> <a class="code" href="classcgicc_1_1FormEntry.html#72a8808d78ba5227a87a7acf24e2911b" title="Get the value of the form element as a string.">getStrippedValue</a>(INT_MAX); } <a name="l00225"></a>00225 <a name="l00235"></a>00235 <span class="keyword">inline</span> std::string <a name="l00236"></a><a class="code" href="classcgicc_1_1FormEntry.html#9b3f165094c4e158f212b871cc3e9d2a">00236</a> getStrippedValue(std::string::size_type maxChars)<span class="keyword"> const</span> <a name="l00237"></a>00237 <span class="keyword"> </span>{ <span class="keywordflow">return</span> makeString(maxChars, <span class="keyword">false</span>); } <a name="l00238"></a>00238 <a name="l00247"></a>00247 <span class="keywordtype">long</span> <a name="l00248"></a>00248 getIntegerValue(<span class="keywordtype">long</span> min = LONG_MIN, <a name="l00249"></a>00249 <span class="keywordtype">long</span> max = LONG_MAX) <span class="keyword">const</span>; <a name="l00250"></a>00250 <a name="l00261"></a>00261 <span class="keywordtype">long</span> <a name="l00262"></a>00262 getIntegerValue(<span class="keywordtype">long</span> min, <a name="l00263"></a>00263 <span class="keywordtype">long</span> max, <a name="l00264"></a>00264 <span class="keywordtype">bool</span>& bounded) <span class="keyword">const</span>; <a name="l00265"></a>00265 <a name="l00274"></a>00274 <span class="keywordtype">double</span> <a name="l00275"></a>00275 getDoubleValue(<span class="keywordtype">double</span> min = -DBL_MAX, <a name="l00276"></a>00276 <span class="keywordtype">double</span> max = DBL_MAX) <span class="keyword">const</span>; <a name="l00277"></a>00277 <a name="l00288"></a>00288 <span class="keywordtype">double</span> <a name="l00289"></a>00289 getDoubleValue(<span class="keywordtype">double</span> min, <a name="l00290"></a>00290 <span class="keywordtype">double</span> max, <a name="l00291"></a>00291 <span class="keywordtype">bool</span>& bounded) <span class="keyword">const</span>; <a name="l00292"></a>00292 <a name="l00293"></a>00293 <a name="l00300"></a>00300 <span class="keyword">inline</span> std::string::size_type <a name="l00301"></a><a class="code" href="classcgicc_1_1FormEntry.html#7c5a604bd278a2db2fa3ba818146b827">00301</a> length()<span class="keyword"> const</span> <a name="l00302"></a>00302 <span class="keyword"> </span>{ <span class="keywordflow">return</span> fValue.length(); } <a name="l00303"></a>00303 <a name="l00310"></a>00310 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a name="l00311"></a><a class="code" href="classcgicc_1_1FormEntry.html#a08d7843e43977b31efda50d689d8ab6">00311</a> isEmpty()<span class="keyword"> const</span> <a name="l00312"></a>00312 <span class="keyword"> </span>{ <span class="keywordflow">return</span> (0 == length()); } <a name="l00314"></a>00314 <a name="l00315"></a>00315 <span class="keyword">private</span>: <a name="l00316"></a>00316 <span class="comment">// utility function</span> <a name="l00317"></a>00317 std::string <a name="l00318"></a>00318 makeString(std::string::size_type maxLen, <a name="l00319"></a>00319 <span class="keywordtype">bool</span> allowNewlines) <span class="keyword">const</span>; <a name="l00320"></a>00320 <a name="l00321"></a>00321 std::string fName; <span class="comment">// the name of this form element</span> <a name="l00322"></a>00322 std::string fValue; <span class="comment">// the value of this form element</span> <a name="l00323"></a>00323 }; <a name="l00324"></a>00324 <a name="l00325"></a>00325 } <span class="comment">// namespace cgicc</span> <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="preprocessor">#endif </span><span class="comment">/* ! _FORMENTRY_H_ */</span> </pre></div></div> <!-- $Id: footer.html,v 1.7 2004/06/12 01:58:25 sbooth Exp $ --> <hr> <address><small> <a href="http://www.cgicc.org">GNU cgicc</a> - A C++ class library for writing CGI applications<br /> Copyright © 1996 - 2004 <a href="mailto:sboothATgnuDOTorg">Stephen F. Booth</a><br /> 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.<br /> Documentation generated Tue Jun 9 15:30:16 2009 for cgicc by <a HREF="http://www.doxygen.org/index.html">doxygen</a> 1.5.9 </small></address> </body> </html>