• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WStringStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: loadJavaScript

std::string WIntValidator::javaScriptValidate() const
{
  loadJavaScript(WApplication::instance());

  WStringStream js;

  js << "new " WT_CLASS ".WIntValidator("
     << isMandatory()
     << ',';

  if (bottom_ != std::numeric_limits<int>::min())
    js << bottom_;
  else
    js << "null";

  js << ',';

  if (top_ != std::numeric_limits<int>::max())
    js << top_;
  else
    js << "null";

  js << "," << WWebWidget::jsStringLiteral(WLocale::currentLocale()
					   .groupSeparator())
     << ',' << invalidBlankText().jsStringLiteral()
     << ',' << invalidNotANumberText().jsStringLiteral()
     << ',' << invalidTooSmallText().jsStringLiteral()
     << ',' << invalidTooLargeText().jsStringLiteral()
     << ");";

  return js.str();
}
开发者ID:913862627,项目名称:wt,代码行数:32,代码来源:WIntValidator.C


示例2: LOAD_JAVASCRIPT

void WCssTheme::applyValidationStyle(WWidget *widget,
				     const Wt::WValidator::Result& validation,
				     WFlags<ValidationStyleFlag> styles) const
{
  WApplication *app = WApplication::instance();

  LOAD_JAVASCRIPT(app, "js/CssThemeValidate.js", "validate", wtjs1);
  LOAD_JAVASCRIPT(app, "js/CssThemeValidate.js", "setValidationState", wtjs2);

  if (app->environment().ajax()) {
    WStringStream js;
    js << WT_CLASS ".setValidationState(" << widget->jsRef() << ","
       << (validation.state() == WValidator::Valid ? 1 : 0) << ","
       << validation.message().jsStringLiteral() << ","
       << styles.value() << ");";

    widget->doJavaScript(js.str());
  } else {
    bool validStyle
      = (validation.state() == WValidator::Valid) && 
      (styles & ValidationValidStyle);
    bool invalidStyle
      = (validation.state() != WValidator::Valid) && 
      (styles & ValidationInvalidStyle);

    widget->toggleStyleClass("Wt-valid", validStyle);
    widget->toggleStyleClass("Wt-invalid", invalidStyle);
  }
}
开发者ID:NeilNienaber,项目名称:wt,代码行数:29,代码来源:WCssTheme.C


示例3: urlDecode

std::string urlDecode(const std::string &text)
{
  WStringStream result;

  for (unsigned i = 0; i < text.length(); ++i) {
    char c = text[i];

    if (c == '+') {
      result << ' ';
    } else if (c == '%' && i + 2 < text.length()) {
      std::string h = text.substr(i + 1, 2);
      char *e = 0;
      int hval = std::strtol(h.c_str(), &e, 16);

      if (*e == 0) {
	result << (char)hval;
	i += 2;
      } else
	// not a proper %XX with XX hexadecimal format
	result << c;
    } else
      result << c;
  }

  return result.str();
}
开发者ID:913862627,项目名称:wt,代码行数:26,代码来源:Utils.C


示例4: XSSFilterRemoveScript

bool XSSFilterRemoveScript(WString& text)
{
  if (text.empty())
    return true;

  std::string result = "<span>" + text.toUTF8() + "</span>";
  char *ctext = const_cast<char *>(result.c_str()); // Shhht it's okay !

  try {
    xml_document<> doc;
    doc.parse<parse_comment_nodes
      | parse_validate_closing_tags
      | parse_validate_utf8
      | parse_xhtml_entity_translation>(ctext);

    XSSSanitize(doc.first_node());

    WStringStream out;
    print(out.back_inserter(), *doc.first_node(), print_no_indenting);
    result = out.str();
  } catch (parse_error& e) {
    LOG_ERROR("Error reading XHTML string: " << e.what());
    return false;
  }

  if (result.length() < 13)
    result.clear();
  else
    result = result.substr(6, result.length() - 13);

  text = WString::fromUTF8(result);

  return true;
}
开发者ID:913862627,项目名称:wt,代码行数:34,代码来源:XSSFilter.C


示例5: doJavaScript

