本文整理汇总了C++中OSTRINGSTREAM::str方法的典型用法代码示例。如果您正苦于以下问题:C++ OSTRINGSTREAM::str方法的具体用法?C++ OSTRINGSTREAM::str怎么用?C++ OSTRINGSTREAM::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSTRINGSTREAM
的用法示例。
在下文中一共展示了OSTRINGSTREAM::str方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
示例2: close
//
// 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());
}
}
}
示例3: 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);
}
示例4: 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));
}
示例5: 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));
}
示例6: serialXml
bool XmlAppSaver::serialXml(Application* app, const char* szFile)
{
// updating application xml file name
app->setXmlFile(szFile);
ErrorLogger* logger = ErrorLogger::Instance();
TiXmlDocument doc; //(szFile);
TiXmlElement * root = new TiXmlElement("application");
doc.LinkEndChild( root );
TiXmlElement * appName = new TiXmlElement("name"); //are all these NEW ok?
appName->LinkEndChild(new TiXmlText(app->getName()));
root->LinkEndChild(appName);
if (strcmp(app->getDescription(), ""))
{
TiXmlElement * desc= new TiXmlElement( "description");
desc->LinkEndChild(new TiXmlText( app->getDescription()));
root->LinkEndChild(desc);
}
if(strcmp (app->getVersion(), ""))
{
TiXmlElement * vers= new TiXmlElement( "version");
vers->LinkEndChild(new TiXmlText( app->getVersion()));
root->LinkEndChild(vers);
}
/*
* TODO: setting prefix of the main application is inactivated.
* Check this should be supported in future or not!
*/
/*
if(strcmp (app->getPrefix(), ""))
{
TiXmlElement * prefix= new TiXmlElement( "prefix");
prefix->LinkEndChild(new TiXmlText( app->getPrefix()));
root->LinkEndChild(prefix);
}
*/
if(app->authorCount()>0)
{
TiXmlElement *auths=new TiXmlElement("authors");
for (int i=0; i<app->authorCount(); i++)
{
//app->getAuthorAt(i);
TiXmlElement *auth=new TiXmlElement("author");
auth->SetAttribute("email", app->getAuthorAt(i).getEmail());
auth->LinkEndChild(new TiXmlText(app->getAuthorAt(i).getName()));
auths->LinkEndChild(auth);
}
root->LinkEndChild(auths);
}
// iterate over modules
{
int nModules=app->imoduleCount();
for (int modCt=0; modCt<nModules; ++modCt)
{
TiXmlElement * newMod = new TiXmlElement("module");
root->LinkEndChild(newMod); //add module element
ModuleInterface curMod=app->getImoduleAt(modCt);
TiXmlElement *name = new TiXmlElement("name");
name->LinkEndChild(new TiXmlText(curMod.getName()));
newMod->LinkEndChild(name);
TiXmlElement *parameters=new TiXmlElement("parameters");
parameters->LinkEndChild(new TiXmlText(curMod.getParam()));
newMod->LinkEndChild(parameters);
TiXmlElement *node = new TiXmlElement("node");
node->LinkEndChild(new TiXmlText(curMod.getHost())); //is host the same as node?
newMod->LinkEndChild(node);
TiXmlElement *prefix=new TiXmlElement("prefix");
prefix->LinkEndChild(new TiXmlText(curMod.getPrefix()));
newMod->LinkEndChild(prefix);
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(), ""))
{
//.........这里部分代码省略.........
示例7: startHandshake
// 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);
}
示例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;
//.........这里部分代码省略.........
示例9: checkExpression
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);
//.........这里部分代码省略.........
示例10: IndexOutOfBoundsException
//
// write()
//
ssize_t
SSLOutputStream::write(const unsigned char* b, size_t size, size_t off, size_t len)
throw(IOException, IllegalBlockingModeException, IndexOutOfBoundsException)
{
// Comprueba los limites del array
if (off + len > size)
{
throw IndexOutOfBoundsException("Index out of bounds");
}
// Delega la operacion en el canal, si este existe
if (_channel)
{
SocketChannel* ch = dynamic_cast<SocketChannel*>(_channel);
return ch->write(b+off, len);
}
//SSL_set_connect_state(_ssl);
//SSL_set_mode(_ssl,SSL_MODE_ENABLE_PARTIAL_WRITE);
//ssize_t n = ::SSL_write(_ssl, (void*) (b + off), len);
// Temporal workaround: 2 SSL_write per operation in order to force flush
ssize_t n = ::SSL_write(_ssl, (void*) (b + off), len-1);
n += ::SSL_write(_ssl, (void*) (b + off + len - 1), 1);
if (n <= 0)
{
int ssl_error = SSL_get_error(_ssl, n);
int error = ERR_get_error();
OSTRINGSTREAM reason;
reason << "SSLOutputStream::write 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());
}
}
//BIO_flush(_sbio);
return n;
}
示例11: addError
void ErrorLogger::addError(OSTRINGSTREAM &stream) {
addError(stream.str());
}
示例12: addWarning
void ErrorLogger::addWarning(OSTRINGSTREAM &stream) {
addWarning(stream.str());
}