123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.10"/>
- <title>CoffeePi: database.h Source File</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/searchdata.js"></script>
- <script type="text/javascript" src="search/search.js"></script>
- <script type="text/javascript">
- $(document).ready(function() { init_search(); });
- </script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">CoffeePi
- </div>
- <div id="projectbrief">Coffee machine control for Raspberry Pi</div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.10 -->
- <script type="text/javascript">
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- </script>
- <div id="navrow1" class="tabs">
- <ul class="tablist">
- <li><a href="index.html"><span>Main Page</span></a></li>
- <li><a href="annotated.html"><span>Data Structures</span></a></li>
- <li class="current"><a href="files.html"><span>Files</span></a></li>
- <li>
- <div id="MSearchBox" class="MSearchBoxInactive">
- <span class="left">
- <img id="MSearchSelect" src="search/mag_sel.png"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- alt=""/>
- <input type="text" id="MSearchField" value="Search" accesskey="S"
- onfocus="searchBox.OnSearchFieldFocus(true)"
- onblur="searchBox.OnSearchFieldFocus(false)"
- onkeyup="searchBox.OnSearchFieldChange(event)"/>
- </span><span class="right">
- <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
- </span>
- </div>
- </li>
- </ul>
- </div>
- <div id="navrow2" class="tabs2">
- <ul class="tablist">
- <li><a href="files.html"><span>File List</span></a></li>
- <li><a href="globals.html"><span>Globals</span></a></li>
- </ul>
- </div>
- </div><!-- top -->
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- </div>
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
- <div class="header">
- <div class="headertitle">
- <div class="title">database.h</div> </div>
- </div><!--header-->
- <div class="contents">
- <a href="database_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div>
- <div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * database.h</span></div>
- <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div>
- <div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * Created on: Dec 4, 2015</span></div>
- <div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * Author: Philipp Hinz</span></div>
- <div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> */</span></div>
- <div class="line"><a name="l00007"></a><span class="lineno"> 7</span> </div>
- <div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="preprocessor">#ifndef DATABASE_H_</span></div>
- <div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor">#define DATABASE_H_</span></div>
- <div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="preprocessor">#include <string></span></div>
- <div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="preprocessor">#include <stdexcept></span></div>
- <div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="preprocessor">#include <cstdio></span></div>
- <div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="preprocessor">#include <stdlib.h></span></div>
- <div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="preprocessor">#include <inttypes.h></span></div>
- <div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="preprocessor">#include <cstdarg></span></div>
- <div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="preprocessor">#include "sqlite/sqlite3.h"</span></div>
- <div class="line"><a name="l00017"></a><span class="lineno"> 17</span> </div>
- <div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div>
- <div class="line"><a name="l00019"></a><span class="lineno"> 19</span> </div>
- <div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment">// Config Keys</span></div>
- <div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="database_8h.html#ae1822373f950fb4881633b7ec843f4df"> 21</a></span> <span class="keyword">typedef</span> <span class="keyword">enum</span> {</div>
- <div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfa4be4c7f723934d3333a26575662e916e"> 22</a></span>  <a class="code" href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfa4be4c7f723934d3333a26575662e916e">CFGbrewcounter</a> = 1,</div>
- <div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfa3c1d629019edc36dce2a7852d3d65968"> 23</a></span>  <a class="code" href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfa3c1d629019edc36dce2a7852d3d65968">CFGHeatingTime</a> = 2,</div>
- <div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfab9f0f19359d390e5602d46e39949ede4"> 24</a></span>  <a class="code" href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfab9f0f19359d390e5602d46e39949ede4">CFGdisplaylang</a> = 3</div>
- <div class="line"><a name="l00025"></a><span class="lineno"> 25</span> } <a class="code" href="database_8h.html#ae1822373f950fb4881633b7ec843f4df">config_key_t</a>;</div>
- <div class="line"><a name="l00026"></a><span class="lineno"> 26</span> </div>
- <div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="keywordtype">int</span> <a class="code" href="database_8h.html#a1885a74e6af3ee510f30f98e60372e3e">sqlOpen</a>();</div>
- <div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="keywordtype">void</span> <a class="code" href="database_8h.html#a7264f51f982e908b32635e91e6dc0062">sqlClose</a>();</div>
- <div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="keywordtype">int</span> <a class="code" href="database_8h.html#aaed3fb776c9dc76d262df026803d3b8c">sqlSetup</a>();</div>
- <div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="keywordtype">int</span> <a class="code" href="database_8h.html#afd88a963f835215b8dad9ee9e49866dc">sqlExecute</a>(<span class="keywordtype">string</span> query);</div>
- <div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="keywordtype">char</span> *<a class="code" href="database_8h.html#a437086982a7400d7205f3ab6600e6dcf">inttochar</a>(uint8_t *guid);</div>
- <div class="line"><a name="l00032"></a><span class="lineno"> 32</span> uint8_t *<a class="code" href="database_8h.html#ad2d2a73c367513b8b71aff5546276a3c">chartoint</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *guid);</div>
- <div class="line"><a name="l00033"></a><span class="lineno"> 33</span> uint8_t *<a class="code" href="database_8h.html#a28dbbb9e24e2035535645629105aea46">int64to8bit</a>(sqlite_int64 guid);</div>
- <div class="line"><a name="l00034"></a><span class="lineno"> 34</span> sqlite_int64 <a class="code" href="database_8h.html#a99cc529fd785c752cd4b73ea7989521d">int8to64bit</a>(uint8_t *guid);</div>
- <div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="keywordtype">void</span> <a class="code" href="database_8h.html#a5d0363e5d886e2c3e4bb5ca46d265ba7">sqltest</a>();</div>
- <div class="line"><a name="l00036"></a><span class="lineno"> 36</span> std::string <a class="code" href="database_8h.html#a6c0bc3256310fd400a26243d8a8f1652">string_sprintf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* format, ...);</div>
- <div class="line"><a name="l00037"></a><span class="lineno"> 37</span> uint64_t <a class="code" href="database_8h.html#aad0e803eda7a440a6063a447cfeca0cd">sqlGetConf</a>(<a class="code" href="database_8h.html#ae1822373f950fb4881633b7ec843f4df">config_key_t</a> <span class="keywordtype">id</span>);</div>
- <div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="keywordtype">int</span> <a class="code" href="database_8h.html#a1ce0ac0c58916c138a92d3282f569784">sqlSetConf</a>(<a class="code" href="database_8h.html#ae1822373f950fb4881633b7ec843f4df">config_key_t</a> <span class="keywordtype">id</span>, uint64_t value);</div>
- <div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div>
- <div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="preprocessor">#endif </span><span class="comment">/* DATABASE_H_ */</span><span class="preprocessor"></span></div>
- <div class="ttc" id="database_8h_html_a1ce0ac0c58916c138a92d3282f569784"><div class="ttname"><a href="database_8h.html#a1ce0ac0c58916c138a92d3282f569784">sqlSetConf</a></div><div class="ttdeci">int sqlSetConf(config_key_t id, uint64_t value)</div><div class="ttdoc">Saves a configuration key to the database. </div><div class="ttdef"><b>Definition:</b> database.cpp:198</div></div>
- <div class="ttc" id="database_8h_html_a6c0bc3256310fd400a26243d8a8f1652"><div class="ttname"><a href="database_8h.html#a6c0bc3256310fd400a26243d8a8f1652">string_sprintf</a></div><div class="ttdeci">std::string string_sprintf(const char *format,...)</div><div class="ttdoc">Allows the format of printf but returns a string Source: http://codereview.stackexchange.com/questions/52522/mimic-sprintf-with-stdstring-output. </div><div class="ttdef"><b>Definition:</b> database.cpp:54</div></div>
- <div class="ttc" id="database_8h_html_ae1822373f950fb4881633b7ec843f4df"><div class="ttname"><a href="database_8h.html#ae1822373f950fb4881633b7ec843f4df">config_key_t</a></div><div class="ttdeci">config_key_t</div><div class="ttdef"><b>Definition:</b> database.h:21</div></div>
- <div class="ttc" id="namespacestd_html"><div class="ttname"><a href="namespacestd.html">std</a></div></div>
- <div class="ttc" id="database_8h_html_ad2d2a73c367513b8b71aff5546276a3c"><div class="ttname"><a href="database_8h.html#ad2d2a73c367513b8b71aff5546276a3c">chartoint</a></div><div class="ttdeci">uint8_t * chartoint(const unsigned char *guid)</div><div class="ttdoc">Converts the GUID from char to int array. </div><div class="ttdef"><b>Definition:</b> database.cpp:227</div></div>
- <div class="ttc" id="database_8h_html_a1885a74e6af3ee510f30f98e60372e3e"><div class="ttname"><a href="database_8h.html#a1885a74e6af3ee510f30f98e60372e3e">sqlOpen</a></div><div class="ttdeci">int sqlOpen()</div><div class="ttdoc">Opens and initializes a sqlite3 database connection. </div><div class="ttdef"><b>Definition:</b> database.cpp:76</div></div>
- <div class="ttc" id="database_8h_html_afd88a963f835215b8dad9ee9e49866dc"><div class="ttname"><a href="database_8h.html#afd88a963f835215b8dad9ee9e49866dc">sqlExecute</a></div><div class="ttdeci">int sqlExecute(string query)</div><div class="ttdoc">Executes a SQL statement. </div><div class="ttdef"><b>Definition:</b> database.cpp:103</div></div>
- <div class="ttc" id="database_8h_html_a7264f51f982e908b32635e91e6dc0062"><div class="ttname"><a href="database_8h.html#a7264f51f982e908b32635e91e6dc0062">sqlClose</a></div><div class="ttdeci">void sqlClose()</div><div class="ttdoc">Closes the database connection. </div><div class="ttdef"><b>Definition:</b> database.cpp:92</div></div>
- <div class="ttc" id="database_8h_html_a437086982a7400d7205f3ab6600e6dcf"><div class="ttname"><a href="database_8h.html#a437086982a7400d7205f3ab6600e6dcf">inttochar</a></div><div class="ttdeci">char * inttochar(uint8_t *guid)</div><div class="ttdoc">Converts the GUID from int to char array. </div><div class="ttdef"><b>Definition:</b> database.cpp:212</div></div>
- <div class="ttc" id="database_8h_html_a5d0363e5d886e2c3e4bb5ca46d265ba7"><div class="ttname"><a href="database_8h.html#a5d0363e5d886e2c3e4bb5ca46d265ba7">sqltest</a></div><div class="ttdeci">void sqltest()</div><div class="ttdef"><b>Definition:</b> database.cpp:258</div></div>
- <div class="ttc" id="database_8h_html_aaed3fb776c9dc76d262df026803d3b8c"><div class="ttname"><a href="database_8h.html#aaed3fb776c9dc76d262df026803d3b8c">sqlSetup</a></div><div class="ttdeci">int sqlSetup()</div><div class="ttdoc">Sets up the database and creates the needed structure. </div><div class="ttdef"><b>Definition:</b> database.cpp:150</div></div>
- <div class="ttc" id="database_8h_html_ae1822373f950fb4881633b7ec843f4dfab9f0f19359d390e5602d46e39949ede4"><div class="ttname"><a href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfab9f0f19359d390e5602d46e39949ede4">CFGdisplaylang</a></div><div class="ttdef"><b>Definition:</b> database.h:24</div></div>
- <div class="ttc" id="database_8h_html_aad0e803eda7a440a6063a447cfeca0cd"><div class="ttname"><a href="database_8h.html#aad0e803eda7a440a6063a447cfeca0cd">sqlGetConf</a></div><div class="ttdeci">uint64_t sqlGetConf(config_key_t id)</div><div class="ttdoc">Reads a configuration key from the database. </div><div class="ttdef"><b>Definition:</b> database.cpp:163</div></div>
- <div class="ttc" id="database_8h_html_a99cc529fd785c752cd4b73ea7989521d"><div class="ttname"><a href="database_8h.html#a99cc529fd785c752cd4b73ea7989521d">int8to64bit</a></div><div class="ttdeci">sqlite_int64 int8to64bit(uint8_t *guid)</div><div class="ttdef"><b>Definition:</b> database.cpp:250</div></div>
- <div class="ttc" id="database_8h_html_ae1822373f950fb4881633b7ec843f4dfa4be4c7f723934d3333a26575662e916e"><div class="ttname"><a href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfa4be4c7f723934d3333a26575662e916e">CFGbrewcounter</a></div><div class="ttdef"><b>Definition:</b> database.h:22</div></div>
- <div class="ttc" id="database_8h_html_ae1822373f950fb4881633b7ec843f4dfa3c1d629019edc36dce2a7852d3d65968"><div class="ttname"><a href="database_8h.html#ae1822373f950fb4881633b7ec843f4dfa3c1d629019edc36dce2a7852d3d65968">CFGHeatingTime</a></div><div class="ttdef"><b>Definition:</b> database.h:23</div></div>
- <div class="ttc" id="database_8h_html_a28dbbb9e24e2035535645629105aea46"><div class="ttname"><a href="database_8h.html#a28dbbb9e24e2035535645629105aea46">int64to8bit</a></div><div class="ttdeci">uint8_t * int64to8bit(sqlite_int64 guid)</div><div class="ttdoc">Converts the GUID from int64 to int8 array. </div><div class="ttdef"><b>Definition:</b> database.cpp:241</div></div>
- </div><!-- fragment --></div><!-- contents -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.10
- </small></address>
- </body>
- </html>
|