dml: Documentation

There's really not a lot worth documenting though.
This commit is contained in:
Joshua Scott 2018-03-30 21:34:06 +01:00
parent 605819b539
commit 6883cae2ae
3 changed files with 39 additions and 0 deletions

View File

@ -36,6 +36,10 @@ namespace dml
private:
ValueT m_value;
/**
* Returns a new Field with the same name, transferability,
* type, and value but with a different owner Record.
*/
Field<ValueT> *clone(const Record &record) const final
{
auto *clone = new Field<ValueT>(m_name, record);

View File

@ -11,6 +11,9 @@ namespace dml
{
class Record;
/**
* An abstract base class for DML fields.
*/
class FieldBase : public util::Serializable
{
friend Record;
@ -33,6 +36,10 @@ namespace dml
FieldBase(std::string name, const Record& record);
/**
* Returns a new Field with the same name, transferability
* and value but with a different owner Record.
*/
virtual FieldBase *clone(const Record &record) const = 0;
private:
const Record &m_record;

View File

@ -6,6 +6,9 @@ namespace ki
{
namespace dml
{
/**
* An ordered collection of DML fields.
*/
class Record final : public util::Serializable
{
public:
@ -13,8 +16,16 @@ namespace dml
Record(const Record &record);
virtual ~Record();
/**
* Returns true if a field of any type has the name
* specified.
*/
bool has_field(std::string name) const;
/**
* Returns true if a field exists with the specified
* name and type.
*/
template <typename ValueT>
bool has_field(std::string name) const
{
@ -23,6 +34,13 @@ namespace dml
return m_field_map.at(name)->is_type<ValueT>();
}
/**
* 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>
Field<ValueT> *get_field(std::string name) const
{
@ -31,6 +49,16 @@ namespace dml
return nullptr;
}
/**
* Adds a new field to the record with the specified name, type,
* and transferability, and returns the newly created field.
*
* If a field already exists with the specified name and type,
* then the previously added field is returned.
*
* If a field already exists with the specified name, but the type
* differs, then a nullptr is returned.
*/
template <typename ValueT>
Field<ValueT> *add_field(std::string name, bool transferable = true)
{