FAUST compiler  0.9.9.6b8
Classes | Functions
description.hh File Reference
#include <string>
#include <list>
#include <set>
#include <map>
#include "signals.hh"
#include "smartpointer.hh"
#include "tlib.hh"
#include "uitree.hh"
Include dependency graph for description.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Description

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)

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: