Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > aaf33964de706a538481c929c1da6a44 > files > 3325

faust-doc-0.9.10-5mdv2010.1.x86_64.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>FAUST compiler: doc_Text.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</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 class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>doc_Text.cpp</h1><a href="doc__Text_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> ************************************************************************</span>
<a name="l00003"></a>00003 <span class="comment">    FAUST compiler</span>
<a name="l00004"></a>00004 <span class="comment">    Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale</span>
<a name="l00005"></a>00005 <span class="comment">    ---------------------------------------------------------------------</span>
<a name="l00006"></a>00006 <span class="comment">    This program is free software; you can redistribute it and/or modify</span>
<a name="l00007"></a>00007 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
<a name="l00008"></a>00008 <span class="comment">    the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00009"></a>00009 <span class="comment">    (at your option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment"></span>
<a name="l00011"></a>00011 <span class="comment">    This program is distributed in the hope that it will be useful,</span>
<a name="l00012"></a>00012 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00013"></a>00013 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00014"></a>00014 <span class="comment">    GNU General Public License for more details.</span>
<a name="l00015"></a>00015 <span class="comment"></span>
<a name="l00016"></a>00016 <span class="comment">    You should have received a copy of the GNU General Public License</span>
<a name="l00017"></a>00017 <span class="comment">    along with this program; if not, write to the Free Software</span>
<a name="l00018"></a>00018 <span class="comment">    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span>
<a name="l00019"></a>00019 <span class="comment"> ************************************************************************</span>
<a name="l00020"></a>00020 <span class="comment"> ************************************************************************/</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="doc__Text_8hh.html">doc_Text.hh</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;<a class="code" href="compatibility_8hh.html">compatibility.hh</a>&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="floats_8hh.html">floats.hh</a>&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="doc__Text_8cpp.html#a9189feb409ffc639ae0bd0a809974123">gInternDoubleSwitch</a>;
<a name="l00037"></a>00037 <span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a766bb71b31ced62a84ffda255da27d10">scientific2tenpow</a> (<span class="keywordtype">double</span> n);
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="preprocessor">#if 0</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00048"></a>00048 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="Text_8cpp.html#a1ab363a003080b60a8e1dbb926a4a0c0" title="Suppress trailing zero in a string representating a floating point number.">zdel</a>(<span class="keywordtype">char</span>* c)
<a name="l00049"></a>00049 {
<a name="l00050"></a>00050     <span class="keywordtype">int</span>     l = strlen(c) - 1;
<a name="l00051"></a>00051     <span class="keywordtype">bool</span>    f = (c[l] == <span class="charliteral">&#39;f&#39;</span>);
<a name="l00052"></a>00052 
<a name="l00053"></a>00053     <span class="keywordflow">if</span> (f) c[l--] = 0;      <span class="comment">// remove trailing if any f</span>
<a name="l00054"></a>00054     <span class="keywordflow">while</span> ( l&gt;1 &amp;&amp; c[l-1] != <span class="charliteral">&#39;.&#39;</span> &amp;&amp; c[l] == <span class="charliteral">&#39;0&#39;</span>)  c[l--] = 0;
<a name="l00055"></a>00055     <span class="keywordflow">if</span> (f) c[++l] = <span class="charliteral">&#39;f&#39;</span>;    <span class="comment">// restaure trailing f if needed</span>
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 <span class="preprocessor">#endif</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span>
<a name="l00059"></a><a class="code" href="doc__Text_8hh.html#a94cd8fa5739b11f30429fe190bf68d3c">00059</a> <span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a94cd8fa5739b11f30429fe190bf68d3c">docT</a> (<span class="keywordtype">char</span>* c)   { <span class="keywordflow">return</span> string(c); }
<a name="l00060"></a><a class="code" href="doc__Text_8hh.html#a8c66ac93ebb8988ee4e5918dcabcb181">00060</a> <span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a94cd8fa5739b11f30429fe190bf68d3c">docT</a> (<span class="keywordtype">int</span> n)     { <span class="keywordtype">char</span> c[64]; snprintf(c, 63, <span class="stringliteral">&quot;%d&quot;</span>,n);  <span class="keywordflow">return</span> string(c); }
<a name="l00061"></a><a class="code" href="doc__Text_8hh.html#abefe2aa03db6fb26473d0cb992d5a8d9">00061</a> <span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a94cd8fa5739b11f30429fe190bf68d3c">docT</a> (<span class="keywordtype">long</span> n)    { <span class="keywordtype">char</span> c[64]; snprintf(c, 63, <span class="stringliteral">&quot;%ld&quot;</span>,n); <span class="keywordflow">return</span> string(c); }
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 <span class="preprocessor">#if 0</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span><span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a94cd8fa5739b11f30429fe190bf68d3c">docT</a> (<span class="keywordtype">float</span> n)
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066     <span class="keywordtype">char</span> c[64];
<a name="l00067"></a>00067     <span class="keywordflow">if</span>  (n &lt;  0.1 &amp;&amp; n &gt; -0.1 &amp;&amp; n != 0.0) {
<a name="l00068"></a>00068         <span class="comment">//snprintf(c, 63, &quot;%e&quot;, n);//f&quot;, n);</span>
<a name="l00069"></a>00069         <span class="keywordtype">string</span> s = <a class="code" href="doc__Text_8cpp.html#a766bb71b31ced62a84ffda255da27d10">scientific2tenpow</a>(n);
<a name="l00070"></a>00070         snprintf(c, 63, <span class="stringliteral">&quot;%s&quot;</span>, s.c_str());
<a name="l00071"></a>00071     } <span class="keywordflow">else</span> {
<a name="l00072"></a>00072         snprintf(c, 63, <span class="stringliteral">&quot;%f&quot;</span>, n);<span class="comment">//f&quot;, n);</span>
<a name="l00073"></a>00073         <a class="code" href="Text_8cpp.html#a1ab363a003080b60a8e1dbb926a4a0c0" title="Suppress trailing zero in a string representating a floating point number.">zdel</a>(c);
<a name="l00074"></a>00074     }
<a name="l00075"></a>00075     <span class="keywordflow">return</span> string(c);
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 <span class="preprocessor">#endif</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>
<a name="l00084"></a><a class="code" href="doc__Text_8hh.html#ab4b332b92264231d800d8dfae3de6758">00084</a> <span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a94cd8fa5739b11f30429fe190bf68d3c">docT</a> (<span class="keywordtype">double</span> n)
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 <span class="comment">//    char c[64];</span>
<a name="l00087"></a>00087 <span class="comment">//    if  (n &lt;  0.1 &amp;&amp; n &gt; -0.1 &amp;&amp; n != 0.0) {</span>
<a name="l00088"></a>00088 <span class="comment">//        //snprintf(c, 63, &quot;%e&quot;, n); //, inumix());</span>
<a name="l00091"></a>00091 <span class="comment"></span><span class="comment">//        snprintf(c, 63, &quot;%g&quot;, n);</span>
<a name="l00092"></a>00092 <span class="comment">//    } else {</span>
<a name="l00093"></a>00093 <span class="comment">//        snprintf(c, 63, &quot;%g&quot;, n);</span>
<a name="l00094"></a>00094 <span class="comment">//        //zdel(c);</span>
<a name="l00095"></a>00095 <span class="comment">//    }</span>
<a name="l00096"></a>00096 <span class="comment">//    return string(c);</span>
<a name="l00097"></a>00097     <span class="keywordflow">return</span> <a class="code" href="doc__Text_8cpp.html#a766bb71b31ced62a84ffda255da27d10">scientific2tenpow</a>(n);
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a><a class="code" href="doc__Text_8cpp.html#a766bb71b31ced62a84ffda255da27d10">00100</a> <span class="keywordtype">string</span> <a class="code" href="doc__Text_8cpp.html#a766bb71b31ced62a84ffda255da27d10">scientific2tenpow</a> (<span class="keywordtype">double</span> n)
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102     <span class="keywordtype">char</span> tmp[64];
<a name="l00103"></a>00103     <span class="keywordtype">string</span> entree = <span class="stringliteral">&quot; * 10^{&quot;</span>;
<a name="l00104"></a>00104     <span class="keywordtype">char</span> sortie = <span class="charliteral">&#39;}&#39;</span>;
<a name="l00105"></a>00105     <span class="keywordtype">string</span> s;
<a name="l00106"></a>00106     string::size_type ps;
<a name="l00107"></a>00107     
<a name="l00108"></a>00108     snprintf(tmp, 63, <span class="stringliteral">&quot;%g&quot;</span>, n);
<a name="l00109"></a>00109     
<a name="l00110"></a>00110     <span class="comment">//cerr &lt;&lt; &quot;doc_Text.cpp : scientific2tenpow : &quot; &lt;&lt; n &lt;&lt; &quot; -&gt; \&quot;&quot; &lt;&lt; tmp &lt;&lt; &quot;\&quot;&quot; &lt;&lt; endl;</span>
<a name="l00111"></a>00111     s = tmp;
<a name="l00112"></a>00112     ps = s.find(<span class="charliteral">&#39;e&#39;</span>);
<a name="l00113"></a>00113     
<a name="l00114"></a>00114     <span class="keywordflow">if</span> (ps != string::npos) {
<a name="l00115"></a>00115         s.replace(ps, 1, <span class="stringliteral">&quot;&quot;</span>);
<a name="l00116"></a>00116         s.insert(ps, entree);
<a name="l00117"></a>00117         s += sortie;
<a name="l00118"></a>00118     }
<a name="l00119"></a>00119     <span class="keywordflow">else</span> {
<a name="l00120"></a>00120         <span class="comment">//cerr &lt;&lt; &quot;doc_Text.cpp : scientific2tenpow : \&#39;e\&#39; non trouvé&quot; &lt;&lt; endl;</span>
<a name="l00121"></a>00121     }
<a name="l00122"></a>00122         
<a name="l00123"></a>00123     <span class="keywordflow">return</span> s;
<a name="l00124"></a>00124 }
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:58 2010 for FAUST compiler by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>