1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt examples: DateValidator Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>DateValidator Class Reference<br>
<small>
[<a class="el" href="group__formexample.html">Form example</a>]</small>
</h1><!-- doxytag: class="DateValidator" --><!-- doxytag: inherits="Wt::WRegExpValidator" -->A validator that accepts dates.
<a href="#_details">More...</a>
<p>
<code>#include <<a class="el" href="DateValidator_8h-source.html">DateValidator.h</a>></code>
<p>
<div class="dynheader">
Inheritance diagram for DateValidator:</div>
<div class="dynsection">
<p><center><img src="classDateValidator__inherit__graph.png" border="0" usemap="#DateValidator__inherit__map" alt="Inheritance graph"></center>
<map name="DateValidator__inherit__map">
<area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WRegExpValidator.html" title="Wt::WRegExpValidator" alt="" coords="5,155,157,181"><area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html" title="Wt::WValidator" alt="" coords="28,80,135,107"><area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html" title="Wt::WObject" alt="" coords="33,5,129,32"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>
<p>
<a href="classDateValidator-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classDateValidator.html#1de946017ced5d2c0493372383fefbd8">DateValidator</a> (const boost::gregorian::date &bottom, const boost::gregorian::date &top)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a date validator. <a href="#1de946017ced5d2c0493372383fefbd8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual <a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a3">State</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classDateValidator.html#aaa584cefc1adeee0c48c9e4ef8b5c63">validate</a> (<a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">WString</a> &input) const </td></tr>
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">boost::gregorian::date </td><td class="memItemRight" valign="bottom"><a class="el" href="classDateValidator.html#1826a737ba4425fba84ece0eaa04c7fa">bottom_</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">boost::gregorian::date </td><td class="memItemRight" valign="bottom"><a class="el" href="classDateValidator.html#6709f13942f4208dc65815a9d12e56b7">top_</a></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A validator that accepts dates.
<p>
This example validator only accepts input in the dd/mm/yyyy format, and checks that the date is in the right range.<p>
It would be a natural thing to extend this class to provide access to the parsed date as a boost::gregorian::date object for example.<p>
This class is part of the Wt form example.
<p>Definition at line <a class="el" href="DateValidator_8h-source.html#l00033">33</a> of file <a class="el" href="DateValidator_8h-source.html">DateValidator.h</a>.</p>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="1de946017ced5d2c0493372383fefbd8"></a><!-- doxytag: member="DateValidator::DateValidator" ref="1de946017ced5d2c0493372383fefbd8" args="(const boost::gregorian::date &bottom, const boost::gregorian::date &top)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">DateValidator::DateValidator </td>
<td>(</td>
<td class="paramtype">const boost::gregorian::date & </td>
<td class="paramname"> <em>bottom</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const boost::gregorian::date & </td>
<td class="paramname"> <em>top</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Construct a date validator.
<p>
The validator will accept only dates in the indicated range.
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="aaa584cefc1adeee0c48c9e4ef8b5c63"></a><!-- doxytag: member="DateValidator::validate" ref="aaa584cefc1adeee0c48c9e4ef8b5c63" args="(WString &input) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a3">WValidator::State</a> DateValidator::validate </td>
<td>(</td>
<td class="paramtype"><a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">WString</a> & </td>
<td class="paramname"> <em>input</em> </td>
<td> ) </td>
<td> const<code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Reimplemented from <a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WRegExpValidator.html#cd0bc1ff9dc23f4f34c6840e3d0d5edc">Wt::WRegExpValidator</a>.</p>
<p>Definition at line <a class="el" href="DateValidator_8C-source.html#l00026">26</a> of file <a class="el" href="DateValidator_8C-source.html">DateValidator.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00027"></a>00027 {
<a name="l00028"></a>00028 <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a3">WValidator::State</a> state = WRegExpValidator::validate(input);
<a name="l00029"></a>00029
<a name="l00030"></a>00030 std::string text = input.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html#159d088da6e8f2be1035b2341889254c">toUTF8</a>();
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keywordflow">if</span> ((state == <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a31bc2acb7589ab9e3050867ebfc32dda3">Valid</a>) && !text.empty()) {
<a name="l00033"></a>00033 boost::smatch what;
<a name="l00034"></a>00034 boost::regex_match(text, what, boost::regex(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WRegExpValidator.html#d4af69a61c23bf59db1b7c6bedf56311">regExp</a>().toUTF8()));
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="keywordflow">try</span> {
<a name="l00037"></a>00037 date d
<a name="l00038"></a>00038 = from_string(what[3] + <span class="stringliteral">"/"</span> + what[2] + <span class="stringliteral">"/"</span> + what[1]);
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="keywordflow">if</span> ((d >= <a class="code" href="classDateValidator.html#1826a737ba4425fba84ece0eaa04c7fa">bottom_</a>) && (d <= <a class="code" href="classDateValidator.html#6709f13942f4208dc65815a9d12e56b7">top_</a>))
<a name="l00041"></a>00041 <span class="keywordflow">return</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a31bc2acb7589ab9e3050867ebfc32dda3">Valid</a>;
<a name="l00042"></a>00042 <span class="keywordflow">else</span>
<a name="l00043"></a>00043 <span class="keywordflow">return</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a3a5bf750faac5f1ca6fb58c8de97bac51">Invalid</a>;
<a name="l00044"></a>00044
<a name="l00045"></a>00045 } <span class="keywordflow">catch</span> (std::exception& e) {
<a name="l00046"></a>00046 <span class="keywordflow">return</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WValidator.html#638a1feefca259ea2f806a8add2d18a3a5bf750faac5f1ca6fb58c8de97bac51">Invalid</a>;
<a name="l00047"></a>00047 }
<a name="l00048"></a>00048 } <span class="keywordflow">else</span>
<a name="l00049"></a>00049 <span class="keywordflow">return</span> state;
<a name="l00050"></a>00050 }
</pre></div>
<p>
</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="1826a737ba4425fba84ece0eaa04c7fa"></a><!-- doxytag: member="DateValidator::bottom_" ref="1826a737ba4425fba84ece0eaa04c7fa" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">boost::gregorian::date <a class="el" href="classDateValidator.html#1826a737ba4425fba84ece0eaa04c7fa">DateValidator::bottom_</a><code> [private]</code> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="DateValidator_8h-source.html#l00050">50</a> of file <a class="el" href="DateValidator_8h-source.html">DateValidator.h</a>.</p>
</div>
</div><p>
<a class="anchor" name="6709f13942f4208dc65815a9d12e56b7"></a><!-- doxytag: member="DateValidator::top_" ref="6709f13942f4208dc65815a9d12e56b7" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">boost::gregorian::date <a class="el" href="classDateValidator.html#6709f13942f4208dc65815a9d12e56b7">DateValidator::top_</a><code> [private]</code> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="DateValidator_8h-source.html#l00050">50</a> of file <a class="el" href="DateValidator_8h-source.html">DateValidator.h</a>.</p>
</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li>/home/koen/project/wt/public-git/wt/examples/form/<a class="el" href="DateValidator_8h-source.html">DateValidator.h</a><li>/home/koen/project/wt/public-git/wt/examples/form/<a class="el" href="DateValidator_8C-source.html">DateValidator.C</a></ul>
</div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:12 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>
|