634 {
636 QuantLib::ext::shared_ptr<ReferenceDatum> refData;
637
638 if (refDataType.empty()) {
639 ALOG(
"Found referenceDatum without Type - skipping");
640 return refData;
641 }
642
644
646 QuantLib::Date validFrom;
647 if (validFromStr.empty()) {
648 validFrom = QuantLib::Date::minDate();
649 } else {
651 }
652
653 validFrom = inputValidFrom == QuantLib::Null<QuantLib::Date>() ? validFrom : inputValidFrom;
654
655 if (id.empty()) {
656 ALOG(
"Found referenceDatum without id - skipping");
657 return refData;
658 }
659
660 if (
auto it =
data_.find(make_pair(refDataType,
id)); it !=
data_.end()) {
661 if (it->second.count(validFrom) > 0) {
662 duplicates_.insert(make_tuple(refDataType,
id, validFrom));
663 ALOG(
"Found duplicate referenceDatum for type='" << refDataType <<
"', id='" <<
id <<
"', validFrom='"
664 << validFrom << "'");
665 return refData;
666 }
667 }
668
669 try {
671 refData->fromXML(node);
672
673 refData->setType(refDataType);
674 refData->setId(id);
675 refData->setValidFrom(validFrom);
676 data_[make_pair(refDataType,
id)][validFrom] = refData;
677 TLOG(
"added referenceDatum for type='" << refDataType <<
"', id='" <<
id <<
"', validFrom='" << validFrom
678 << "'");
679 } catch (const std::exception& e) {
680 buildErrors_[make_pair(refDataType,
id)][validFrom] = e.what();
681 ALOG(
"Error building referenceDatum for type='" << refDataType <<
"', id='" <<
id <<
"', validFrom='" << validFrom
682 << "': " << e.what());
683 }
684
685 return refData;
686}
map< std::pair< string, string >, std::map< QuantLib::Date, string > > buildErrors_
QuantLib::ext::shared_ptr< ReferenceDatum > buildReferenceDatum(const string &refDataType)
std::set< std::tuple< string, string, QuantLib::Date > > duplicates_
static string getAttribute(XMLNode *node, const string &attrName)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
#define ALOG(text)
Logging Macro (Level = Alert)
#define TLOG(text)
Logging Macro (Level = Data)