Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
trademonetary.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
21
22namespace ore {
23namespace data {
24
25
27 currency_ = XMLUtils::getChildValue(node, "Currency", false);
28 valueString_ = XMLUtils::getChildValue(node, "Value", true);
30}
31
33 XMLUtils::addChild(doc, node, "Value", valueString_);
34 XMLUtils::addChild(doc, node, "Currency", currency_);
35}
36
37std::string TradeMonetary::currency() const {
38 if (!currency_.empty())
40 else
41 return currency_;
42}
43
44QuantLib::Real TradeMonetary::value() const {
45 if (currency_.empty())
46 return value_;
47 else
49}
50
51} // namespace data
52} // namespace ore
std::string valueString_
store a string version of the value, this ensures toXML values matches fromXML input
std::string currency() const
void fromXMLNode(XMLNode *node)
QuantLib::Real value() const
void toXMLNode(XMLDocument &doc, XMLNode *node)
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:310
QuantLib::Real convertMinorToMajorCurrency(const std::string &s, QuantLib::Real value)
Convert a value from a minor ccy to major.
Definition: parsers.cpp:324
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.