Text.cpp File Reference

#include <stdio.h>
#include <string.h>
#include "Text.hh"
#include "compatibility.hh"
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <assert.h>
#include "floats.hh"
Include dependency graph for Text.cpp:

Go to the source code of this file.

Functions

static string substitution (const string &model, const vector< string > &args)
string subst (const string &model, const vector< string > &args)
string subst (const string &model, const string &a0)
string subst (const string &model, const string &a0, const string &a1)
string subst (const string &model, const string &a0, const string &a1, const string &a2)
string subst (const string &model, const string &a0, const string &a1, const string &a2, const string &a3)
string subst (const string &model, const string &a0, const string &a1, const string &a2, const string &a3, const string &a4)
string subst (const string &model, const string &a0, const string &a1, const string &a2, const string &a3, const string &a4, const string &a5)
string subst (const string &model, const string &a0, const string &a1, const string &a2, const string &a3, const string &a4, const string &a5, const string &a6)
static void zdel (char *c)
 Suppress trailing zero in a string representating a floating point number.
string T (char *c)
string T (int n)
string T (long n)
string T (double n)
 Add a trailing f when converting double-precision numbers to text if single-precision is required.
string unquote (const string &s)
 remove quotes from a string
string quote (const string &s)
 add quotes to a string

Variables

bool gInternDoubleSwitch

Function Documentation

string quote ( const string &  s  ) 

add quotes to a string

Definition at line 232 of file Text.cpp.

00233 {
00234     string q("\"");
00235     q += s;
00236     q += "\"";
00237     return q;
00238 }

string subst ( const string &  model,
const string &  a0,
const string &  a1,
const string &  a2,
const string &  a3,
const string &  a4,
const string &  a5,
const string &  a6 
)

Definition at line 131 of file Text.cpp.

References substitution().

00132 {
00133     vector<string> args(10);
00134 
00135     args[0] = a0;
00136     args[1] = a1;
00137     args[2] = a2;
00138     args[3] = a3;
00139     args[4] = a4;
00140     args[5] = a5;
00141     args[6] = a6;
00142 
00143     return substitution (model, args);
00144 }

Here is the call graph for this function:

string subst ( const string &  model,
const string &  a0,
const string &  a1,
const string &  a2,
const string &  a3,
const string &  a4,
const string &  a5 
)

Definition at line 117 of file Text.cpp.

References substitution().

00118 {
00119     vector<string> args(10);
00120 
00121     args[0] = a0;
00122     args[1] = a1;
00123     args[2] = a2;
00124     args[3] = a3;
00125     args[4] = a4;
00126     args[5] = a5;
00127 
00128     return substitution (model, args);
00129 }

Here is the call graph for this function:

string subst ( const string &  model,
const string &  a0,
const string &  a1,
const string &  a2,
const string &  a3,
const string &  a4 
)

Definition at line 104 of file Text.cpp.

References substitution().

00105 {
00106     vector<string> args(10);
00107 
00108     args[0] = a0;
00109     args[1] = a1;
00110     args[2] = a2;
00111     args[3] = a3;
00112     args[4] = a4;
00113 
00114     return substitution (model, args);
00115 }

Here is the call graph for this function:

string subst ( const string &  model,
const string &  a0,
const string &  a1,
const string &  a2,
const string &  a3 
)

Definition at line 92 of file Text.cpp.

References substitution().

00093 {
00094     vector<string> args(10);
00095 
00096     args[0] = a0;
00097     args[1] = a1;
00098     args[2] = a2;
00099     args[3] = a3;
00100 
00101     return substitution (model, args);
00102 }

Here is the call graph for this function:

string subst ( const string &  model,
const string &  a0,
const string &  a1,
const string &  a2 
)

Definition at line 81 of file Text.cpp.

References substitution().

00082 {
00083     vector<string> args(10);
00084 
00085     args[0] = a0;
00086     args[1] = a1;
00087     args[2] = a2;
00088 
00089     return substitution (model, args);
00090 }

