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


C++ StringBuffer::printf方法代码示例

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


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

示例1: xdebug_array_element_export_xml_node

// Exports the given xml key value pair as an xml child of the given parent node
static void xdebug_array_element_export_xml_node(xdebug_xml_node& parent,
                                                 const char* parentName,
                                                 const Variant& key,
                                                 const Variant& val,
                                                 XDebugExporter& exporter) {
  String key_str = key.toString();
  Variant full_name = init_null();

  // Construct the full name
  StringBuffer buf;
  if (parentName != nullptr)  {
    if (key.isInteger()) {
      buf.printf("%s[%s]", parentName, key_str.data());
    } else {
      buf.printf("%s['%s']", parentName, key_str.data());
    }
    full_name = buf.detach();
  }
  const char* full_name_str = full_name.isNull() ?
    nullptr : full_name.toString().data();

  // Recursively add the child
  xdebug_xml_node* child = xdebug_var_export_xml_node(xdstrdup(key_str.data()),
                                                      xdstrdup(full_name_str),
                                                      nullptr,
                                                      val, exporter);
  xdebug_xml_add_child(&parent, child);
}
开发者ID:Dream-Seeker,项目名称:hhvm,代码行数:29,代码来源:xdebug_var.cpp

示例2: append_line_no

static void append_line_no(StringBuffer &sb, const char *text,
                           int &line, const char *color, const char *end,
                           int lineFocus0, int charFocus0, int lineFocus1,
                           int charFocus1, const char **palette =
                           DebuggerClient::DefaultCodeColors) {
  TRACE(7, "debugger_base:append_line_no\n");
  const char *colorLineNo = palette[CodeColorLineNo * 2];
  const char *endLineNo = palette[CodeColorLineNo * 2 + 1];

  // beginning
  if (line && sb.empty()) {
    if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                   colorLineNo);
    sb.printf(DebuggerClient::LineNoFormat, line);
    if (endLineNo) sb.append(endLineNo);
  }

  // ending
  if (text == nullptr) {
    if (line) {
      if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                     colorLineNo);
      sb.append("(END)\n");
      if (endLineNo) sb.append(endLineNo);
    }
    return;
  }

  if (color) sb.append(color);

  if (line == 0) {
    sb.append(text);
  } else {
    const char *begin = text;
    const char *p = begin;
    for (; *p; p++) {
      if (*p == '\n') {
        ++line;
        sb.append(begin, p - begin);
        if (color) sb.append(ANSI_COLOR_END);
        sb.append('\n');
        if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                       colorLineNo);
        sb.printf(DebuggerClient::LineNoFormat, line);
        if (endLineNo) sb.append(endLineNo);
        if (color) sb.append(color);
        begin = p + 1;
      }
    }
    if (p - begin > 0) {
      sb.append(begin, p - begin);
    }
  }

  if (end) sb.append(end);
}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:56,代码来源:debugger_base.cpp

示例3: append_line_no

static void append_line_no(StringBuffer &sb, const char *text,
                           int &line, const char *color, const char *end,
                           const char **palette =
                           DebuggerClient::DefaultCodeColors) {
  const char *colorLineNo = palette[CodeColorLineNo * 2];
  const char *endLineNo = palette[CodeColorLineNo * 2 + 1];

  // beginning
  if (line && sb.empty()) {
    if (colorLineNo) sb.append(colorLineNo);
    sb.printf(DebuggerClient::LineNoFormat, line);
    if (endLineNo) sb.append(endLineNo);
  }

  // ending
  if (text == NULL) {
    if (line) {
      if (colorLineNo) sb.append(colorLineNo);
      sb.append("(END)\n");
      if (endLineNo) sb.append(endLineNo);
    }
    return;
  }

  if (color) sb.append(color);

  if (line == 0) {
    sb.append(text);
  } else {
    const char *begin = text;
    const char *p = begin;
    for (; *p; p++) {
      if (*p == '\n') {
        sb.append(begin, p - begin);
        if (end) sb.append(end);
        sb.append('\n');
        if (colorLineNo) sb.append(colorLineNo);
        sb.printf(DebuggerClient::LineNoFormat, ++line);
        if (endLineNo) sb.append(endLineNo);
        if (color) sb.append(color);
        begin = p + 1;
      }
    }
    if (p - begin > 0) {
      sb.append(begin, p - begin);
    }
  }

  if (end) sb.append(end);
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:50,代码来源:debugger_base.cpp

示例4: _convertSerializable

/* {{{ Special objects that implement MongoDB\BSON\Serializable */
void VariantToBsonConverter::_convertSerializable(bson_t *bson, const char *key, Object v)
{
	Variant result;
	Array   properties;
	TypedValue args[1] = { *(Variant(v)).asCell() };
	Class *cls;
	Func *m;

	cls = v.get()->getVMClass();
	m = cls->lookupMethod(s_MongoDriverBsonSerializable_functionName.get());
	
	g_context->invokeFuncFew(
		result.asTypedValue(),
		m,
		v.get(),
		nullptr,
		1, args
	);

	if ( ! (
			result.isArray() || 
			(result.isObject() && result.toObject().instanceof(s_stdClass))
		)
	) {
		StringBuffer buf;
		buf.printf(
			"Expected %s::%s() to return an array or stdClass, %s given",
			cls->nameStr().c_str(),
			s_MongoDriverBsonSerializable_functionName.data(),
			result.isObject() ? result.toObject()->getVMClass()->nameStr().c_str() : HPHP::getDataTypeString(result.getType()).data()
		);
		Variant full_name = buf.detach();

		throw MongoDriver::Utils::throwUnexpectedValueException((char*) full_name.toString().c_str());
	}

	/* Convert to array so that we can handle it well */
	properties = result.toArray();

	if (v.instanceof(s_MongoDriverBsonPersistable_className)) {
		const char *class_name = cls->nameStr().c_str();
		Object obj = createMongoBsonBinaryObject(
			(const uint8_t *) class_name,
			strlen(class_name),
			(bson_subtype_t) 0x80
		);
		properties.add(String(s_MongoDriverBsonODM_fieldName), obj);
	}

	convertDocument(bson, key, result.isObject() ? Variant(Variant(properties).toObject()) : Variant(properties));
}
开发者ID:divrt,项目名称:mongo-hhvm-driver,代码行数:52,代码来源:bson.cpp

示例5: location_to_string

String Eval::location_to_string(const Location *loc) {
  StringBuffer buf;
  buf.printf("%s:%d:%d", loc->file, loc->line1, loc->char1);
  return buf.detach();
}
开发者ID:ArPharazon,项目名称:hiphop-php,代码行数:5,代码来源:eval.cpp

示例6: toString

String Location::toString() const {
  StringBuffer buf;
  buf.printf("%s:%d:%d", this->file, this->line1, this->char1);
  return buf.detach();
}
开发者ID:kreshano,项目名称:hiphop-php,代码行数:5,代码来源:parser.cpp


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