mirror of https://github.com/SeanOMik/libki.git
dml: Fix some const-correctness problems
This commit is contained in:
parent
3922ca4b39
commit
802dfeba29
|
@ -34,7 +34,8 @@ namespace dml
|
||||||
return m_field_map.at(name)->is_type<ValueT>();
|
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
|
* Returns a previously added field with the specified name
|
||||||
|
@ -44,7 +45,22 @@ namespace dml
|
||||||
* returned.
|
* returned.
|
||||||
*/
|
*/
|
||||||
template <typename ValueT>
|
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))
|
if (has_field<ValueT>(name))
|
||||||
return dynamic_cast<Field<ValueT> *>(m_field_map.at(name));
|
return dynamic_cast<Field<ValueT> *>(m_field_map.at(name));
|
||||||
|
|
|
@ -30,7 +30,14 @@ namespace dml
|
||||||
return m_field_map.count(name);
|
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))
|
if (has_field(name))
|
||||||
return m_field_map.at(name);
|
return m_field_map.at(name);
|
||||||
|
|
Loading…
Reference in New Issue