mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-02 10:58:45 -05:00
QueryResult iterator nextRow() may get into infinite loop. Additionally, fixed handling of the case when each row of result could have a different count of fields.
42 lines
721 B
C++
42 lines
721 B
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "Field.hpp"
|
|
|
|
class QueryResult
|
|
{
|
|
|
|
public:
|
|
QueryResult();
|
|
|
|
virtual ~QueryResult(){};
|
|
|
|
const Field &operator[](int index) const
|
|
{
|
|
return rows[currentRow][index];
|
|
}
|
|
|
|
bool nextRow();
|
|
|
|
void addRow(const std::vector<Field> &row);
|
|
|
|
uint32_t getFieldCount() const
|
|
{
|
|
return rows[currentRow].size();
|
|
}
|
|
|
|
uint32_t getRowCount() const
|
|
{
|
|
return rows.size();
|
|
}
|
|
|
|
private:
|
|
uint32_t currentRow;
|
|
std::vector<std::vector<Field>> rows;
|
|
};
|