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
|
<!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/wt-homepage/SourceView.C 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 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/wt-homepage/SourceView.C File Reference</h1><code>#include "<a class="el" href="SourceView_8h-source.html">SourceView.h</a>"</code><br>
<code>#include <iostream></code><br>
<code>#include <fstream></code><br>
<code>#include <sstream></code><br>
<code>#include <boost/algorithm/string.hpp></code><br>
<code>#include <boost/filesystem/operations.hpp></code><br>
<code>#include <boost/filesystem/convenience.hpp></code><br>
<code>#include <Wt/WApplication></code><br>
<code>#include <Wt/WText></code><br>
<code>#include <Wt/WImage></code><br>
<p>
<a href="SourceView_8C-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>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="SourceView_8C.html#e50d5388ee0cfd7d80f931509dc435cc">tempFileName</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="SourceView_8C.html#8fe8775b5b65da2de2254166ecdcc74e">getLanguageFromFileExtension</a> (const std::string &fileName)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="SourceView_8C.html#5df67bacd4ae6a5fd90b7bfd5a16f263">readFileToString</a> (const std::string &fileName)</td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="8fe8775b5b65da2de2254166ecdcc74e"></a><!-- doxytag: member="SourceView.C::getLanguageFromFileExtension" ref="8fe8775b5b65da2de2254166ecdcc74e" args="(const std::string &fileName)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string getLanguageFromFileExtension </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"> <em>fileName</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="SourceView_8C-source.html#l00061">61</a> of file <a class="el" href="SourceView_8C-source.html">SourceView.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00062"></a>00062 {
<a name="l00063"></a>00063 <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">".h"</span>)
<a name="l00064"></a>00064 || boost::iends_with(fileName, <span class="stringliteral">".C"</span>)
<a name="l00065"></a>00065 || boost::iends_with(fileName, <span class="stringliteral">".cpp"</span>))
<a name="l00066"></a>00066 <span class="keywordflow">return</span> <span class="stringliteral">"cpp"</span>;
<a name="l00067"></a>00067 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">".xml"</span>))
<a name="l00068"></a>00068 <span class="keywordflow">return</span> <span class="stringliteral">"xml"</span>;
<a name="l00069"></a>00069 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">".html"</span>))
<a name="l00070"></a>00070 <span class="keywordflow">return</span> <span class="stringliteral">"html"</span>;
<a name="l00071"></a>00071 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">".java"</span>))
<a name="l00072"></a>00072 <span class="keywordflow">return</span> <span class="stringliteral">"java"</span>;
<a name="l00073"></a>00073 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">".css"</span>))
<a name="l00074"></a>00074 <span class="keywordflow">return</span> <span class="stringliteral">"css"</span>;
<a name="l00075"></a>00075 <span class="keywordflow">else</span>
<a name="l00076"></a>00076 <span class="keywordflow">return</span> std::string();
<a name="l00077"></a>00077 }
</pre></div>
<p>
</div>
</div><p>
<a class="anchor" name="5df67bacd4ae6a5fd90b7bfd5a16f263"></a><!-- doxytag: member="SourceView.C::readFileToString" ref="5df67bacd4ae6a5fd90b7bfd5a16f263" args="(const std::string &fileName)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string readFileToString </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"> <em>fileName</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="SourceView_8C-source.html#l00079">79</a> of file <a class="el" href="SourceView_8C-source.html">SourceView.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00080"></a>00080 {
<a name="l00081"></a>00081 std::size_t outputFileSize = (std::size_t)fs::file_size(fileName);
<a name="l00082"></a>00082 std::fstream file (fileName.c_str(), std::ios::in | std::ios::binary);
<a name="l00083"></a>00083 <span class="keywordtype">char</span>* memblock = <span class="keyword">new</span> <span class="keywordtype">char</span> [outputFileSize];
<a name="l00084"></a>00084 file.read(memblock, outputFileSize);
<a name="l00085"></a>00085 file.close();
<a name="l00086"></a>00086 std::string data = std::string(memblock, outputFileSize);
<a name="l00087"></a>00087 <span class="keyword">delete</span> [] memblock;
<a name="l00088"></a>00088 <span class="keywordflow">return</span> data;
<a name="l00089"></a>00089 }
</pre></div>
<p>
</div>
</div><p>
<a class="anchor" name="e50d5388ee0cfd7d80f931509dc435cc"></a><!-- doxytag: member="SourceView.C::tempFileName" ref="e50d5388ee0cfd7d80f931509dc435cc" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string tempFileName </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="SourceView_8C-source.html#l00046">46</a> of file <a class="el" href="SourceView_8C-source.html">SourceView.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00047"></a>00047 {
<a name="l00048"></a>00048 <span class="preprocessor">#ifndef WIN32</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span> <span class="keywordtype">char</span> spool[20];
<a name="l00050"></a>00050 strcpy(spool, <span class="stringliteral">"/tmp/wtXXXXXX"</span>);
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="keywordtype">int</span> i = mkstemp(spool);
<a name="l00053"></a>00053 close(i);
<a name="l00054"></a>00054 <span class="preprocessor">#else</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span> <span class="keywordtype">char</span> spool[2 * L_tmpnam];
<a name="l00056"></a>00056 tmpnam(spool);
<a name="l00057"></a>00057 <span class="preprocessor">#endif</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span> <span class="keywordflow">return</span> std::string(spool);
<a name="l00059"></a>00059 }
</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 <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>
|