Here is the call graph for this function:

string subst ( const string &  model,
const string &  a0,
const string &  a1 
)

Definition at line 72 of file Text.cpp.

References substitution().

00073 {
00074     vector<string> args(10);
00075     args[0] = a0;
00076     args[1] = a1;
00077 
00078     return substitution (model, args);
00079 }

Here is the call graph for this function:

string subst ( const string &  model,
const string &  a0 
)

Definition at line 65 of file Text.cpp.

References substitution().

00066 {
00067     vector<string> args(10);
00068     args[0] = a0;
00069     return substitution (model, args);
00070 }

Here is the call graph for this function:

string subst ( const string &  model,
const vector< string > &  args 
)

Definition at line 60 of file Text.cpp.

References substitution().

Referenced by Description::addGroup(), Description::addWidget(), apply_pattern_matcher(), Klass::buildTasksList(), calcNumberedName(), DocCompiler::compileLateq(), VectorCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), ScalarCompiler::compileSingleSignal(), copyFaustSources(), dlineLoop(), DocCompiler::generateBinOp(), ScalarCompiler::generateBinOp(), ScalarCompiler::generateButton(), VectorCompiler::generateCacheCode(), ScalarCompiler::generateCheckbox(), TanPrim::generateCode(), SqrtPrim::generateCode(), SinPrim::generateCode(), RintPrim::generateCode(), RemainderPrim::generateCode(), PowPrim::generateCode(), MinPrim::generateCode(), MaxPrim::generateCode(), LogPrim::generateCode(), Log10Prim::generateCode(), FmodPrim::generateCode(), FloorPrim::generateCode(), ExpPrim::generateCode(), CosPrim::generateCode(), CeilPrim::generateCode(), AtanPrim::generateCode(), Atan2Prim::generateCode(), AsinPrim::generateCode(), AcosPrim::generateCode(), DocCompiler::generateDelayLine(), ScalarCompiler::generateDelayLine(), VectorCompiler::generateDelayVec(), DocCompiler::generateDelayVecNoTemp(), ScalarCompiler::generateDelayVecNoTemp(), DocCompiler::generateDocAccessTbl(), DocCompiler::generateDocConstantTbl(), DocCompiler::generateDocWriteTbl(), DocCompiler::generateFixDelay(), VectorCompiler::generateFixDelay(), ScalarCompiler::generateFixDelay(), DocCompiler::generateFloatCast(), ScalarCompiler::generateFloatCast(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), DocCompiler::generateInput(), ScalarCompiler::generateInput(), DocCompiler::generateIntCast(), ScalarCompiler::generateIntCast(), DocCompiler::generateIota(), ScalarCompiler::generateIota(), TanPrim::generateLateq(), SqrtPrim::generateLateq(), SinPrim::generateLateq(), RintPrim::generateLateq(), RemainderPrim::generateLateq(), PowPrim::generateLateq(), MinPrim::generateLateq(), MaxPrim::generateLateq(), LogPrim::generateLateq(), Log10Prim::generateLateq(), FmodPrim::generateLateq(), FloorPrim::generateLateq(), ExpPrim::generateLateq(), CosPrim::generateLateq(), CeilPrim::generateLateq(), AtanPrim::generateLateq(), Atan2Prim::generateLateq(), AsinPrim::generateLateq(), AcosPrim::generateLateq(), AbsPrim::generateLateq(), ScalarCompiler::generateNumEntry(), DocCompiler::generateOutput(), ScalarCompiler::generateOutput(), DocCompiler::generatePrefix(), ScalarCompiler::generatePrefix(), ScalarCompiler::generateRDTbl(), DocCompiler::generateRecProj(), ScalarCompiler::generateRecProj(), DocCompiler::generateSelect2(), ScalarCompiler::generateSelect2(), DocCompiler::generateSelect3(), ScalarCompiler::generateSelect3(), ScalarCompiler::generateSigGen(), ScalarCompiler::generateStaticSigGen(), ScalarCompiler::generateStaticTable(), ScalarCompiler::generateTable(), Compiler::generateUserInterfaceTree(), DocCompiler::generateVariableStore(), VectorCompiler::generateVariableStore(), ScalarCompiler::generateVariableStore(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), Compiler::generateWidgetCode(), Compiler::generateWidgetMacro(), ScalarCompiler::generateWRTbl(), DocCompiler::getFreshID(), ScalarCompiler::getFreshID(), DocCompiler::getTypedNames(), ScalarCompiler::getTypedNames(), main(), Klass::printComputeMethodOpenMP(), Klass::printComputeMethodScalar(), Klass::printComputeMethodScheduler(), Klass::printComputeMethodVectorFaster(), Klass::printComputeMethodVectorSimple(), printDoc(), printDocDgm(), Lateq::println(), SigFloatGenKlass::println(), Klass::printOneLoopScheduler(), setSigListNickName(), subst(), substitute(), and vectorLoop().

