本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例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();
}
示例6: toString
String Location::toString() const {
StringBuffer buf;
buf.printf("%s:%d:%d", this->file, this->line1, this->char1);
return buf.detach();
}