当前位置: 首页>>代码示例>>C++>>正文


C++ Tokeniser::getnextfloat方法代码示例

本文整理汇总了C++中Tokeniser::getnextfloat方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokeniser::getnextfloat方法的具体用法?C++ Tokeniser::getnextfloat怎么用?C++ Tokeniser::getnextfloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tokeniser的用法示例。


在下文中一共展示了Tokeniser::getnextfloat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseAVar

static void parseAVar(bool diamond){
    // it's a valid type
    char buf[256];
    bool autoRange=false;
    float mn=0,mx=0;
    int size;
    RawDataBuffer *b;
    tok.getnextident(buf); // get name
    
    // 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);
        diamondapparatus::subscribe(tname);
        if(!diamondSet.contains(tname))
            diamondSet.insert(tname);
    }
#endif    
    size = tok.getnextint(); // and size
    // now get the range
    tok.getnextcheck(T_RANGE);
    switch(tok.getnext()){
    case T_INT:
    case T_FLOAT:
        mn = tok.getfloat();
        tok.getnextcheck(T_TO);
        mx = tok.getnextfloat();
        break;
    case T_AUTO:
        autoRange=true;
        break;
    default:
        throw UnexpException(&tok,"number or 'auto'");
        break;
    }
    b=createVar(T_NAMEFLOAT,buf,size,mn,mx);
    if(autoRange)
        ((DataBuffer<float>*)b)->setAutoRange();
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例2: ParseException

DataBuffer<float> *ConfigManager::parseFloatSource(){
    
    DataBuffer<float> *b;
    char buf[256];
    
    switch(tok.getnext()){
    case T_VAR:
        tok.getnextident(buf);
        b = DataManager::findFloatBuffer(buf);
        if(!b)
            throw ParseException(&tok).set("undefined variable '%s'",buf);
        break;
    case T_EXPR:
        tok.getnextstring(buf);
        // OK, we're going to lose a reference to this, but such is life.
        // In this version we never delete expressions anyway.
        try {
            b = (new Expression(buf))->buffer;
        } catch(Exception& e){
            throw Exception(e,tok.getline());
        }
        // now parse the extra bits
        tok.getnextcheck(T_RANGE);
        float mn,mx;
        switch(tok.getnext()){
        case T_INT:
        case T_FLOAT:
            mn = tok.getfloat();
            tok.getnextcheck(T_TO);
            mx = tok.getnextfloat();
            b->setMinMax(mn,mx);
            break;
        case T_AUTO:
            b->setAutoRange();
            break;
        default:
            throw UnexpException(&tok,"expected number or 'auto'");
        }
        break;
    default:
        throw UnexpException(&tok,"'var' or 'expr'");
    }
    return b;
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例3: parseWaypoint

static void parseWaypoint(){
    tok.getnextcheck(T_OCURLY);
    
    wpResetDefinitions();
    
    for(;;){
        char buf[256];
        tok.getnextcheck(T_IDENT);
        strcpy(buf,tok.getstring());
        wpAddField(buf,tok.getnextfloat());
        int t = tok.getnext();
        if(t==T_CCURLY)
            break;
        else if(t!=T_COMMA)
            throw UnexpException(&tok,"comma or '}'");
    }
    
    
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例4: parseFile

void ConfigManager::parseFile(QString fname){
    
    tok.init();
    
    tok.seterrorhandler(&tokerrorhandler);
    tok.settokens(tokens);
    tok.setcommentlinesequence("#");
    
    // read the entire file!
    QFile file(fname);
    if(!file.open(QIODevice::ReadOnly))
        throw Exception().set("could not open config file");
    QByteArray b = file.readAll();
    if(b.isNull() || b.isEmpty())
        throw Exception().set("could not read config file");
    b.append((char)0);
    file.close();
    
    const char *data = b.constData();
    
    tok.reset(data);
    
    bool done = false;
    while(!done){
        // at the top level we parse frames and
        // variables
        
        int t = tok.getnext();
        switch(t){
        case T_VAR:
            parseVars();
            break;
        case T_WINDOW:
            parseWindow();
            break;
        case T_END:
            done=true;
            break;
        case T_PORT:
            port = tok.getnextint();
            break;
        case T_SENDPORT:
            udpSendPort = tok.getnextint();
            break;
            // the UDP client now sets its address from the first packet received
            // but this will override it
        case T_SENDADDR:
            tok.getnextstring(udpSendAddr);
            UDPClient::getInstance()->setAddress(udpSendAddr);
            break;
        case T_VALIDTIME:
            DataManager::dataValidInterval = tok.getnextfloat();
            break;
        case T_SENDINTERVAL:
            sendInterval = tok.getnextfloat();
            break;
        case T_UPDATEINTERVAL:
            graphicalUpdateInterval = tok.getnextfloat()*1000;
            break;
        case T_AUDIO:
            parseAudio();
            break;
        case T_WAYPOINT:
            parseWaypoint();
            break;
        default:
            throw UnexpException(&tok,"'var', 'frame', config data or end of file");
        }
    }
    
}
开发者ID:,项目名称:,代码行数:71,代码来源:

示例5: parseLinkedVars

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;
    }
}
开发者ID:,项目名称:,代码行数:61,代码来源:


注:本文中的Tokeniser::getnextfloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。