Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > b3a1f4d91c26f535919e39e25606614a > files > 186

wt-doc-3.2.3-1.fc18.noarch.rpm

<!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"/>
<title>Wt examples: /home/koen/project/wt/public-git/wt/examples/wt-homepage/SourceView.C File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Wt examples
   &#160;<span id="projectnumber">3.2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;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 id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">/home/koen/project/wt/public-git/wt/examples/wt-homepage/SourceView.C File Reference</div>  </div>
</div>
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="SourceView_8h_source.html">SourceView.h</a>&quot;</code><br/>
<code>#include &lt;iostream&gt;</code><br/>
<code>#include &lt;fstream&gt;</code><br/>
<code>#include &lt;sstream&gt;</code><br/>
<code>#include &lt;stdlib.h&gt;</code><br/>
<code>#include &lt;boost/algorithm/string.hpp&gt;</code><br/>
<code>#include &lt;boost/filesystem/operations.hpp&gt;</code><br/>
<code>#include &lt;boost/filesystem/convenience.hpp&gt;</code><br/>
<code>#include &lt;Wt/WApplication&gt;</code><br/>
<code>#include &lt;Wt/WText&gt;</code><br/>
<code>#include &lt;Wt/WImage&gt;</code><br/>
</div>
<p><a href="SourceView_8C_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="SourceView_8C.html#ae50d5388ee0cfd7d80f931509dc435cc">tempFileName</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="SourceView_8C.html#a8fe8775b5b65da2de2254166ecdcc74e">getLanguageFromFileExtension</a> (const std::string &amp;fileName)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="SourceView_8C.html#a5df67bacd4ae6a5fd90b7bfd5a16f263">readFileToString</a> (const std::string &amp;fileName)</td></tr>
</table>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a8fe8775b5b65da2de2254166ecdcc74e"></a><!-- doxytag: member="SourceView.C::getLanguageFromFileExtension" ref="a8fe8775b5b65da2de2254166ecdcc74e" args="(const std::string &amp;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 &amp;&#160;</td>
          <td class="paramname"><em>fileName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="SourceView_8C_source.html#l00063">63</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">&quot;.h&quot;</span>)
      || boost::iends_with(fileName, <span class="stringliteral">&quot;.C&quot;</span>)
      || boost::iends_with(fileName, <span class="stringliteral">&quot;.cpp&quot;</span>))
    <span class="keywordflow">return</span> <span class="stringliteral">&quot;cpp&quot;</span>;
  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">&quot;.xml&quot;</span>))
    <span class="keywordflow">return</span> <span class="stringliteral">&quot;xml&quot;</span>;
  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">&quot;.html&quot;</span>))
    <span class="keywordflow">return</span> <span class="stringliteral">&quot;html&quot;</span>;
  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">&quot;.java&quot;</span>)) 
    <span class="keywordflow">return</span> <span class="stringliteral">&quot;java&quot;</span>;
  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">&quot;.js&quot;</span>)) 
    <span class="keywordflow">return</span> <span class="stringliteral">&quot;javascript&quot;</span>;
  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (boost::iends_with(fileName, <span class="stringliteral">&quot;.css&quot;</span>)) 
    <span class="keywordflow">return</span> <span class="stringliteral">&quot;css&quot;</span>;
  <span class="keywordflow">else</span>
    <span class="keywordflow">return</span> std::string();
} 
</pre></div>
</div>
</div>
<a class="anchor" id="a5df67bacd4ae6a5fd90b7bfd5a16f263"></a><!-- doxytag: member="SourceView.C::readFileToString" ref="a5df67bacd4ae6a5fd90b7bfd5a16f263" args="(const std::string &amp;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 &amp;&#160;</td>
          <td class="paramname"><em>fileName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="SourceView_8C_source.html#l00083">83</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p>
<div class="fragment"><pre class="fragment">{
  std::size_t outputFileSize = (std::size_t)fs::file_size(fileName);
  std::fstream file (fileName.c_str(), std::ios::in | std::ios::binary);
  <span class="keywordtype">char</span>* memblock = <span class="keyword">new</span> <span class="keywordtype">char</span> [outputFileSize];
  file.read(memblock, (std::streamsize)outputFileSize);
  file.close();
  std::string data = std::string(memblock, outputFileSize);
  <span class="keyword">delete</span> [] memblock;
  <span class="keywordflow">return</span> data;
}
</pre></div>
</div>
</div>
<a class="anchor" id="ae50d5388ee0cfd7d80f931509dc435cc"></a><!-- doxytag: member="SourceView.C::tempFileName" ref="ae50d5388ee0cfd7d80f931509dc435cc" 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>Definition at line <a class="el" href="SourceView_8C_source.html#l00048">48</a> of file <a class="el" href="SourceView_8C_source.html">SourceView.C</a>.</p>
<div class="fragment"><pre class="fragment">{
<span class="preprocessor">#ifndef WIN32</span>
<span class="preprocessor"></span>  <span class="keywordtype">char</span> spool[20];
  strcpy(spool, <span class="stringliteral">&quot;/tmp/wtXXXXXX&quot;</span>);

  <span class="keywordtype">int</span> i = mkstemp(spool);
  close(i);
<span class="preprocessor">#else</span>
<span class="preprocessor"></span>  <span class="keywordtype">char</span> spool[2 * L_tmpnam];
  tmpnam(spool);
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>  <span class="keywordflow">return</span> std::string(spool);
}
</pre></div>
</div>
</div>
</div>
<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by&nbsp;<a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>