FAUST compiler  0.9.9.6b8
Functions
description.cpp File Reference
#include <map>
#include <set>
#include <string>
#include "description.hh"
#include "Text.hh"
Include dependency graph for description.cpp:

Go to the source code of this file.

Functions

void extractMetadata (const string &fulllabel, string &label, map< string, set< string > > &metadata)
 Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata. More...
 
string extractName (Tree fulllabel)
 
static string xmlize (const string &fullsrc)
 removes enclosing quotes and transforms '<', '>' and '&' characters More...
 

Function Documentation

void extractMetadata ( const string &  fulllabel,
string &  label,
map< string, set< string > > &  metadata 
)

Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata.

Definition at line 14 of file description.cpp.

References rmWhiteSpaces().

Referenced by extractName(), Compiler::generateUserInterfaceTree(), Compiler::generateWidgetCode(), Compiler::generateWidgetMacro(), DocCompiler::getUIDocInfos(), and xmlize().

15 {
16  enum {kLabel, kEscape1, kEscape2, kEscape3, kKey, kValue};
17  int state = kLabel; int deep = 0;
18  string key, value;
19 
20  for (size_t i=0; i < fulllabel.size(); i++) {
21  char c = fulllabel[i];
22  switch (state) {
23  case kLabel :
24  assert (deep == 0);
25  switch (c) {
26  case '\\' : state = kEscape1; break;
27  case '[' : state = kKey; deep++; break;
28  default : label += c;
29  }
30  break;
31 
32  case kEscape1 :
33  label += c;
34  state = kLabel;
35  break;
36 
37  case kEscape2 :
38  key += c;
39  state = kKey;
40  break;
41 
42  case kEscape3 :
43  value += c;
44  state = kValue;
45  break;
46 
47  case kKey :
48  assert (deep > 0);
49  switch (c) {
50  case '\\' : state = kEscape2;
51  break;
52 
53  case '[' : deep++;
54  key += c;
55  break;
56 
57  case ':' : if (deep == 1) {
58  state = kValue;
59  } else {
60  key += c;
61  }
62  break;
63  case ']' : deep--;
64  if (deep < 1) {
65  metadata[rmWhiteSpaces(key)].insert("");
66  state = kLabel;
67  key="";
68  value="";
69  } else {
70  key += c;
71  }
72  break;
73  default : key += c;
74  }
75  break;
76 
77  case kValue :
78  assert (deep > 0);
79  switch (c) {
80  case '\\' : state = kEscape3;
81  break;
82 
83  case '[' : deep++;
84  value += c;
85  break;
86 
87  case ']' : deep--;
88  if (deep < 1) {
89  metadata[rmWhiteSpaces(key)].insert(rmWhiteSpaces(value));
90  state = kLabel;
91  key="";
92  value="";
93  } else {
94  value += c;
95  }
96  break;
97  default : value += c;
98  }
99  break;
100 
101  default :
102  cerr << "ERROR unrecognized state " << state << endl;
103  }
104  }
105  label = rmWhiteSpaces(label);
106 }
string rmWhiteSpaces(const string &s)
Definition: Text.cpp:222

Here is the call graph for this function:

Here is the caller graph for this function:

string extractName ( Tree  fulllabel)

Definition at line 110 of file description.cpp.

References extractMetadata(), name(), and tree2str().

Referenced by generateInsideSchema(), and UserInterfaceDescription().

111 {
112  string name;
113  map<string, set<string> > metadata;
114 
115  extractMetadata(tree2str(fulllabel), name, metadata);
116  return name;
117 }
void extractMetadata(const string &fulllabel, string &label, map< string, set< string > > &metadata)
Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata.
Definition: description.cpp:14
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278

Here is the call graph for this function:

Here is the caller graph for this function:

static string xmlize ( const string &  fullsrc)
static

removes enclosing quotes and transforms '<', '>' and '&' characters

Definition at line 123 of file description.cpp.

References extractMetadata().

Referenced by Description::addGroup(), Description::addWidget(), and Description::print().

124 {
125  map<string, set<string> > metadata;
126  string dst;
127  string src;
128 
129  extractMetadata(fullsrc, src, metadata);
130 
131  for (size_t i=0; i<src.size(); i++) {
132  if (src[i] == '"' & (i==0 | i==src.size()-1)) {
133  // nothing to do just skip the quotes
134  } else {
135  switch (src[i]) {
136  case '<' : dst += "&lt;"; break;
137  case '>' : dst += "&gt;"; break;
138  case '&' : dst += "&amp;"; break;
139  default : dst += src[i];
140  }
141  }
142  }
143  return dst;
144 }
void extractMetadata(const string &fulllabel, string &label, map< string, set< string > > &metadata)
Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata.
Definition: description.cpp:14

Here is the call graph for this function:

Here is the caller graph for this function: