Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
tlockdata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <boost/algorithm/string/join.hpp>
20#include <boost/lexical_cast.hpp>
23
24using namespace QuantLib;
25using namespace QuantExt;
26
27namespace ore {
28namespace data {
29
31 XMLUtils::checkNode(node, "TreasuryLockData");
32 QL_REQUIRE(node, "No TreasuryLockData Node");
33 payer_ = XMLUtils::getChildValueAsBool(node, "Payer", true);
36 referenceRate_ = XMLUtils::getChildValueAsDouble(node, "ReferenceRate", true);
37 dayCounter_ = XMLUtils::getChildValue(node, "DayCounter", false);
38 terminationDate_ = XMLUtils::getChildValue(node, "TerminationDate", true);
39 paymentGap_ = XMLUtils::getChildValueAsInt(node, "PaymentGap", false, 0);
40 paymentCalendar_ = XMLUtils::getChildValue(node, "PaymentCalendar", true);
41 empty_ = false;
42}
43
45 XMLNode* tlockNode = doc.allocNode("TreasuryLockData");
46 XMLUtils::addChild(doc, tlockNode, "Payer", payer_);
48 XMLUtils::addChild(doc, tlockNode, "ReferenceRate", referenceRate_);
49 if (!dayCounter_.empty())
50 XMLUtils::addChild(doc, tlockNode, "DayCounter", dayCounter_);
51 XMLUtils::addChild(doc, tlockNode, "TerminationDate", terminationDate_);
52 XMLUtils::addChild(doc, tlockNode, "PaymentGap", paymentGap_);
53 XMLUtils::addChild(doc, tlockNode, "PaymentCalendar", paymentCalendar_);
54 return tlockNode;
55}
56
57} // namespace data
58} // namespace ore
virtual void fromXML(XMLNode *node) override
XMLSerializable interface.
Definition: bond.cpp:59
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: bond.cpp:95
virtual void fromXML(XMLNode *node) override
XMLSerializable interface.
Definition: tlockdata.cpp:30
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: tlockdata.cpp:44
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
A class to hold Treasury-Lock data.