本文整理汇总了C++中TextOutput::writeString方法的典型用法代码示例。如果您正苦于以下问题:C++ TextOutput::writeString方法的具体用法?C++ TextOutput::writeString怎么用?C++ TextOutput::writeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextOutput
的用法示例。
在下文中一共展示了TextOutput::writeString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatIP
void NetworkDevice::EthernetAdapter::describe(TextOutput& t) const {
t.writeSymbol("{");
t.pushIndent();
t.writeNewline();
t.writeSymbols("hostname", "=");
t.writeString(hostname + ";");
t.writeNewline();
t.writeSymbols("name", "=");
t.writeString(name + ";");
t.writeNewline();
t.writeSymbols("ip", "=");
t.writeSymbol("\"" + formatIP(ip) + "\";");
t.writeNewline();
t.writeSymbols("subnet", "=");
t.writeSymbol("\"" + formatIP(subnet) + "\";");
t.writeNewline();
t.writeSymbols("broadcast", "=");
t.writeSymbol("\"" + formatIP(broadcast) + "\";");
t.writeNewline();
t.writeSymbols("mac", "=");
t.writeSymbol("\"" + formatMAC(mac) + "\";");
t.writeNewline();
t.popIndent();
t.writeSymbol("};");
t.writeNewline();
}
示例2: serialize
// TODO: if the output will fit on one line, compress tables and arrays into a single line
void Any::serialize(TextOutput& to) const {
beforeRead();
if (m_data && !m_data->comment.empty()) {
to.printf("\n/* %s */\n", m_data->comment.c_str());
}
switch (m_type) {
case NONE:
to.writeSymbol("NONE");
break;
case BOOLEAN:
to.writeBoolean(m_simpleValue.b);
break;
case NUMBER:
to.writeNumber(m_simpleValue.n);
break;
case STRING:
debugAssert(m_data != NULL);
to.writeString(*(m_data->value.s));
break;
case TABLE: {
debugAssert(m_data != NULL);
if (!m_data->name.empty()) {
if (needsQuotes(m_data->name)) {
to.writeString(m_data->name);
}
else {
to.writeSymbol(m_data->name);
}
}
to.writeSymbol("{");
to.writeNewline();
to.pushIndent();
AnyTable& table = *(m_data->value.t);
Array<std::string> keys;
table.getKeys(keys);
keys.sort();
for (int i = 0; i < keys.size(); ++i) {
to.writeSymbol(keys[i]);
to.writeSymbol("=");
table[keys[i]].serialize(to);
if (i < keys.size() - 1) {
to.writeSymbol(",");
}
to.writeNewline();
// Skip a line between table entries
to.writeNewline();
}
to.popIndent();
to.writeSymbol("}");
break;
}
case ARRAY: {
debugAssert(m_data != NULL);
if (!m_data->name.empty()) {
// For arrays, leave no trailing space between the name and the paren
to.writeSymbol(format("%s(", m_data->name.c_str()));
}
else {
to.writeSymbol("(");
}
to.writeNewline();
to.pushIndent();
Array<Any>& array = *(m_data->value.a);
for (int ii = 0; ii < size(); ++ii) {
array[ii].serialize(to);
if (ii < size() - 1) {
to.writeSymbol(",");
to.writeNewline();
}
// Put the close paren on an array right behind the last element
}
to.popIndent();
to.writeSymbol(")");
break;
}
}
}