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.
string extractName (Tree fulllabel)
static string xmlize (const string &fullsrc)
 removes enclosing quotes and transforms '<', '>' and '&' characters

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().

{
    enum {kLabel, kEscape1, kEscape2, kEscape3, kKey, kValue};
    int state = kLabel; int deep = 0;
    string key, value;

    for (size_t i=0; i < fulllabel.size(); i++) {
        char c = fulllabel[i];
        switch (state) {
            case kLabel :
                assert (deep == 0);
                switch (c) {
                    case '\\' : state = kEscape1; break;
                    case '[' : state = kKey; deep++; break;
                    default : label += c;
                }
                break;

            case kEscape1 :
                label += c;
                state = kLabel;
                break;

            case kEscape2 :
                key += c;
                state = kKey;
                break;

            case kEscape3 :
                value += c;
                state = kValue;
                break;

            case kKey :
                assert (deep > 0);
                switch (c) {
                    case '\\' :  state = kEscape2;
                                break;

                    case '[' :  deep++;
                                key += c;
                                break;

                    case ':' :  if (deep == 1) {
                                    state = kValue;
                                } else {
                                    key += c;
                                }
                                break;
                    case ']' :  deep--;
                                if (deep < 1) {
                                    metadata[rmWhiteSpaces(key)].insert("");
                                    state = kLabel;
                                    key="";
                                    value="";
                                } else {
                                    key += c;
                                }
                                break;
                    default :   key += c;
                }
                break;

            case kValue :
                assert (deep > 0);
                switch (c) {
                    case '\\' : state = kEscape3;
                                break;

                    case '[' :  deep++;
                                value += c;
                                break;

                    case ']' :  deep--;
                                if (deep < 1) {
                                    metadata[rmWhiteSpaces(key)].insert(rmWhiteSpaces(value));
                                    state = kLabel;
                                    key="";
                                    value="";
                                } else {
                                    value += c;
                                }
                                break;
                    default :   value += c;
                }
                break;

            default :
                cerr << "ERROR unrecognized state " << state << endl;
        }
    }
    label = rmWhiteSpaces(label);
}

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().

{
    string name;
    map<string, set<string> >   metadata;

    extractMetadata(tree2str(fulllabel), name, metadata);
    return name;
}

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().

{
    map<string, set<string> > metadata;
    string dst;
    string src;

    extractMetadata(fullsrc, src, metadata);

    for (size_t i=0; i<src.size(); i++) {
        if (src[i] == '"' & (i==0 | i==src.size()-1)) {
            // nothing to do just skip the quotes
        } else {
            switch (src[i]) {
                case '<' : dst += "&lt;"; break;
                case '>' : dst += "&gt;"; break;
                case '&' : dst += "&amp;"; break;
                default :  dst += src[i];
            }
        }
    }
    return dst;
}

Here is the call graph for this function:

Here is the caller graph for this function: