32 if (nettingSetDetailsNode) {
46 std::function<boost::any(
XMLNode*)> getValue;
47 getValue = [&getValue](
XMLNode* node) {
54 std::multimap<string, boost::any> subAddFields;
55 for (
XMLNode* child : children) {
57 boost::any childValue = getValue(child);
58 subAddFields.insert({
name, childValue});
90 std::function<void(
XMLNode*,
const string&,
const boost::any&)> addChild;
91 addChild = [&addChild, &doc](
XMLNode* node,
const string&
name,
const boost::any& val) {
92 if (val.type() ==
typeid(string)) {
95 QL_REQUIRE(val.type() ==
typeid(std::multimap<string, boost::any>),
96 "Additional field type must be either string or map<string, boost::any>");
99 for (
const auto& kv : boost::any_cast<std::multimap<string, boost::any>>(val)) {
100 addChild(childNode, kv.first, kv.second);
106 addChild(additionalNode, it.first, it.second);
111 map<string, string> stringAddFields;
113 if (f.second.type() ==
typeid(
string))
114 stringAddFields[f.first] = boost::any_cast<string>(f.second);
115 return stringAddFields;
120 auto it = af.find(
name);
121 QL_REQUIRE(it != af.end() || !mandatory,
122 "Envelope::additionalField(): Mandatory field '" <<
name <<
"' not found.");
123 return it == af.end() ? defaultValue : it->second;
129 "Envelope::additionalField(): Mandatory field '" <<
name <<
"' not found.");
set< string > portfolioIds_
const map< string, string > additionalFields() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
void setAdditionalField(const std::string &key, const boost::any &value)
NettingSetDetails nettingSetDetails_
const string & nettingSetId() const
boost::any additionalAnyField(const std::string &name, const bool mandatory=true, const boost::any &defaultValue=boost::none) const
map< string, boost::any > additionalFields_
string additionalField(const std::string &name, const bool mandatory=true, const std::string &defaultValue=std::string()) const
Serializable object holding netting set identification data.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const string & nettingSetId() const
bool emptyOptionalFields() const
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static string getNodeName(XMLNode *n)
Get and set a node's name.
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
Get a node's value.
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
SafeStack< ValueType > value
trade envelope data model and serialization
Classes and functions for log message handling.
Serializable Credit Default Swap.