00061 {
00062     return substitution(model, args);
00063 }

Here is the call graph for this function:

static string substitution ( const string &  model,
const vector< string > &  args 
) [static]

Definition at line 38 of file Text.cpp.

Referenced by subst().

00039 {
00040     char    c;
00041     int     i=0, ilast = model.length()-1;
00042     string  result;
00043 
00044     while (i < ilast) {
00045         c = model[i++];
00046         if (c != '$') {
00047             result += c;
00048         } else {
00049             c = model[i++];
00050             if (c >= '0' && c <= '9') {
00051                 result += args[c - '0'];
00052             } else {
00053                 result += c;
00054             }
00055         }
00056     }
00057     if (i == ilast) result += model[i];
00058     return result;
00059 }

Here is the caller graph for this function:

string T ( double  n  ) 

Add a trailing f when converting double-precision numbers to text if single-precision is required.

Definition at line 185 of file Text.cpp.

References inumix(), and zdel().

00186 {
00187     char c[64];
00188     if  (n <  0.1 && n > -0.1 && n != 0.0) {
00189         snprintf(c, 63, "%e%s", n, inumix());
00190     } else {
00191         snprintf(c, 63, "%f%s", n, inumix());
00192         zdel(c);
00193     }
00194     return string(c);
00195 }

Here is the call graph for this function:

string T ( long  n  ) 

Definition at line 165 of file Text.cpp.

00165 { char c[64]; snprintf(c, 63, "%ld",n); return string(c); }

string T ( int  n  ) 

Definition at line 164 of file Text.cpp.

00164 { char c[64]; snprintf(c, 63, "%d",n);  return string(c); }

string T ( char *  c  ) 
string unquote ( const string &  s  ) 

remove quotes from a string

Definition at line 220 of file Text.cpp.

Referenced by printdocheader(), and yyparse().

00221 {
00222     assert(s.size() >= 2);
00223     assert(s[0] == '"');
00224     assert(s[s.size()-1] == '"');
00225     return s.substr(1, s.size()-2);
00226 }

Here is the caller graph for this function:

static void zdel ( char *  c  )  [static]

Suppress trailing zero in a string representating a floating point number.

example : 1.00000 -> 1.0 example : 1.00000f -> 1.0f

Definition at line 153 of file Text.cpp.

Referenced by T().

00154 {
00155     int     l = strlen(c) - 1;
00156     bool    f = (c[l] == 'f');
00157 
00158     if (f) c[l--] = 0;      // remove trailing if any f
00159     while ( l>1 && c[l-1] != '.' && c[l] == '0')  c[l--] = 0;
00160     if (f) c[++l] = 'f';    // restaure trailing f if needed
00161 }

Here is the caller graph for this function:


Variable Documentation

Generated on Thu Apr 29 00:00:16 2010 for FAUST compiler by  doxygen 1.6.3