28# define LIBXML_ATTR_ALLOC_SIZE(x)
30#include <libxml/encoding.h>
31#include <libxml/xmlwriter.h>
34#define MY_ENCODING "ISO-8859-1"
92 std::vector< Root::TGoodRunsList >::const_iterator litr =
m_grlvec.begin();
93 for (
int i=0; litr!=
m_grlvec.end(); ++litr, ++i) {
117 m_logger <<
kINFO <<
"Output filename not set. Will be generated automatically." <<
GEndl;
127 writer = xmlNewTextWriterDoc(&doc, 0);
128 if (writer == NULL) {
140 rc = xmlTextWriterEndDocument(writer);
146 xmlFreeTextWriter(writer);
164const std::vector<TString>&
178 std::vector< Root::TGoodRunsList >::const_iterator litr =
m_grlvec.begin();
179 for (
int i=0; litr!=
m_grlvec.end(); ++litr, ++i) {
211 buf = xmlBufferCreate();
219 writer = xmlNewTextWriterMemory(buf, 0);
220 if (writer == NULL) {
232 rc = xmlTextWriterEndDocument(writer);
238 xmlFreeTextWriter(writer);
263 rc = xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
270 rc = xmlTextWriterWriteDTD(writer, (
xmlChar *)
"LumiRangeCollection", NULL,
271 (
xmlChar *)
"http://atlas-runquery.cern.ch/LumiRangeCollection.dtd", NULL);
282 rc = xmlTextWriterWriteComment(writer, tmp);
287 if (tmp != NULL) xmlFree(tmp);
291 rc = xmlTextWriterStartElement(writer, BAD_CAST
"LumiRangeCollection");
306 std::vector< Root::TGoodRunsList >::const_iterator litr =
m_grlvec.begin();
307 for (; litr!=
m_grlvec.end(); ++litr) {
318 rc = xmlTextWriterEndElement(writer);
347 rc = xmlTextWriterStartElement(writer, BAD_CAST
"NamedLumiRange");
358 if (
m_grl.GetVersion().Length()>0) {
362 if (!
m_grl.GetMetaData().empty()) {
363 std::map<TString,TString>::const_iterator mitr =
m_grl.GetMetaData().begin();
364 for (; mitr!=
m_grl.GetMetaData().end(); ++mitr)
365 this->
WriteElement(writer,
"Metadata",mitr->second.Data(),
"Name",mitr->first.Data());
368 std::map<Int_t,Root::TGoodRun>::const_iterator gitr =
m_grl.begin();
369 for (; gitr!=
m_grl.end(); ++gitr)
373 rc = xmlTextWriterEndElement(writer);
398 rc = xmlTextWriterStartElement(writer, BAD_CAST
"LumiBlockCollection");
408 std::vector<TLumiBlockRange>::const_iterator litr = goodrun.begin();
409 for (; litr!=goodrun.end(); ++litr)
410 if (!litr->IsEmpty()) {
411 if (litr->End()!=2147483647)
412 this->
WriteElement(writer,
"LBRange",0,
"Start",Form(
"%d",litr->Begin()),
"End",Form(
"%d",litr->End()));
414 this->
WriteElement(writer,
"LBRange",0,
"Start",Form(
"%d",litr->Begin()));
419 rc = xmlTextWriterEndElement(writer);
438 const char* name,
const char* value,
439 const char* atr1,
const char* val1,
const char* atr2,
const char* val2)
445 rc = xmlTextWriterStartElement(writer, BAD_CAST (name));
451 if ((atr1!=0) && (val1!=0)) {
452 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (atr1), BAD_CAST (val1));
459 if ((atr2!=0) && (val2!=0)) {
460 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (atr2), BAD_CAST (val2));
468 rc = xmlTextWriterWriteString(writer, BAD_CAST (value));
475 rc = xmlTextWriterEndElement(writer);
513 xmlCharEncodingHandlerPtr
handler;
518 handler = xmlFindCharEncodingHandler(encoding);
521 m_logger <<
kWARNING <<
"ConvertInput: no encoding handler found for " << (encoding ? encoding :
"") <<
GEndl;
525 size = (int) strlen(in) + 1;
526 out_size = size * 2 - 1;
527 out = (
unsigned char *) xmlMalloc((
size_t) out_size);
531 ret =
handler->input(out, &out_size, (
const xmlChar *) in, &temp);
532 if ((ret < 0) || (temp - size + 1)) {
536 m_logger <<
kWARNING <<
"ConvertInput: conversion wasn't successful. Converted: " << temp <<
" octets." <<
GEndl;
542 out = (
unsigned char *) xmlRealloc(out, out_size + 1);
ClassImp(Root::TGoodRunsListWriter) using namespace std
xmlTextWriter * xmlTextWriterPtr
Int_t GetRunNumber() const
xmlChar * ConvertInput(const char *in, const char *encoding)
ConvertInput: @in: string in a given encoding @encoding: the encoding used.
const TGoodRunsList GetMergedGoodRunsList(const Root::BoolOperation &operation=OR) const
Bool_t WriteNamedLumiRange(xmlTextWriterPtr writer)
Bool_t WriteLumiRangeCollection(xmlTextWriterPtr writer)
const TString & GetXMLString()
std::vector< TString > m_xmlstringVec
Bool_t WriteElement(xmlTextWriterPtr writer, const char *name, const char *value=0, const char *atr1=0, const char *val1=0, const char *atr2=0, const char *val2=0)
const std::vector< TString > & GetXMLStrings()
Bool_t WriteLumiBlockCollection(xmlTextWriterPtr writer, const TGoodRun &goodrun)
void handler(int sig)
signal handler