void WPopupMenu::prepareRender(WApplication *app)
{
  if (app->environment().agentIsIE()) {
    doJavaScript(jsRef() + ".lastChild.style.width="
		 + jsRef() + ".lastChild.offsetWidth + 'px';");
  }

  // FIXME: we should really also prepareRender() of submenus when shown...

  if (!cancel_.isConnected()) {
    LOAD_JAVASCRIPT(app, "js/WPopupMenu.js", "WPopupMenu", wtjs1);

    std::vector<WPopupMenu *> subMenus;
    getSubMenus(subMenus);

    WStringStream s;

    s << "new " WT_CLASS ".WPopupMenu("
      << app->javaScriptClass() << ',' << jsRef() << ','
      << autoHideDelay_ << ",[";

    for (unsigned i = 0; i < subMenus.size(); ++i) {
      if (i != 0)
	s << ',';
      s << WWebWidget::jsStringLiteral(subMenus[i]->id());
    }

    s << "]);";

    setJavaScriptMember(" WPopupMenu", s.str());

    cancel_.connect(this, &WPopupMenu::done);
  }
}
开发者ID:ReWeb3D,项目名称:wt,代码行数:34,代码来源:WPopupMenu.C


示例6: loadJavaScript

std::string WLengthValidator::javaScriptValidate() const
{
  loadJavaScript(WApplication::instance());

  WStringStream js;

  js << "new " WT_CLASS ".WLengthValidator("
     << isMandatory()
     << ',';

  if (minLength_ != 0)
    js << minLength_;
  else
    js << "null";

  js << ',';

  if (maxLength_ != std::numeric_limits<int>::max())
    js << maxLength_;
  else
    js << "null";

  js << ',' << invalidBlankText().jsStringLiteral()
     << ',' << invalidTooShortText().jsStringLiteral()
     << ',' << invalidTooLongText().jsStringLiteral()
     << ");";

  return js.str();
}
开发者ID:913862627,项目名称:wt,代码行数:29,代码来源:WLengthValidator.C


示例7: loadJavaScript

std::string WRegExpValidator::javaScriptValidate() const
{
  loadJavaScript(WApplication::instance());

  WStringStream js;

  js << "new " WT_CLASS ".WRegExpValidator("
     << isMandatory()
     << ',';

  if (regexp_) {
    js << WWebWidget::jsStringLiteral(regexp_->pattern())
       << ",'";

#ifndef WT_TARGET_JAVA
    WFlags<RegExpFlag> flags = regexp_->flags();
#else
    int flags = regexp_->flags();
#endif

    if (flags & MatchCaseInsensitive)
      js << 'i';

    js << '\'';
  } else
    js << "null, null";

  js << ',' << WWebWidget::jsStringLiteral(invalidBlankText())
     << ',' << WWebWidget::jsStringLiteral(invalidNoMatchText())
     << ");";

  return js.str();
}
开发者ID:DTidd,项目名称:wt,代码行数:33,代码来源:WRegExpValidator.C


示例8: string

const std::string WColor::cssText(bool withAlpha) const
{
  if (default_)
    return std::string();
  else {
    if (!name_.empty())
      return name_.toUTF8();
    else {
      WStringStream s;

#ifndef WT_TARGET_JAVA
      char buf[30];
#else
      char *buf;
#endif

      if (alpha_ != 255 && withAlpha) {
	s << "rgba(" << red_
	  << ',' << green_
	  << ',' << blue_
	  << ',' << Utils::round_css_str(alpha_ / 255., 2, buf) << ')';
      }	else
	s << "rgb(" << red_ << ',' << green_ << ',' << blue_ << ')';

      return s.c_str();
    }
  }
}
开发者ID:Dinesh-Ramakrishnan,项目名称:wt,代码行数:28,代码来源:WColor.C


示例9: EncodeRefs

void EncodeRefs(WString& text, WFlags<RefEncoderOption> options)
{
  if (text.empty())
    return;

  std::string result = "<span>" + text.toUTF8() + "</span>";
  char *ctext = const_cast<char *>(result.c_str()); // Shhht it's okay !

  WApplication *app = WApplication::instance();

  try {
    xml_document<> doc;
    doc.parse<parse_comment_nodes
      | parse_validate_closing_tags
      | parse_validate_utf8
      | parse_xhtml_entity_translation>(ctext);

    EncodeRefs(doc.first_node(), app, options);

    WStringStream out;
    print(out.back_inserter(), *doc.first_node(), print_no_indenting);

    result = out.str();
  } catch (parse_error& e) {
    LOG_ERROR("Error reading XHTML string: " << e.what());
    return;
  }

  if (result.length() < 13)
    result.clear();
  else
    result = result.substr(6, result.length() - 13);

  text = WString::fromUTF8(result);
}
开发者ID:NovaWova,项目名称:wt,代码行数:35,代码来源:RefEncoder.C


