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


C++ OSTRINGSTREAM类代码示例

本文整理汇总了C++中OSTRINGSTREAM的典型用法代码示例。如果您正苦于以下问题:C++ OSTRINGSTREAM类的具体用法?C++ OSTRINGSTREAM怎么用?C++ OSTRINGSTREAM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: init

bool ScriptLocalBroker::init(const char* szcmd, const char* szparam,
            const char* szhost, const char* szstdio,
            const char* szworkdir, const char* szenv )
{
    OSTRINGSTREAM strDevParam;
    std::string strParam;
    std::string strCmd;
    if(szcmd)
    {
        yarp::os::Bottle possiblePaths = parsePaths(yarp::os::NetworkBase::getEnvironment("PATH"));
        for (size_t i=0; i<possiblePaths.size(); ++i)
        {
            std::string guessString=possiblePaths.get(i).asString() + slash + szcmd;
            const char* guess=guessString.c_str();
            if (fileExists (guess))
            {
#if defined(_WIN32)
                strCmd = "\"" + std::string(guess) + "\"";
#else
                strCmd = guess;
#endif
                break;
            }
        }

    }
    if(strCmd=="")
        return false;
    if(szparam) strParam = szparam;
    strDevParam<<strCmd<<" "<<strParam;
    return LocalBroker::init(script.c_str(), strDevParam.str().c_str(),
                                szhost, szstdio, szworkdir, szenv);
     }
开发者ID:robotology,项目名称:yarp,代码行数:33,代码来源:scriptbroker.cpp

示例2: throw

//
// close()
//
void SSLOutputStream::close()
    throw(IOException)
{

  int ret = SSL_shutdown(_ssl);

  if (ret == 2) 
    ret = SSL_shutdown(_ssl);

  if (!ret) {

    int ssl_error = SSL_get_error(_ssl, ret);
    int error = ERR_get_error();
    
    OSTRINGSTREAM reason;
    reason << "SSLOutputStream::close error: ";
      
    switch(ssl_error) {
      case SSL_ERROR_NONE:
        reason << "SSL_ERROR_NONE reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_WANT_READ:
        reason << "SSL_ERROR_WANT_READ reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_WANT_WRITE:
        reason << "SSL_ERROR_WANT_WRITE reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_ZERO_RETURN:
        reason << "SSL_ERROR_ZERO_RETURN reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_WANT_CONNECT:
        reason << "SSL_ERROR_WANT_CONNECT reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_WANT_X509_LOOKUP:
        reason << "SSL_ERROR_WANT_X509_LOOKUP reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_SYSCALL:
        reason << "SSL_ERROR_SYSCALL reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      case SSL_ERROR_SSL:
        reason << "SSL_ERROR_SSL reason: " << ERR_reason_error_string(error) << ends;
        throw IOException(reason.str().c_str());
        break;
      default:
        reason << "unknown: " << ends;
        throw IOException(reason.str().c_str());
    }
  }


}
开发者ID:AlvaroVega,项目名称:TIDorbC,代码行数:61,代码来源:SSLOutputStream.C

示例3: addWarning

