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


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

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


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

示例1: Exception

/// handy function for creating a buffer of any type - mn and mx will be cast from float or just ignored,
/// whatever is appropriate for the type.
static RawDataBuffer *createVar(int type, const char *s, int size,float mn=0,float mx=1){
    
    switch(type){
    case T_NAMEFLOAT:
        if(DataManager::findFloatBuffer(s))
            throw Exception(tok.getline()).set("variable %s already exists",s);
        else {
            printf("Adding var %s, size %d, range (%f,%f)\n",s,size,mn,mx);
            return DataManager::createFloatBuffer(s,size,mn,mx);
        }
        break;
    default:
        throw ParseException(&tok).set("unsupported type for variable %s",s);
    }
    return NULL;
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例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: parseWindow

static void parseWindow(){
    // option defaults
    bool fullScreen = false; // should it be fullscreen?
    bool disabled = false;
    // what size? (default is fit around widgets. Ignored for fullscreen.)
    int width=-1,height=-1; 
    // if set, move the window to a screen of the given dimensions
    int swidth=-1,sheight=-1;
    // title if any
    char title[256];
    // "tab" number - used to generate a shortcut to pull this window
    // to the front
    int number=-1;
    
    title[0]=0;
    int screensetline=-1;
    
    // set this window to not inverse
    ConfigManager::inverse=false;
    
    // get window options
    bool done = false;
    while(!done){
        switch(tok.getnext()){
        case T_OCURLY:
            done = true;
            break;
        case T_TITLE:
            tok.getnextstring(title);
            break;
        case T_NUMBER:
            number = tok.getnextint();
            break;
        case T_INVERSE:
            ConfigManager::inverse=true;
            break;
        case T_FULLSCREEN:
            fullScreen = true;
            break;
        case T_SIZE: // size of window if not fullscreen
            width = tok.getnextint();
            tok.getnextcheck(T_COMMA);
            height = tok.getnextint();
            break;
        case T_SCREEN: // move to a screen of given dimensions
            swidth = tok.getnextint();
            tok.getnextcheck(T_COMMA);
            screensetline = tok.getline();
            sheight = tok.getnextint();
            break;
        case T_DISABLE: // the window is disabled and should be immediately closed
            disabled=true;
            break;
        }
    }
    
    // create a window
    Window *w = getApp()->createWindow();
    if(number>=0)
        getApp()->setWindowKey(number,w);
    ConfigManager::setStyle(w);
    // and parse the contents
    parseContainer(w->centralWidget());
    
    if(*title){
        w->setWindowTitle(title);
    }
    
    // move the window if we want to
    if(swidth>0){
        QDesktopWidget *dt = QApplication::desktop();
        QRect r;
        int i;
        for(i=0;i<dt->screenCount();i++){
            r = dt->screenGeometry(i);
            printf("Found display : %d x %d\n",r.width(),r.height());
            if(r.width() == swidth && r.height()==sheight)
                break;
        }
        if(i==dt->screenCount())
            throw Exception(screensetline).set("could not find display of %d x %d",swidth,sheight);
        w->move(r.topLeft());
    }
    
    
    // finally show the window and resize if required
    if(disabled){
        w->hide(); // marked "disabled" in the config
    } else {
        w->setWindowState(Qt::WindowActive);
        w->raise();
        w->activateWindow();
        if(fullScreen){
            w->showFullScreen();
        } else {
            if(width>0)
                w->resize(width,height);
            w->showNormal();
        }
    }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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