Exemplo n.º 1
0
ConfigRect ConfigManager::parseRect(){
    ConfigRect r;
    r.x = tok.getnextint(); // either just x,y..
    tok.getnextcheck(T_COMMA);
    r.y = tok.getnextint();
    if(tok.getnext()==T_COMMA){ // or x,y,w,h
        r.w = tok.getnextint();
        tok.getnextcheck(T_COMMA);
        r.h = tok.getnextint();
    }else{
        tok.rewind();
        r.w = 1; r.h = 1;
    }
    if(tok.getnext() == T_SIZE){
        r.minsizex = tok.getnextint();
        if(tok.getnext()==T_COMMA){
            r.minsizey = tok.getnextint();
        }else{
            r.minsizey = r.minsizex;
            tok.rewind();
        }
    }else
          tok.rewind();
    return r;
}
Exemplo n.º 2
0
void parseLinkedVars(bool diamond){
    char buf[256];
    int size,type;
    RawDataBuffer *linkvar,*b;
    if(tok.getnext()!=T_OPREN)
        throw UnexpException(&tok,"( after linked");
    linkedVars.clear();
    for(;;){
        double mn,mx;
        char buf[256];
        // get type
        type = tok.getnext();
        // get name
        tok.getnextident(buf);
        // if diamond, get topic and datum index
        char tname[256];
        int idx;
#if DIAMOND
        if(diamond){
            tok.getnextcheck(T_TOPIC);
            tok.getnextident(tname);
            tok.getnextcheck(T_COMMA);
            idx = tok.getnextint();
            diamondMap[DiamondTopicKey(tname,idx)]=QString(buf);
            if(!diamondSet.contains(tname))
                diamondSet.insert(tname);
            diamondapparatus::subscribe(tname);
        }
#endif
        // now the range
        tok.getnextcheck(T_RANGE);
        mn = tok.getnextfloat();
        tok.getnextcheck(T_TO);
        mx = tok.getnextfloat();
        
        // add to a list!
        linkedVars.append(LinkedVarEntry(buf,type,mn,mx));
        if(tok.getnext()!=T_COMMA){
            tok.rewind();
            break;
        }
    }
    if(tok.getnext()!=T_CPREN)
        throw UnexpException(&tok,") after linked var list");
    if(tok.getnext()!=T_INT)
        throw UnexpException(&tok,"buffer size after linked var list");
    size = tok.getint();
    
    linkvar = NULL;
    for(int i=0;i<linkedVars.size();i++){
        b = createVar(linkedVars[i].type,
                      linkedVars[i].name,
                      size,
                      linkedVars[i].minVal,
                      linkedVars[i].maxVal);
        if(linkvar)
            linkvar->link(b);
        else
            linkvar = b;
    }
}