MCPcopy Create free account
hub / github.com/KLayout/klayout / write_data

Function write_data

src/laybasic/laybasic/gtf.cc:431–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429// The log event base class implementation
430
431static void
432write_data (const tl::Variant &data, std::ostream &os, unsigned int level)
433{
434 if (data.is_list ()) {
435
436 for (unsigned int i = 0; i < level; ++i) {
437 os << " ";
438 }
439 os << "<block>" << std::endl;
440
441 for (tl::Variant::const_iterator b = data.begin (); b != data.end (); ++b) {
442 write_data (*b, os, level + 1);
443 }
444
445 for (unsigned int i = 0; i < level; ++i) {
446 os << " ";
447 }
448 os << "</block>" << std::endl;
449
450 } else {
451
452 for (unsigned int i = 0; i < level; ++i) {
453 os << " ";
454 }
455
456 if (data.is_long ()) {
457 os << "<int>" << data.to_long () << "</int>" << std::endl;
458 } else if (data.is_a_string ()) {
459 os << "<string>" << escape_string (data.to_string ()) << "</string>" << std::endl;
460 } else if (data.is_user<QImage> ()) {
461
462 QImage img (data.to_user<QImage> ());
463 QByteArray ba;
464 QBuffer buffer (&ba);
465 buffer.open (QIODevice::WriteOnly);
466 img.save (&buffer, "PNG");
467 os << "<img>" << ba.toBase64 ().constData () << "</img>" << std::endl;
468
469 }
470 }
471}
472
473void
474LogEventBase::write (std::ostream &os, bool with_endl) const

Callers 1

writeMethod · 0.85

Calls 7

to_longMethod · 0.80
escape_stringFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
to_stringMethod · 0.45
openMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected