std::string StackTrace::ToString() const { std::stringstream stream; #if !defined(__UCLIBC__) OutputToStream(&stream); #endif return stream.str(); }
void Word::OutputToStream( const ManagerBase &mgr, size_t targetPos, const SCFG::Hypothesis &hypo, std::ostream &out) const { const SCFG::TargetPhraseImpl &tp = hypo.GetTargetPhrase(); const SCFG::SymbolBind &symbolBind = hypo.GetSymbolBind(); bool outputWord = true; if (mgr.system.options.input.placeholder_factor != NOT_FOUND) { const AlignmentInfo &alignInfo = tp.GetAlignTerm(); std::set<size_t> sourceAligns = alignInfo.GetAlignmentsForTarget(targetPos); if (sourceAligns.size() == 1) { size_t sourcePos = *sourceAligns.begin(); /* cerr << "sourcePos=" << sourcePos << endl; cerr << "tp=" << tp.Debug(mgr.system) << endl; cerr << "m_symbolBind=" << symbolBind.Debug(mgr.system) << endl; */ assert(sourcePos < symbolBind.GetSize()); const Range &inputRange = symbolBind.coll[sourcePos].GetRange(); assert(inputRange.GetNumWordsCovered() == 1); const SCFG::Sentence &sentence = static_cast<const SCFG::Sentence &>(mgr.GetInput()); const SCFG::Word &sourceWord = sentence[inputRange.GetStartPos()]; const Factor *factor = sourceWord[mgr.system.options.input.placeholder_factor]; if (factor) { out << factor->GetString(); outputWord = false; } } } if (outputWord) { OutputToStream(mgr.system, out); } }
bool ChemDrawXMLFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv) { static const xmlChar C_MOLECULE[] = "fragment"; static const xmlChar C_CDXML[] = "CDXML"; static const xmlChar C_BONDLENGTH[] = "BondLength"; static const xmlChar C_PAGE[] = "page"; static const xmlChar C_ATOM[] = "n"; static const xmlChar C_BOND[] = "b"; static const xmlChar C_ID[] = "id"; static const xmlChar C_CHARGE[] = "Charge"; static const xmlChar C_COORDS[] = "p"; static const xmlChar C_ELEMENT[] = "Element"; static const xmlChar C_ORDER[] = "Order"; static const xmlChar C_BEGIN[] = "B"; static const xmlChar C_END[] = "E"; static const xmlChar C_DISPLAY[] = "Display"; _pxmlConv = XMLConversion::GetDerived(pConv,false); if(!_pxmlConv) return false; OBMol* pmol = dynamic_cast<OBMol*>(pOb); if(pmol==NULL) return false; OBMol &mol = *pmol; OBBond *pbond; vector<OBBond*>::iterator j; if(_pxmlConv->GetOutputIndex() == 1) { xmlTextWriterStartDocument(writer(), NULL, NULL, NULL); xmlTextWriterWriteDTD(writer(), BAD_CAST "CDXML", NULL, BAD_CAST "http://www.camsoft.com/xml/cdxml.dtd", NULL); xmlTextWriterStartElement(writer(), C_CDXML); xmlTextWriterWriteFormatAttribute(writer(), C_BONDLENGTH , "30"); xmlTextWriterStartElement(writer(), C_PAGE); // put everything on one page // now guess the average bond size for the first molecule and scale to 30. _scale = 0.; if (mol.NumBonds()) { for (pbond = mol.BeginBond(j); pbond; pbond = mol.NextBond(j)) _scale += pbond->GetLength(); _scale /= mol.NumBonds(); } else _scale = 1.; // FIXME: what happens if the molecule has no bond? _scale = 30. / _scale; _offset = 0; } xmlTextWriterStartElement(writer(), C_MOLECULE); OBAtom *patom; vector<OBAtom*>::iterator i; int n; for (patom = mol.BeginAtom(i); patom; patom = mol.NextAtom(i)) { xmlTextWriterStartElement(writer(), C_ATOM); xmlTextWriterWriteFormatAttribute(writer(), C_ID , "%d", patom->GetIdx() + _offset); xmlTextWriterWriteFormatAttribute(writer(), C_COORDS , "%f %f", patom->GetX() * _scale, patom->GetY() * _scale); n = patom->GetAtomicNum(); if (n != 6) { xmlTextWriterWriteFormatAttribute(writer(), C_ELEMENT , "%d", n); } n = patom->GetFormalCharge(); if (n != 0) { xmlTextWriterWriteFormatAttribute(writer(), C_CHARGE , "%d", n); } xmlTextWriterEndElement(writer()); } for (pbond = mol.BeginBond(j); pbond; pbond = mol.NextBond(j)) { xmlTextWriterStartElement(writer(), C_BOND); patom = pbond->GetBeginAtom(); xmlTextWriterWriteFormatAttribute(writer(), C_BEGIN , "%d", patom->GetIdx() + _offset); patom = pbond->GetEndAtom(); xmlTextWriterWriteFormatAttribute(writer(), C_END , "%d", patom->GetIdx() + _offset); n = pbond->GetBO(); if (n != 1) { xmlTextWriterWriteFormatAttribute(writer(), C_ORDER , "%d", n); } if (pbond->IsHash()) xmlTextWriterWriteFormatAttribute(writer(), C_DISPLAY , "WedgeBegin"); else if (pbond->IsWedge()) xmlTextWriterWriteFormatAttribute(writer(), C_DISPLAY , "WedgedHashEnd"); xmlTextWriterEndElement(writer()); } _offset += mol.NumAtoms (); xmlTextWriterEndElement(writer());//molecule //TODO: Writing property block if(_pxmlConv->IsLast()) { xmlTextWriterEndDocument(writer()); // page xmlTextWriterEndDocument(writer()); //document OutputToStream(); } return true; }
std::string StackTrace::ToString() const { std::stringstream stream; OutputToStream(&stream); return stream.str(); }
void StackTrace::PrintBacktrace() { OutputToStream(&std::cerr); }