File: HangmanDb_8h-source.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 (62 lines) | stat: -rw-r--r-- 6,475 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
<!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/HangmanDb.h Source File</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>
<h1>/home/koen/project/wt/public-git/wt/examples/hangman/HangmanDb.h</h1><a href="HangmanDb_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef DB_H_</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define DB_H_</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00006"></a>00006 
<a name="l00007"></a><a class="code" href="classHangmanDb.html">00007</a> <span class="keyword">class </span><a class="code" href="classHangmanDb.html">HangmanDb</a>
<a name="l00008"></a>00008 {
<a name="l00009"></a>00009 <span class="keyword">public</span>:
<a name="l00010"></a>00010   <span class="comment">// this function returns false if user existed, true if user inserted</span>
<a name="l00011"></a>00011   <span class="comment">// It guarantees atomic userExists() checking and adding it if the user</span>
<a name="l00012"></a>00012   <span class="comment">// did not yet exits.</span>
<a name="l00013"></a>00013   <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classHangmanDb.html#0190e8b4f748d0720bc1d61eeb2a5f4b">addUser</a>(<span class="keyword">const</span> std::wstring &amp;user, <span class="keyword">const</span> std::wstring &amp;password);
<a name="l00014"></a>00014 
<a name="l00015"></a>00015   <span class="comment">// This function returns true when the credentials are found in the</span>
<a name="l00016"></a>00016   <span class="comment">// database, otherwise false</span>
<a name="l00017"></a>00017   <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classHangmanDb.html#f64e7b180549bdf218992a1b37ab0549">validLogin</a>(<span class="keyword">const</span> std::wstring &amp;user, <span class="keyword">const</span> std::wstring &amp;pass);
<a name="l00018"></a>00018 
<a name="l00019"></a>00019   <span class="comment">// Increments the number of games played, and adds delta to the score</span>
<a name="l00020"></a>00020   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classHangmanDb.html#3f039b9d0d96ca0ac8baa7bbff12f0db">addToScore</a>(<span class="keyword">const</span> std::wstring &amp;user, <span class="keywordtype">int</span> delta);
<a name="l00021"></a>00021 
<a name="l00022"></a><a class="code" href="structHangmanDb_1_1Score.html">00022</a>   <span class="keyword">struct </span><a class="code" href="structHangmanDb_1_1Score.html">Score</a> {
<a name="l00023"></a><a class="code" href="structHangmanDb_1_1Score.html#13f13771f8ae33f3373d0659ddadc5e2">00023</a>     <span class="keywordtype">int</span> <a class="code" href="structHangmanDb_1_1Score.html#13f13771f8ae33f3373d0659ddadc5e2">number</a>; <span class="comment">// position of the user</span>
<a name="l00024"></a><a class="code" href="structHangmanDb_1_1Score.html#3959752a946d56b3e48acd27b6229d21">00024</a>     std::wstring user;
<a name="l00025"></a><a class="code" href="structHangmanDb_1_1Score.html#602fc68f5609343eb9ed20b5bca2c2b5">00025</a>     <span class="keywordtype">int</span> <a class="code" href="structHangmanDb_1_1Score.html#602fc68f5609343eb9ed20b5bca2c2b5">numgames</a>;
<a name="l00026"></a><a class="code" href="structHangmanDb_1_1Score.html#26c5fb07c6654e5122e2a98659a857d8">00026</a>     <span class="keywordtype">int</span> <a class="code" href="structHangmanDb_1_1Score.html#26c5fb07c6654e5122e2a98659a857d8">score</a>;
<a name="l00027"></a><a class="code" href="structHangmanDb_1_1Score.html#2d61f30856924ebf175209d1903708f1">00027</a>     std::wstring <a class="code" href="structHangmanDb_1_1Score.html#2d61f30856924ebf175209d1903708f1">lastseen</a>; <span class="comment">// Last seen, in GMT</span>
<a name="l00028"></a>00028   };
<a name="l00029"></a>00029 
<a name="l00030"></a>00030   <span class="comment">// Returns the top n highest scoring users</span>
<a name="l00031"></a>00031   <span class="keyword">static</span> std::vector&lt;Score&gt; <a class="code" href="classHangmanDb.html#76b21f25db8d1939fcc57d9eb2e6d5c0">getHighScores</a>(<span class="keywordtype">int</span> top);
<a name="l00032"></a>00032 
<a name="l00033"></a>00033   <span class="comment">// Returns the score structure for the given user</span>
<a name="l00034"></a>00034   <span class="keyword">static</span> <a class="code" href="structHangmanDb_1_1Score.html">Score</a> <a class="code" href="classHangmanDb.html#3b623adea086ec71342220dd4f2359f7">getUserPosition</a>(<span class="keyword">const</span> std::wstring &amp;user);
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">private</span>:
<a name="l00037"></a>00037   <span class="keyword">static</span> std::string <a class="code" href="classHangmanDb.html#36c9d6aeaee2c97bbeb5e8c8b6a5bba4">DbUser</a>();
<a name="l00038"></a>00038   <span class="keyword">static</span> std::string <a class="code" href="classHangmanDb.html#c085430ceb59cac54dfd5fa90586741a">DbPass</a>();
<a name="l00039"></a>00039 };
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="preprocessor">#endif</span>
</pre></div></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>