drivers added SqlRecord::fieldNames()

This commit is contained in:
silverqx
2024-07-17 14:57:28 +02:00
parent 270b75bf8d
commit 97e0c2892e
2 changed files with 14 additions and 0 deletions
@@ -41,6 +41,9 @@ namespace Orm::Drivers
/*! Swap the SqlRecord. */
inline void swap(SqlRecord &other) noexcept;
/*! Get all field names. */
QStringList fieldNames() const;
/*! Get the field name at the given index. */
QString fieldName(size_type index) const;
/*! Get the index of the given field name (-1 if it can't be found). */
@@ -17,6 +17,17 @@ namespace Orm::Drivers
/* public */
QStringList SqlRecord::fieldNames() const
{
QStringList result;
result.reserve(m_fields.size());
for (const auto &field : m_fields)
result << field.name();
return result;
}
QString SqlRecord::fieldName(const size_type index) const
{
return m_fields.value(index).name();