diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-11-11 18:57:13 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-11-12 12:32:01 +0800 |
commit | 6530f56b97f57cb7d80bb916a2b15af0b7f6c425 (patch) | |
tree | 024f7870252fe309ebdef3fbd4f2a34f1e9bc5ee /indra/llcommon/resultset.h | |
parent | 5704c81c1b6dc1da7ec3cfb5ee3979d0fc1db86d (diff) | |
parent | 814d6d43f0720bda2e74a0ecedb560ad8fcf10a9 (diff) |
Merge remote-tracking branch 'secondlife/release/maint-c' into maint-c
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); |