Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
tradeactions.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
20
22
23namespace ore {
24namespace data {
25
27 XMLUtils::checkNode(node, "TradeAction");
28 type_ = XMLUtils::getChildValue(node, "Type", true);
29 owner_ = XMLUtils::getChildValue(node, "Owner", true);
30 schedule_.fromXML(XMLUtils::getChildNode(node, "Schedule"));
31}
32
34 XMLNode* node = doc.allocNode("TradeAction");
35 QL_REQUIRE(node, "Failed to create trade node");
36 XMLUtils::addChild(doc, node, "Type", type_);
37 XMLUtils::addChild(doc, node, "Owner", owner_);
39 return node;
40}
41
43 XMLUtils::checkNode(node, "TradeActions");
44 for (auto& action : XMLUtils::getChildrenNodes(node, "TradeAction")) {
45 actions_.emplace_back();
46 actions_.back().fromXML(action);
47 }
48}
49
51 XMLNode* node = doc.allocNode("TradeActions");
52 for (auto& action : actions_)
53 XMLUtils::appendNode(node, action.toXML(doc));
54 return node;
55}
56} // namespace data
57} // namespace ore
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
virtual void fromXML(XMLNode *node) override
vector< TradeAction > actions_
virtual XMLNode * toXML(XMLDocument &doc) const override
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
XML Utilities Class.
Definition: xmlutils.hpp:119
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
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
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23