本文整理汇总了C++中io::XMLArchive::setFormattedOutput方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLArchive::setFormattedOutput方法的具体用法?C++ XMLArchive::setFormattedOutput怎么用?C++ XMLArchive::setFormattedOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io::XMLArchive
的用法示例。
在下文中一共展示了XMLArchive::setFormattedOutput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
bool run() {
DataModel::VS::VSPtr vs = new DataModel::VS::VS;
DataModel::CreationInfo ci;
ci.setAgencyID(agencyID());
ci.setAuthor(author());
ci.setCreationTime(Core::Time::GMT());
DataModel::VS::EnvelopePtr env = DataModel::VS::Envelope::Create();
env->setCreationInfo(ci);
env->setNetwork("CH");
env->setStation("ZUR");
DataModel::VS::EnvelopeChannelPtr cha = DataModel::VS::EnvelopeChannel::Create();
cha->setName("Z");
cha->setWaveformID(DataModel::WaveformStreamID("CH", "ZUR", "", "HGZ", ""));
cha->add(new DataModel::VS::EnvelopeValue(0.3, "vel", Core::None));
cha->add(new DataModel::VS::EnvelopeValue(0.2, "acc", Core::None));
cha->add(new DataModel::VS::EnvelopeValue(0.1, "disp", Core::None));
env->add(cha.get());
vs->add(env.get());
IO::XMLArchive ar;
ar.create("-");
ar.setFormattedOutput(true);
ar << vs;
return true;
}
示例2: run
//.........这里部分代码省略.........
if ( ep )
ep->add(oldAmp.get());
else
updates.push_back(oldAmp);
cerr << "-> " << newAmp->amplitude().value();
}
else
cerr << " no changes";
++ampsRecomputed;
}
else {
cerr << "-";
++errors;
}
cerr << endl;
}
if ( !updates.empty() ) {
if ( !_testMode ) {
NotifierMessagePtr nmsg = new NotifierMessage;
for ( list<AmplitudePtr>::iterator it = updates.begin();
it != updates.end(); ++it ) {
nmsg->attach(new Notifier("EventParameters", OP_UPDATE, it->get()));
}
connection()->send(nmsg.get());
++messagesSent;
if ( messagesSent % 100 == 0 )
sync();
}
else {
cerr << " --------------------------------" << endl;
cerr << " Test mode, nothing sent" << endl;
}
}
}
if ( ep ) {
IO::XMLArchive ar;
ar.create("-");
ar.setFormattedOutput(true);
ar << ep;
ar.close();
}
cerr << "----------------------------------" << endl;
cerr << "Recomputed " << ampsRecomputed << " amplitudes" << endl;
cerr << "Sent " << messagesSent << " messages" << endl;
if ( errors )
cerr << errors << " errors occurred, check the processing log" << endl;
return true;
}
if ( !_epFile.empty() ) {
_fetchMissingAmplitudes = false;
// Disable database
setDatabase(NULL);
_cache.setDatabaseArchive(NULL);
IO::XMLArchive ar;
if ( !ar.open(_epFile.c_str()) ) {
SEISCOMP_ERROR("Failed to open %s", _epFile.c_str());
return false;
}
ar >> _ep;
ar.close();
if ( !_ep ) {
SEISCOMP_ERROR("No event parameters found in %s", _epFile.c_str());
return false;
}
if ( commandline().hasOption("reprocess") ) {
for ( size_t i = 0; i < _ep->amplitudeCount(); ++i ) {
AmplitudePtr amp = _ep->amplitude(i);
feed(amp.get());
}
}
for ( size_t i = 0; i < _ep->originCount(); ++i ) {
OriginPtr org = _ep->origin(i);
SEISCOMP_INFO("Processing origin %s", org->publicID().c_str());
process(org.get());
}
ar.create("-");
ar.setFormattedOutput(true);
ar << _ep;
ar.close();
_ep = NULL;
return true;
}
示例3: syncInventory
//.........这里部分代码省略.........
(int)keyFiles.size(), keyFiles.size() > 1?"s":"");
for ( map<string,string>::iterator it = keyFiles.begin();
it != keyFiles.end(); ++it )
SEISCOMP_WARNING(" %s", it->second.c_str());
}
DataModel::Notifier::SetEnabled(false);
_currentTask = NULL;
if ( _exitRequested ) {
cerr << "Exit requested: abort" << endl;
return false;
}
bool doSyncKeys = false;
if ( createNotifier ) {
DataModel::NotifierMessagePtr nmsg;
size_t notifierCount = DataModel::Notifier::Size();
if ( notifierCount > 0 ) {
cerr << notifierCount << " notifiers available" << endl;
if ( !_output.empty() ) {
IO::XMLArchive ar;
if ( !ar.create(_output.c_str()) ) {
cerr << "Failed to create output file: " << _output << endl;
DataModel::Notifier::Clear();
return false;
}
cerr << "Generating output ... " << flush;
ar.setFormattedOutput(true);
nmsg = DataModel::Notifier::GetMessage(true);
ar << nmsg;
ar.close();
cerr << "done" << endl;
}
else if ( !testMode ) {
// Notify about start of synchronization
DataModel::InventorySyncMessagePtr ismsg = new DataModel::InventorySyncMessage(false);
ismsg->setCreationInfo(DataModel::CreationInfo());
ismsg->creationInfo().setCreationTime(Core::Time::GMT());
ismsg->creationInfo().setAuthor(author());
ismsg->creationInfo().setAgencyID(agencyID());
connection()->send(Communication::Protocol::STATUS_GROUP, ismsg.get());
// Send an inital sync command to also wake-up the messaging
sync();
// Send notifier
DataModel::NotifierMessagePtr tmp = new DataModel::NotifierMessage();
DataModel::NotifierMessage::iterator it;
int count = 0;
// Fetch each single notifier message. Fetching all notifiers
// in one message can take a long time if a huge amount of
// notifiers is in the queue. Due to memory fragmentation
// most of the time spent is in malloc.
while ( (nmsg = DataModel::Notifier::GetMessage(false)) != NULL ) {
if ( _exitRequested ) break;
for ( it = nmsg->begin(); it != nmsg->end(); ++it ) {
DataModel::Notifier* n = DataModel::Notifier::Cast(*it);
示例4: mergeInventory
bool mergeInventory() {
bool stripUnreferenced = commandline().hasOption("strip");
// Disable object registration
DataModel::PublicObject::SetRegistrationEnabled(false);
vector<string> files;
collectFiles(files);
if ( files.empty() ) {
cerr << "Nothing to merge, no files given" << endl;
return false;
}
DataModel::InventoryPtr finalInventory = new DataModel::Inventory();
Merge merger(finalInventory.get());
merger.setLogHandler(this);
_continueOperation = true;
_currentTask = &merger;
for ( size_t i = 0; i < files.size(); ++i ) {
if ( _exitRequested ) break;
IO::XMLArchive ar;
if ( !ar.open(files[i].c_str()) ) {
cerr << "Could not open file (ignored): " << files[i] << endl;
continue;
}
DataModel::InventoryPtr inv;
cerr << "Parsing " << files[i] << " ... " << flush;
ar >> inv;
cerr << "done" << endl;
if ( !inv ) {
cerr << "No inventory found (ignored): " << files[i] << endl;
continue;
}
_inventorySources[inv.get()] = files[i];
// Pushing the inventory into the merger cleans it
// completely. The ownership of all childs went to
// the merger
merger.push(inv.get());
}
_currentTask = NULL;
if ( _exitRequested ) {
cerr << "Exit requested: abort" << endl;
return false;
}
cerr << "Merging inventory ... " << flush;
merger.merge(stripUnreferenced);
cerr << "done" << endl;
printLogs();
if ( !_continueOperation ) {
cerr << "Unresolvable errors ... aborting" << endl;
return false;
}
if ( _output.empty() ) _output = "-";
IO::XMLArchive ar;
if ( !ar.create(_output.c_str()) ) {
cerr << "Failed to create output file: " << _output << endl;
return false;
}
cerr << "Generating output ... " << flush;
ar.setFormattedOutput(true);
ar << finalInventory;
ar.close();
cerr << "done" << endl;
if ( !_rcdir.empty() ) {
if ( !syncRCFiles(finalInventory.get()) ) return false;
}
return true;
}
示例5: applyNotifier
//.........这里部分代码省略.........
IO::XMLArchive ar;
if ( !ar.open(files[i].c_str()) ) {
cerr << "Could not open file (ignored): " << files[i] << endl;
continue;
}
cerr << "Parsing " << files[i] << " ... " << flush;
DataModel::NotifierMessagePtr msg;
ar >> msg;
cerr << "done" << endl;
if ( !msg ) {
cerr << "No notifier message found (ignored): " << files[i] << endl;
continue;
}
size_t notifierCount = msg->size();
cerr << notifierCount << " notifiers available" << endl;
if ( !_output.empty() ) {
cerr << "Applying notifier ... " << flush;
// Apply all notifier
DataModel::NotifierMessage::iterator it;
for ( it = msg->begin(); it != msg->end(); ++it ) {
DataModel::Notifier* n = DataModel::Notifier::Cast(*it);
if ( !n ) continue;
n->apply();
}
cerr << "done" << endl;
}
else {
// Send all notifier
// Send an inital sync command to also wake-up the messaging
sync();
// Send notifier
DataModel::NotifierMessagePtr tmp = new DataModel::NotifierMessage();
DataModel::NotifierMessage::iterator it;
int count = 0;
for ( it = msg->begin(); it != msg->end(); ++it ) {
DataModel::Notifier* n = DataModel::Notifier::Cast(*it);
if ( !n ) continue;
tmp->attach(n);
++count;
if ( count % 100 == 0 ) {
cerr << "\rSending notifiers: " << (int)(count*100/notifierCount) << "%" << flush;
if ( !send(tmp.get()) ) {
SEISCOMP_ERROR("Failed to send message, abort");
return false;
}
tmp->clear();
sync();
}
}
sync();
if ( !tmp->empty() ) {
if ( !send(tmp.get()) ) {
SEISCOMP_ERROR("Failed to send message, abort");
return false;
}
cerr << "\rSending notifiers: " << (int)(count*100/notifierCount) << "%" << flush;
}
}
}
if ( _exitRequested ) {
cerr << "Exit requested: abort" << endl;
return false;
}
if ( !_output.empty() ) {
IO::XMLArchive ar;
if ( !ar.create(_output.c_str()) ) {
cerr << "Failed to create output file: " << _output << endl;
return false;
}
cerr << "Generating output ... " << flush;
ar.setFormattedOutput(true);
ar << targetInv;
ar.close();
cerr << "done" << endl;
}
return true;
}
示例6: runFromEPFile
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool App::runFromEPFile(const char *fname) {
IO::XMLArchive ar;
if ( !ar.open(fname)) {
SEISCOMP_ERROR("unable to open XML file: %s", fname);
return false;
}
ar >> _ep;
ar.close();
if ( !_ep ) {
SEISCOMP_ERROR("No event parameters found: %s", fname);
return false;
}
SEISCOMP_INFO("finished reading event parameters from XML");
SEISCOMP_INFO(" number of picks: %ld", (long int)_ep->pickCount());
SEISCOMP_INFO(" number of amplitudes: %ld", (long int)_ep->amplitudeCount());
SEISCOMP_INFO(" number of origins: %ld", (long int)_ep->originCount());
typedef std::pair<Core::Time,DataModel::PublicObjectPtr> TimeObject;
typedef std::vector<TimeObject> TimeObjectVector;
// retrieval of relevant objects from event parameters
// and subsequent DSU sort
TimeObjectVector objs;
for ( size_t i = 0; i < _ep->pickCount(); ++i ) {
DataModel::PickPtr pick = _ep->pick(i);
try {
Core::Time t = pick->creationInfo().creationTime();
objs.push_back(TimeObject(t, pick));
}
catch ( ... ) {
SEISCOMP_WARNING("Ignore pick %s: no creation time set",
pick->publicID().c_str());
}
}
for ( size_t i = 0; i < _ep->amplitudeCount(); ++i ) {
DataModel::AmplitudePtr amplitude = _ep->amplitude(i);
try {
Core::Time t = amplitude->creationInfo().creationTime();
objs.push_back(TimeObject(t, amplitude));
}
catch ( ... ) {
SEISCOMP_WARNING("Ignore amplitude %s: no creation time set",
amplitude->publicID().c_str());
}
}
for ( size_t i = 0; i < _ep->originCount(); ++i ) {
DataModel::OriginPtr origin = _ep->origin(i);
try {
Core::Time t = origin->creationInfo().creationTime();
objs.push_back(TimeObject(t, origin));
}
catch ( ... ) {
SEISCOMP_WARNING("Ignore origin %s: no creation time set",
origin->publicID().c_str());
}
}
std::sort(objs.begin(), objs.end());
for (TimeObjectVector::iterator
it = objs.begin(); it != objs.end(); ++it) {
_objects.push(it->second);
}
while ( !_objects.empty() && !isExitRequested() ) {
DataModel::PublicObjectPtr o = _objects.front();
_objects.pop();
addObject("", o.get());
++objectCount;
}
_flush();
ar.create("-");
ar.setFormattedOutput(true);
ar << _ep;
ar.close();
return true;
}