diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-11-11 09:57:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-11 09:57:49 +0200 |
commit | 814d6d43f0720bda2e74a0ecedb560ad8fcf10a9 (patch) | |
tree | 3db2802f0ab39f2d7b1264e2ac1d3599f1a3bd5a /indra/llcommon/resultset.h | |
parent | eccc9057d9d9799d3d5056bdfe255bd9e5e2be6a (diff) | |
parent | 32df877cd73b5b6a3672d0159c982077a4b67a9d (diff) |
Merge pull request #3067 from secondlife/marchcat/c-develop
develop → Maint C sync
Diffstat (limited to 'indra/llcommon/resultset.h')
-rw-r--r-- | indra/llcommon/resultset.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/indra/llcommon/resultset.h b/indra/llcommon/resultset.h index 90d52b6fe4..10d84c038f 100644 --- a/indra/llcommon/resultset.h +++ b/indra/llcommon/resultset.h @@ -17,6 +17,7 @@ #include "llsd.h" #include <iosfwd> // std::ostream #include <utility> // std::pair +#include <vector> namespace LL { @@ -41,11 +42,6 @@ struct ResultSet: public LLIntTracker<ResultSet> LLSD getSlice(int index, int count) const; // Like getSlice(), but also return adjusted start position. std::pair<LLSD, int> getSliceStart(int index, int count) const; -/*==========================================================================*| - // Retrieve LLSD corresponding to a single entry from the result set, - // with index validation. - LLSD getSingle(int index) const; -|*==========================================================================*/ /*---------------- the rest is solely for debug logging ----------------*/ std::string mName; @@ -54,6 +50,21 @@ struct ResultSet: public LLIntTracker<ResultSet> virtual ~ResultSet(); }; +// VectorResultSet is for the simple case of a ResultSet managing a single +// std::vector<T>. +template <typename T> +struct VectorResultSet: public ResultSet +{ + using super = VectorResultSet<T>; + + VectorResultSet(const std::string& name): ResultSet(name) {} + int getLength() const override { return narrow(mVector.size()); } + LLSD getSingle(int index) const override { return getSingleFrom(mVector[index]); } + virtual LLSD getSingleFrom(const T&) const = 0; + + std::vector<T> mVector; +}; + } // namespace LL std::ostream& operator<<(std::ostream& out, const LL::ResultSet& self); |