本文整理汇总了C++中TextOutput类的典型用法代码示例。如果您正苦于以下问题:C++ TextOutput类的具体用法?C++ TextOutput怎么用?C++ TextOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextOutput类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Vector2::serialize(TextOutput& t) const {
t.writeSymbol("(");
t.writeNumber(x);
t.writeSymbol(",");
t.writeNumber(y);
t.writeSymbol(")");
}
示例2: describeSystem
void NetworkDevice::describeSystem(
std::string& s) {
TextOutput t;
describeSystem(t);
t.commitString(s);
}
示例3: write_connolly_surface
IMPMULTIFIT_BEGIN_NAMESPACE
void write_connolly_surface(atom::Atoms atoms, TextOutput fn,
float density, float probe_radius) {
algebra::Sphere3Ds spheres;
for (unsigned int i = 0; i < atoms.size(); ++i) {
spheres.push_back(core::XYZR(atoms[i]).get_sphere());
}
algebra::ConnollySurfacePoints sps =
algebra::get_connolly_surface(spheres, density, probe_radius);
for (unsigned int i = 0; i < sps.size(); ++i) {
fn.get_stream() << std::setw(5) << sps[i].get_atom(0) + 1 << std::setw(5)
<< sps[i].get_atom(1) + 1 << std::setw(5)
<< sps[i].get_atom(2) + 1 << std::fixed << std::setw(8)
<< std::setprecision(3) << sps[i].get_surface_point()[0]
<< std::setw(8) << std::setprecision(3)
<< sps[i].get_surface_point()[1] << std::setw(8)
<< std::setprecision(3) << sps[i].get_surface_point()[2]
<< std::setw(8) << std::setprecision(3) << sps[i].get_area()
<< std::setw(7) << std::setprecision(3)
<< sps[i].get_normal()[0] << std::setw(7)
<< std::setprecision(3) << sps[i].get_normal()[1]
<< std::setw(7) << std::setprecision(3)
<< sps[i].get_normal()[2] << " 0.500" << std::endl;
}
}
示例4: serialize
void XML::serialize(TextOutput& t) const {
if (m_type == VALUE) {
// Raw string; no quotes
t.writeSymbol(m_value);
} else {
t.printf("<%s", m_name.c_str());
for (AttributeTable::Iterator it = m_attribute.begin(); it.hasMore(); ++it) {
t.printf(" %s=\"%s\"", it->key.c_str(), it->value.m_value.c_str());
}
t.printf(">");
t.writeNewline();
t.pushIndent();
for (int i = 0; i < m_child.size(); ++i) {
m_child[i].serialize(t);
if (m_child[i].m_type == VALUE) {
// Only tags know to append a newline
t.writeNewline();
}
}
t.popIndent();
t.printf("</%s>", m_name.c_str());
t.writeNewline();
}
}
示例5: describeSystem
void NetworkDevice::describeSystem(
TextOutput& t) {
t.writeSymbols("Network", "{");
t.writeNewline();
t.pushIndent();
t.popIndent();
t.writeSymbols("}");
t.writeNewline();
t.writeNewline();
}
示例6: serialize
void serialize(const double& b, TextOutput& to) {
to.writeNumber(b);
}
示例7: 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();
}
示例8: write_pdb
void write_pdb(const ParticlesTemp& ps, TextOutput out) {
IMP_FUNCTION_LOG;
int last_index = 0;
bool use_input_index = true;
for (unsigned int i = 0; i < ps.size(); ++i) {
if (Atom(ps[i]).get_input_index() != last_index + 1) {
use_input_index = false;
break;
} else {
++last_index;
}
}
for (unsigned int i = 0; i < ps.size(); ++i) {
if (Atom::get_is_setup(ps[i])) {
Atom ad(ps[i]);
Residue rd = get_residue(ad);
// really dumb and slow, fix later
char chain;
Chain c = get_chain(rd);
if (c) {
chain = c.get_id()[0];
} else {
chain = ' ';
}
int inum = i+1;
if (i>=99999) inum=99999;
out.get_stream() << get_pdb_string(
core::XYZ(ps[i]).get_coordinates(),
use_input_index ? ad.get_input_index()
: static_cast<int>(inum),
ad.get_atom_type(), rd.get_residue_type(), chain,
rd.get_index(), rd.get_insertion_code(),
ad.get_occupancy(), ad.get_temperature_factor(),
ad.get_element());
if (!out) {
IMP_THROW("Error writing to file in write_pdb", IOException);
}
}
else if (Residue::get_is_setup(ps[i])) { // if C-alpha residue is available
Residue rd = IMP::atom::Residue(ps[i]);
// comment 1 by SJ - TODO: How to retrieve the correct chain information without an hierarchy?
char chain;
Chain c = get_chain(rd);
if (c) {
chain = c.get_id()[0];
} else {
chain = ' ';
}
// comment 2 by SJ - TODO: The C-alpha residues are not sorted yet. We need to sort the residues similarly to what PMI does.
out.get_stream() << get_pdb_string(
core::XYZ(ps[i]).get_coordinates(),
static_cast<int>(i + 1),
IMP::atom::AT_CA, rd.get_residue_type(), chain,
rd.get_index(), ' ',
1.0, IMP::core::XYZR(ps[i]).get_radius());
}
else { // if a coarse-grained BEAD is available
Ints resindexes = IMP::atom::Fragment(ps[i]).get_residue_indexes();
int resindex = (int)resindexes.front() + (int)(resindexes.size()/2);
// comment 1 by SJ - TODO: How to retrieve the correct chain information without an hierarchy?
char chain = ' ';
// comment 3 by SJ - TODO: The BEADs are not sorted yet. We need to sort the residues similarly to what PMI does.
// comment 4 by SJ - TODO: currently IMP does not allow "BEA" as a residue name, while PMI allows it. Thus "UNK" was used instead.
out.get_stream() << get_pdb_string(
core::XYZ(ps[i]).get_coordinates(),
static_cast<int>(i + 1),
IMP::atom::AT_CA, IMP::atom::UNK, chain,
(int)resindex, ' ',
1.0, IMP::core::XYZR(ps[i]).get_radius());
}
}
}
示例9: Writer
TextWriter::TextWriter(TextOutput fn) : Writer(fn.get_name()), out_(fn) {
set_was_used(true);
}
示例10: 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;
}
}
}