示例10: replaceUrlInStyle

static std::string replaceUrlInStyle(std::string& style, WApplication *app)
{
  boost::regex re("url\\((.*//.*)\\)",
		  boost::regex::perl | boost::regex::icase);

  boost::sregex_iterator i(style.begin(), style.end(), re);
  boost::sregex_iterator end;

  WStringStream result;
  std::size_t pos = 0;

  for (; i != end; ++i) {
    result << style.substr(pos, i->position(1) - pos);

    std::string url = style.substr(i->position(1), i->length(1));
    boost::algorithm::trim(url);
    if (url.length() > 2)
      if (url[0] == '\'' || url[1] == '"')
	url = url.substr(1, url.length() - 2);
    
    result << WWebWidget::jsStringLiteral(app->encodeUntrustedUrl(url), '\'');

    pos = i->position(1) + i->length(1);
  }

  result << style.substr(pos);

  return result.str();
}
开发者ID:NovaWova,项目名称:wt,代码行数:29,代码来源:RefEncoder.C


示例11: jsValue

std::string WPointF::jsValue() const
{
  char buf[30];
  WStringStream ss;
  ss << '[';
  ss << Utils::round_js_str(x_, 3, buf) << ',';
  ss << Utils::round_js_str(y_, 3, buf) << ']';
  return ss.str();
}
开发者ID:hhirsch,项目名称:wtim,代码行数:9,代码来源:WPointF.C


示例12: createContents

void WWidgetCanvasPainter::createContents(DomElement *result,
					  WPaintDevice *device)
{
  std::string wstr = boost::lexical_cast<std::string>(widget_->renderWidth_);
  std::string hstr = boost::lexical_cast<std::string>(widget_->renderHeight_);

  result->setProperty(PropertyStylePosition, "relative");
  result->setProperty(PropertyStyleOverflowX, "hidden");
  result->setProperty(PropertyStyleOverflowY, "hidden");

  DomElement *canvas = DomElement::createNew(DomElement_CANVAS);
  canvas->setId('c' + widget_->id());
  canvas->setProperty(PropertyStyleDisplay, "block");
  canvas->setAttribute("width", wstr);
  canvas->setAttribute("height", hstr);
  result->addChild(canvas);
  widget_->sizeChanged_ = false;

  WCanvasPaintDevice *canvasDevice = dynamic_cast<WCanvasPaintDevice *>(device);

  DomElement *text = 0;
  if (canvasDevice->textMethod() == WCanvasPaintDevice::DomText) {
    text = DomElement::createNew(DomElement_DIV);
    text->setId('t' + widget_->id());
    text->setProperty(PropertyStylePosition, "absolute");
    text->setProperty(PropertyStyleZIndex, "1");
    text->setProperty(PropertyStyleTop, "0px");
    text->setProperty(PropertyStyleLeft, "0px");
  }

  DomElement *el = text ? text : result;
  bool hasJsObjects = widget_->jsObjects_.size() > 0;

  if (hasJsObjects) {
    WStringStream ss;
    WApplication *app = WApplication::instance();
    ss << "new " WT_CLASS ".WPaintedWidget("
      << app->javaScriptClass() << "," << widget_->jsRef() << ");";
    widget_->jsObjects_.updateJs(ss);
    el->callJavaScript(ss.str());
  }

  canvasDevice->render('c' + widget_->id(), el);

  if (hasJsObjects) {
    WStringStream ss;
    ss << widget_->objJsRef() << ".repaint=function(){";
    ss << canvasDevice->recordedJs_.str();
    ss << "};";
    el->callJavaScript(ss.str());
  }

  if (text)
    result->addChild(text);

  delete device;
}
开发者ID:pgquiles,项目名称:wt,代码行数:57,代码来源:WPaintedWidget.C


示例13: setAreaCoordsJS

