File: Dictionary_8h.html

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (124 lines) | stat: -rw-r--r-- 7,342 bytes parent folder | download
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
<!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: /home/koen/project/wt/public-git/wt/examples/hangman/Dictionary.h File 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&nbsp;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><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>/home/koen/project/wt/public-git/wt/examples/hangman/Dictionary.h File Reference</h1><code>#include &lt;string&gt;</code><br>

<p>
<a href="Dictionary_8h-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Enumerations</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f9">Dictionary</a> { <a class="el" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f9d50f9a7fcbf407c389ff3834333ac719">DICT_EN</a> =  0, 
<a class="el" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f97b7a0d1c13d5ae5a4e27e17b7b6e26c1">DICT_NL</a> =  1
 }</td></tr>

<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">std::wstring&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="Dictionary_8h.html#ddb438135bbc4b68a5ff5b6c6dfa5dd4">RandomWord</a> (<a class="el" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f9">Dictionary</a> dictionary)</td></tr>

</table>
<hr><h2>Enumeration Type Documentation</h2>
<a class="anchor" name="75d0a1670704923e348986686c3714f9"></a><!-- doxytag: member="Dictionary.h::Dictionary" ref="75d0a1670704923e348986686c3714f9" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f9">Dictionary</a>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<dl compact><dt><b>Enumerator: </b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" name="75d0a1670704923e348986686c3714f9d50f9a7fcbf407c389ff3834333ac719"></a><!-- doxytag: member="DICT_EN" ref="75d0a1670704923e348986686c3714f9d50f9a7fcbf407c389ff3834333ac719" args="" -->DICT_EN</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" name="75d0a1670704923e348986686c3714f97b7a0d1c13d5ae5a4e27e17b7b6e26c1"></a><!-- doxytag: member="DICT_NL" ref="75d0a1670704923e348986686c3714f97b7a0d1c13d5ae5a4e27e17b7b6e26c1" args="" -->DICT_NL</em>&nbsp;</td><td>
</td></tr>
</table>
</dl>

<p>Definition at line <a class="el" href="Dictionary_8h-source.html#l00012">12</a> of file <a class="el" href="Dictionary_8h-source.html">Dictionary.h</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00012"></a>00012                 {
<a name="l00013"></a>00013   <a class="code" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f9d50f9a7fcbf407c389ff3834333ac719">DICT_EN</a> = 0,
<a name="l00014"></a>00014   <a class="code" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f97b7a0d1c13d5ae5a4e27e17b7b6e26c1">DICT_NL</a> = 1
<a name="l00015"></a>00015 };
</pre></div>
<p>

</div>
</div><p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="ddb438135bbc4b68a5ff5b6c6dfa5dd4"></a><!-- doxytag: member="Dictionary.h::RandomWord" ref="ddb438135bbc4b68a5ff5b6c6dfa5dd4" args="(Dictionary dictionary)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::wstring RandomWord           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f9">Dictionary</a>&nbsp;</td>
          <td class="paramname"> <em>dictionary</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>

<p>Definition at line <a class="el" href="Dictionary_8C-source.html#l00015">15</a> of file <a class="el" href="Dictionary_8C-source.html">Dictionary.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00016"></a>00016 {
<a name="l00017"></a>00017    std::ifstream dict;
<a name="l00018"></a>00018    <span class="keywordflow">if</span>(dictionary == <a class="code" href="Dictionary_8h.html#75d0a1670704923e348986686c3714f97b7a0d1c13d5ae5a4e27e17b7b6e26c1">DICT_NL</a>) {
<a name="l00019"></a>00019       dict.open(<span class="stringliteral">"dict-nl.txt"</span>);
<a name="l00020"></a>00020    } <span class="keywordflow">else</span> { <span class="comment">// english is default</span>
<a name="l00021"></a>00021       dict.open(<span class="stringliteral">"dict.txt"</span>);
<a name="l00022"></a>00022    }
<a name="l00023"></a>00023       
<a name="l00024"></a>00024    std::string retval;
<a name="l00025"></a>00025    <span class="keywordtype">int</span> numwords = 0;
<a name="l00026"></a>00026    <span class="keywordflow">while</span>(dict) {
<a name="l00027"></a>00027       getline(dict, retval);
<a name="l00028"></a>00028       numwords++;
<a name="l00029"></a>00029    }
<a name="l00030"></a>00030    dict.clear();
<a name="l00031"></a>00031    dict.seekg(0);
<a name="l00032"></a>00032 
<a name="l00033"></a>00033    srand(time(0));
<a name="l00034"></a>00034    <span class="keywordtype">int</span> selection = rand() % numwords; <span class="comment">// not entirely uniform, but who cares?</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036    <span class="keywordflow">while</span>(selection--) {
<a name="l00037"></a>00037       getline(dict, retval);
<a name="l00038"></a>00038    }
<a name="l00039"></a>00039    getline(dict, retval);
<a name="l00040"></a>00040    <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; retval.size(); ++i)
<a name="l00041"></a>00041       <span class="keywordflow">if</span>(retval[i] &lt; <span class="charliteral">'A'</span> || retval[i] &gt; <span class="charliteral">'Z'</span>)
<a name="l00042"></a>00042          std::cout &lt;&lt; <span class="stringliteral">"word "</span> &lt;&lt; retval &lt;&lt; <span class="stringliteral">" contains illegal data at pos "</span> &lt;&lt; i &lt;&lt; std::endl;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044    <span class="keywordflow">return</span> Wt::widen(retval);
<a name="l00045"></a>00045 }
</pre></div>
<p>

</div>
</div><p>
</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&nbsp;<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>