Merge branch 'master' into messaging

This commit is contained in:
Joshua Scott 2018-04-22 17:25:22 +01:00
commit 9c6a756f68
2 changed files with 26 additions and 3 deletions

View File

@ -34,7 +34,8 @@ namespace dml
return m_field_map.at(name)->is_type<ValueT>();
}
FieldBase *get_field(std::string name) const;
FieldBase *get_field(std::string name);
const FieldBase *get_field(std::string name) const;
/**
* Returns a previously added field with the specified name
@ -44,7 +45,22 @@ namespace dml
* returned.
*/
template <typename ValueT>
Field<ValueT> *get_field(std::string name) const
Field<ValueT> *get_field(std::string name)
{
if (has_field<ValueT>(name))
return dynamic_cast<Field<ValueT> *>(m_field_map.at(name));
return nullptr;
}
/**
* Returns a previously added field with the specified name
* and type.
*
* If the field was not previously added, then a nullptr is
* returned.
*/
template <typename ValueT>
const Field<ValueT> *get_field(std::string name) const
{
if (has_field<ValueT>(name))
return dynamic_cast<Field<ValueT> *>(m_field_map.at(name));

View File

@ -30,7 +30,14 @@ namespace dml
return m_field_map.count(name);
}
FieldBase *Record::get_field(std::string name) const
FieldBase *Record::get_field(std::string name)
{
if (has_field(name))
return m_field_map.at(name);
return nullptr;
}
const FieldBase *Record::get_field(std::string name) const
{
if (has_field(name))
return m_field_map.at(name);