std::string WImage::setAreaCoordsJS()
{
  WStringStream ss;
  if (!targetJS_.empty()) {
    ss << "jQuery.data(" << jsRef() << ", 'obj').setAreaCoordsJSON("
       << updateAreaCoordsJSON() << ");";
  }
  return ss.str();
}
开发者ID:LifeGo,项目名称:wt,代码行数:9,代码来源:WImage.C


示例14: toWString

	WString toWString(wchar_t val, unsigned short width, char fill, std::ios::fmtflags flags)
	{
		WStringStream stream;
		stream.width(width);
		stream.fill(fill);
		if (flags)
			stream.setf(flags);
		stream << val;
		return stream.str();
	}
开发者ID:MarcoROG,项目名称:BansheeEngine,代码行数:10,代码来源:BsString.cpp


示例15: jsValue

std::string WBrush::jsValue() const
{
  WStringStream ss;
  ss << "{\"color\":["
    << color_.red() << ","
    << color_.green() << ","
    << color_.blue() << ","
    << color_.alpha() << "]}";
  return ss.str();
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:10,代码来源:WBrush.C


示例16: updateThrottling

void AuthModel::updateThrottling(WInteractWidget *button)
{
  if (passwordAuth() && passwordAuth()->attemptThrottlingEnabled()) {
    WStringStream s;
    s << button->jsRef() << ".wtThrottle.reset("
      << throttlingDelay_ << ");";

    button->doJavaScript(s.str());
  }
}
开发者ID:kdeforche,项目名称:wt,代码行数:10,代码来源:AuthModel.C


示例17: value

const std::string Money::toString() const
{
  WStringStream ans;
  if(cents() > 9)
    ans << value() << "." << cents(); //todo use formater.
  else
    ans << value() << ".0" << cents(); //todo use formater.

  return ans.str();
}
开发者ID:913862627,项目名称:wt,代码行数:10,代码来源:Money.C


示例18: setTransient

void WPopupWidget::setTransient(bool isTransient, int autoHideDelay)
{
    transient_ = isTransient;
    autoHideDelay_ = autoHideDelay;
    if (isRendered()) {
        WStringStream ss;
        ss << "jQuery.data(" << jsRef() << ", 'popup').setTransient("
           << transient_ << ',' << autoHideDelay_ << ");";
        doJavaScript(ss.str());
    }
}
开发者ID:hhirsch,项目名称:wtim,代码行数:11,代码来源:WPopupWidget.C


示例19: LOAD_JAVASCRIPT

void WImage::defineJavaScript()
{
  WApplication *app = WApplication::instance();

  LOAD_JAVASCRIPT(app, "js/WImage.js", "WImage", wtjs1);

  WStringStream ss;
  ss << "new " WT_CLASS ".WImage("
     << app->javaScriptClass() << "," << jsRef() << "," << targetJS_ << ");";
  doJavaScript(ss.str());
}
开发者ID:LifeGo,项目名称:wt,代码行数:11,代码来源:WImage.C


示例20: cssStyle

const std::string WFont::cssText(bool combined) const
{
  WStringStream result;

  if (combined) {
    std::string s;
    s = cssStyle(false);
    if (!s.empty())
      result << s << ' ';

    s = cssVariant(false);
    if (!s.empty())
      result << s << ' ';

    s = cssWeight(false);
    if (!s.empty())
      result << s << ' ';

    result << cssSize(true) << ' ';

    s = cssFamily(true);
    if (!s.empty())
      result << s << ' ';
    else
      result << s << " inherit";
  } else {
    std::string s;
    s = cssSize(false);
    if (!s.empty())
      result << "font-size: " << s << ";";

    s = cssStyle(false);
    if (!s.empty())
      result << "font-style: " << s << ";";

    s = cssVariant(false);
    if (!s.empty())
      result << "font-variant: " << s << ";";

    s = cssWeight(false);
    if (!s.empty())
      result << "font-weight: " << s << ";";

    // Last because of workaround in WVmlImage that searches for a ','
    s = cssFamily(false);
    if (!s.empty())
      result << "font-family: " << s << ";";

  }

  return result.str();
}
开发者ID:913862627,项目名称:wt,代码行数:52,代码来源:WFont.C



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WT_BM类代码示例发布时间:2022-05-31
下一篇:
C++ WStringAutoPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap