14 void extractMetadata(
const string& fulllabel,
string& label, map<
string, set<string> >& metadata)
16 enum {kLabel, kEscape1, kEscape2, kEscape3, kKey, kValue};
17 int state = kLabel;
int deep = 0;
20 for (
size_t i=0; i < fulllabel.size(); i++) {
21 char c = fulllabel[i];
26 case '\\' : state = kEscape1;
break;
27 case '[' : state = kKey; deep++;
break;
50 case '\\' : state = kEscape2;
57 case ':' :
if (deep == 1) {
80 case '\\' : state = kEscape3;
102 cerr <<
"ERROR unrecognized state " << state << endl;
113 map<string, set<string> > metadata;
123 static string xmlize(
const string& fullsrc)
125 map<string, set<string> > metadata;
131 for (
size_t i=0; i<src.size(); i++) {
132 if (src[i] ==
'"' & (i==0 | i==src.size()-1)) {
136 case '<' : dst +=
"<";
break;
137 case '>' : dst +=
">";
break;
138 case '&' : dst +=
"&";
break;
139 default : dst += src[i];
148 list<string>::iterator s;
149 list<int>::iterator t;
151 tab(n,fout); fout <<
"<faust>";
159 tab(n+1,fout); fout <<
"<inputs>" <<
fInputs <<
"</inputs>";
160 tab(n+1,fout); fout <<
"<outputs>" <<
fOutputs <<
"</outputs>";
162 tab(n+1,fout); fout <<
"<ui>";
165 tab(n+2,fout); fout <<
"<activewidgets>";
168 tab(n+3, fout); fout << *s;
170 tab(n+2,fout); fout <<
"</activewidgets>";
175 tab(n+2,fout); fout <<
"<passivewidgets>";
178 tab(n+3, fout); fout << *s;
180 tab(n+2,fout); fout <<
"</passivewidgets>";
186 tab(n+2,fout); fout <<
"<layout>";
189 tab(n+3+*t, fout); fout << *s;
191 tab(n+2,fout); fout <<
"</layout>";
193 tab(n+1,fout); fout <<
"</ui>";
196 tab(n,fout); fout <<
"</faust>" << endl;
208 Tree label, elements, varname, sig;
209 const char* groupnames[] = {
"vgroup",
"hgroup",
"tgroup"};
218 while (!
isNil(elements)) {
220 elements =
tl(elements);
224 }
else if (
isUiWidget(t, label, varname, sig)) {
231 fprintf(stderr,
"error in user interface generation 2\n");
240 while (n--) fout <<
'\t';
245 Tree path, c, x, y, z;
332 fprintf(stderr,
"Error describing widget : unrecognized expression\n");
bool isSigHSlider(Tree s)
void tab(int n, ostream &fout)
bool isSigCheckbox(Tree s)
bool isSigNumEntry(Tree s)
list< string > fLayoutLines
list< string > fActiveLines
int tree2int(Tree t)
if t has a node of type int, return it otherwise error
int addWidget(Tree label, Tree varname, Tree sig)
void addActiveLine(const string &l)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
void addGroup(int level, Tree t)
bool isSigVBargraph(Tree s)
bool isSigVSlider(Tree s)
void print(int n, ostream &fout)
string subst(const string &model, const vector< string > &args)
Text substitution.
bool isSigHBargraph(Tree s)
void extractMetadata(const string &fulllabel, string &label, map< string, set< string > > &metadata)
Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata.
bool isUiWidget(Tree t, Tree &label, Tree &varname, Tree &sig)
string rmWhiteSpaces(const string &s)
string extractName(Tree fulllabel)
const char * name(Symbol *sym)
Returns the name of a symbol.
list< string > fPassiveLines
double tree2double(Tree t)
if t has a node of type float, return it otherwise error
void addPassiveLine(const string &l)
static string xmlize(const string &fullsrc)
removes enclosing quotes and transforms '<', '>' and '&' characters
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
void addLayoutLine(int n, const string &l)