void MessagesList::addWarning( const char* warning)
{
    OSTRINGSTREAM msg;
    msg<<"[WAR]:   "<<warning;
    Gtk::TreeModel::Row row = *(m_refListStore->append());
    row.set_value(0, Glib::ustring(msg.str()));
    row[m_Columns.m_col_color] = Gdk::Color("#FFF6C8");
    m_TreeView.scroll_to_row( m_refListStore->get_path(row));
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:9,代码来源:message_list.cpp

示例4: addError

void MessagesList::addError(const char* error)
{
    OSTRINGSTREAM msg;
    msg<<"[ERR]:   "<<error;
    Gtk::TreeModel::Row row = *(m_refListStore->append());
    row.set_value(0, Glib::ustring(msg.str()));
    row[m_Columns.m_col_color] = Gdk::Color("#F9CCCA");
    m_TreeView.scroll_to_row( m_refListStore->get_path(row));
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:9,代码来源:message_list.cpp

示例5: updateParamteres

void ModulePropertyWindow::updateParamteres()
{
    // updating parameters
    typedef Gtk::TreeModel::Children type_children;
    type_children children = m_refTreeModel->children();
    OSTRINGSTREAM strParams;
    Glib::ustring strName;
    for(type_children::iterator iter = children.begin(); iter!=children.end(); ++iter)
    {
        strName = Glib::ustring((*iter)[m_Columns.m_col_name]);
        if(strName == "Parameters")
        {
            for(type_children::iterator jter = (*iter).children().begin(); 
                jter!=(*iter).children().end(); ++jter)
            {
                Glib::ustring strItem = Glib::ustring((*jter)[m_Columns.m_col_name]);
                Glib::ustring strValue = Glib::ustring((*jter)[m_Columns.m_col_value]);
                for(int i=0; i<m_pModule->argumentCount(); i++) 
                {
                    if(strItem == m_pModule->getArgumentAt(i).getParam())
                    {   
                        if(strValue.size())
                        {
                            if(!m_pModule->getArgumentAt(i).isSwitch())                            
                                strParams<<"--"<<strItem<<" "<<strValue<<" ";
                            else
                            {
                                if(compareString(strValue.c_str(), "on" ))
                                    strParams<<"--"<<strItem<<" ";
                                else
                                    (*jter)[m_Columns.m_col_value] = "off";
                            }
                        }
                        else
                            if(m_pModule->getArgumentAt(i).isSwitch())                            
                                (*jter)[m_Columns.m_col_value] = "off";
                    }    

                    if((strItem == m_pModule->getArgumentAt(i).getParam()) &&
                        m_pModule->getArgumentAt(i).isRequired())
                    {    
                        if(!strValue.size())
                            (*jter)[m_Columns.m_col_color_item] = Gdk::Color("#BF0303");
                        else
                            (*jter)[m_Columns.m_col_color_item] = Gdk::Color("#000000");
                    }
                }
            }
            (*iter)[m_Columns.m_col_value] = strParams.str();
            updateModule(strName.c_str(), strParams.str().c_str());
            break;
        }
    }        
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:54,代码来源:module_property_window.cpp

示例6: TiXmlElement


//.........这里部分代码省略.........

            if(strcmp(curMod.getStdio(), ""))
            {
                TiXmlElement *stdio=new TiXmlElement("stdio");
                stdio->LinkEndChild(new TiXmlText(curMod.getStdio()));
                newMod->LinkEndChild(stdio);
            }

            if(strcmp(curMod.getWorkDir(), ""))
            {
                TiXmlElement *workdir=new TiXmlElement("workdir");
                workdir->LinkEndChild(new TiXmlText(curMod.getWorkDir()));
                newMod->LinkEndChild(workdir);
            }

            if(strcmp(curMod.getBroker(), ""))
            {
                TiXmlElement *broker=new TiXmlElement("deployer");
                broker->LinkEndChild(new TiXmlText(curMod.getBroker()));
                newMod->LinkEndChild(broker);
            }
            /*
            if(curMod.getRank()>0) //TODO check here how is rank handled
            {
                TiXmlElement *rank=new TiXmlElement("rank");
                char str[256];
                sprintf(str,"%d", curMod.getRank());
                rank->LinkEndChild(new TiXmlText(str));
                newMod->LinkEndChild(rank);
            }
            */

            GraphicModel model = curMod.getModelBase();
            OSTRINGSTREAM txt;
            if(model.points.size()>0)
            {
                txt<<"(Pos (x "<<model.points[0].x<<") "<<"(y "<<model.points[0].y<<"))";
                TiXmlElement *geometry=new TiXmlElement("geometry");
                geometry->LinkEndChild(new TiXmlText(txt.str().c_str()));
                newMod->LinkEndChild(geometry);
            }
        }

    }

    // iterate over embedded applications
    {
        int nApps=app->iapplicationCount();
        for (int appCt=0; appCt<nApps; ++appCt)
        {
            TiXmlElement *newApp  = new TiXmlElement("application");
            root->LinkEndChild(newApp); //add application element
            ApplicationInterface curApp=app->getIapplicationAt(appCt);

            TiXmlElement *name = new TiXmlElement("name");
            name->LinkEndChild(new TiXmlText(curApp.getName()));
            newApp->LinkEndChild(name);


            TiXmlElement *prefix=new TiXmlElement("prefix");
            prefix->LinkEndChild(new TiXmlText(curApp.getPrefix()));
            newApp->LinkEndChild(prefix);

            GraphicModel model = curApp.getModelBase();
            OSTRINGSTREAM txt;
            if(model.points.size()>0)
开发者ID:jgvictores,项目名称:yarp,代码行数:67,代码来源:xmlappsaver.cpp

示例7: throw

// Starts an SSL handshake on this connection.
void SSLSocket::startHandshake() 
  throw(IOException)
{
  Synchronized synchronized(_sync);

  // TODO: 
  if (_session != NULL)
    SSL_set_session(_ssl, _session->_session);
  

  // TODO: add some checks...
  if (!_use_client_mode)
    return;

  int ret = SSL_connect(_ssl);

  if (ret != 1) {
  
    int ssl_error = SSL_get_error(_ssl, ret);
    int error = ERR_get_error();
    
    OSTRINGSTREAM reason;
    reason << "SSLSocket::startHandshake connect error: ";
  
    switch (ssl_error) { 
      reason << "SSL_ERROR_NONE reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_WANT_READ:
      reason << "SSL_ERROR_WANT_READ reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_WANT_WRITE:
      reason << "SSL_ERROR_WANT_WRITE reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_ZERO_RETURN:
      reason << "SSL_ERROR_ZERO_RETURN reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_WANT_CONNECT:
      reason << "SSL_ERROR_WANT_CONNECT reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_WANT_X509_LOOKUP:
      reason << "SSL_ERROR_WANT_X509_LOOKUP reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_SYSCALL:
      reason << "SSL_ERROR_SYSCALL reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    case SSL_ERROR_SSL:
      reason << "SSL_ERROR_SSL reason: " << ERR_reason_error_string(error) << ends;
      throw IOException(reason.str().c_str());
      break;
    default:
      reason << "unknown: " << ends;
      throw IOException(reason.str().c_str());
    }
  }

//   if (!SSL_session_reused(_ssl))
//     cerr << " new session negotiated" << endl;

  //check_cert(ssl,host);

  
}
开发者ID:AlvaroVega,项目名称:TIDorbC,代码行数:70,代码来源:SSLSocket.C

示例8: GroupModel

ModuleModel::ModuleModel(ApplicationWindow* parentWnd, Module* mod, bool nested) : GroupModel()
{
    parentWindow = parentWnd;
    module = mod;
    bNested = nested;
    mod->setModel(this);

    // adding module name
    Glib::RefPtr<Goocanvas::TextModel> text = Goocanvas::TextModel::create(mod->getName());
#ifdef GLIBMM_PROPERTIES_ENABLED
    text->property_font() = FONT_DESC;
    text->property_alignment().set_value(Pango::ALIGN_CENTER);
#endif

    PangoLayout *layout = gtk_widget_create_pango_layout((GtkWidget*)parentWindow->gobj(), 
                            mod->getName());
    int text_w, text_h;
    PangoFontDescription *fontdesc = pango_font_description_from_string(FONT_DESC);
    pango_layout_set_font_description (layout, fontdesc);
    pango_layout_get_pixel_size (layout, &text_w, &text_h);

    //double w = strlen(mod->getName()) * FONT_WIDTH;
    double w = text_w + TEXT_MARGINE*2;

    int nInputs = module->inputCount();
    int nPorts = MAX(nInputs, module->outputCount());
    double h = nPorts*PORT_SIZE + 
              (nPorts-1)*PORT_GAP + 2*PORT_GAP;
    h = (h<MIN_HEIGHT) ? MIN_HEIGHT : h;

    
    shadowRect = Goocanvas::RectModel::create(3, 3, w, h);
    shadowRect->property_line_width().set_value(1.5) ;
    shadowRect->property_radius_x().set_value(3.0) ;
    shadowRect->property_radius_y().set_value(3.0) ;
    shadowRect->property_stroke_color().set_value("gray");
    shadowRect->property_fill_color().set_value("gray");    
    this->add_child(shadowRect);    

    mainRect = Goocanvas::RectModel::create(0,0, w, h);
    mainRect->property_line_width().set_value(1.2); 
    mainRect->property_radius_x().set_value(3.0) ;
    mainRect->property_radius_y().set_value(3.0) ;
    mainRect->property_stroke_color().set_value("DodgerBlue3");
    mainRect->property_fill_color().set_value(MODULE_COLOR);
    
    //if(module->owner() != parentWindow->manager.getKnowledgeBase()->getApplication())
    if(bNested)
    {
        GooCanvasLineDash *dash = goo_canvas_line_dash_new (2, 3.0, 3.0);
        g_object_set(mainRect->gobj(), "line-dash", dash, NULL);
    }
    this->add_child(mainRect);

    text->property_x().set_value(TEXT_MARGINE);
    text->property_y().set_value(h/2.0 - text_h/2.0);
    this->add_child(text);

    double top = (h - (nInputs*PORT_SIZE+(nInputs-1)*PORT_GAP))/2.0;
    for(int i=0; i<module->inputCount(); i++)
    {
        Glib::RefPtr<InternalPortModel> port = InternalPortModel::create(parentWindow, INPUTD, 
                                                        &module->getInputAt(i));
        port->set_property("x", -15);
        port->set_property("y", top +i*PORT_SIZE + i*PORT_GAP);
        this->add_child(port);
        // adding module name
        OSTRINGSTREAM str;
        str<<"I"<<i+1;
        Glib::RefPtr<Goocanvas::TextModel> text = Goocanvas::TextModel::create(str.str().c_str());
#ifdef GLIBMM_PROPERTIES_ENABLED
        text->property_font() = "Monospace 9";
        text->property_alignment().set_value(Pango::ALIGN_LEFT);
        text->property_x().set_value(8);
        text->property_y().set_value(top +i*PORT_SIZE + i*PORT_GAP);
#endif
        this->add_child(text);
    }

    top = (h - (module->outputCount()*PORT_SIZE+(module->outputCount()-1)*PORT_GAP))/2.0;  
    for(int i=0; i<module->outputCount(); i++)
    {
        Glib::RefPtr<InternalPortModel> port = InternalPortModel::create(parentWindow, OUTPUTD, 
                                                         &module->getOutputAt(i));
        port->set_property("x", w);
        port->set_property("y", top +i*PORT_SIZE + i*PORT_GAP);
        this->add_child(port);
        OSTRINGSTREAM str;
        str<<"O"<<i+1;
        Glib::RefPtr<Goocanvas::TextModel> text = Goocanvas::TextModel::create(str.str().c_str());
#ifdef GLIBMM_PROPERTIES_ENABLED
        text->property_font() = "Monospace 9";
        text->property_alignment().set_value(Pango::ALIGN_RIGHT);
        text->property_x().set_value(w-strlen(str.str().c_str())*10);
        text->property_y().set_value(top +i*PORT_SIZE + i*PORT_GAP);
#endif
        this->add_child(text);
    }
    
    width  = w;
//.........这里部分代码省略.........
开发者ID:JoErNanO,项目名称:yarp,代码行数:101,代码来源:module_model.cpp

示例9: while

bool BinaryExpParser::checkExpression(std::string& strexp)
{
    ErrorLogger* logger = ErrorLogger::Instance();

    if(std::count(strexp.begin(), strexp.end(), '(') != 
        std::count(strexp.begin(), strexp.end(), ')'))
    {
        logger->addError("Incorrect expression format! (parentheses do not match)");
        return false;
    }
    if(std::count(strexp.begin(), strexp.end(), IMPLY) != 1 )
    {
        logger->addError("Incorrect expression format! (no implication ':' found)");
        return false;
    }

    // erassing all the sapces
    strexp.erase(std::remove_if(strexp.begin(), strexp.end(), ::isspace), strexp.end());
    if(!strexp.size())
    {
       logger->addError("Empty expression!");
       return false;
    }

    // making a copy of strexp and checking more
    string  dummy = strexp;
    // removing all pranteses 
    dummy.erase(std::remove_if(dummy.begin(), dummy.end(), isParentheses), dummy.end());
    leftOpr = dummy.substr(0, dummy.find(IMPLY)); 
    if(!leftOpr.size())
    {
        logger->addError("Missing operand before ':'");
        return false; 
    }
    if(dummy.find(IMPLY) == (dummy.size()-1))
    {
        logger->addError("Missing operands after ':'");
        return false; 
    }

    dummy.erase(0, dummy.find(IMPLY)+1);
    if(dummy.find(leftOpr) != string::npos)
    {
        std::string msg;
        msg = "recursive assignment of operand '" + leftOpr + "'";
        logger->addError(msg.c_str());
        return false;       
    }

    // checking '~'
    size_t n = dummy.find(EXPNOT);
    while(n != string::npos)
    { 
        OSTRINGSTREAM msg;        
        bool bError = ((n+1) == dummy.length()); // empty operand after ~
        if((n+1) < dummy.length())
        {
            bError |= (dummy[n+1] == EXPAND);        // operator & after ~
            bError |= (dummy[n+1] == EXPOR);         // operand | after ~
        }            
        if(n != 0)
            bError |= (dummy[n-1] != EXPAND) && (dummy[n-1] != EXPOR);  // an operand before ~
        if(bError)
        {
            msg<<"Incorrect expression format of '~' at "<<(int)n;
            logger->addError(msg.str().c_str());
            return false;
        }
        n = dummy.find(EXPNOT, n+1);
    }

    // checking '| &'
    n = dummy.find_first_of("&|");
    while(n != string::npos)
    {
        OSTRINGSTREAM msg;        
        bool bError = ((n+1) == dummy.length());    // empty operand after & or |
        if((n+1) < dummy.length())
        {
            bError |= (dummy[n+1] == EXPAND);        // operator & after & or |
            bError |= (dummy[n+1] == EXPOR);         // operand | after & or |
        }            
        bError |= (n == 0);                      // empty operand before & or |
        if(n != 0)
        {
            bError |= (dummy[n-1] == EXPAND);        // operator & before & or |
            bError |= (dummy[n-1] == EXPOR);         // operand | before & or |
            bError |= (dummy[n-1] == EXPOR);         // operand ~ before & or |
        } 
        if(bError)
        {
            msg<<"Incorrect expression format of '&' or '|' at "<<(int)n;
            logger->addError(msg.str().c_str());
            return false;
        }
        n = dummy.find_first_of("&|", n+1);
    }

    // at the end
    strexp.erase(0, strexp.find(IMPLY)+1);
//.........这里部分代码省略.........
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:101,代码来源:binexparser.cpp

示例10: addError

void ErrorLogger::addError(OSTRINGSTREAM &stream) {
    addError(stream.str());
}
开发者ID:Tiger66639,项目名称:yarp,代码行数:3,代码来源:utility.cpp

示例11: addWarning

void ErrorLogger::addWarning(OSTRINGSTREAM &stream) {
    addWarning(stream.str());
}
开发者ID:Tiger66639,项目名称:yarp,代码行数:3,代码来源:utility.cpp


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