diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-10-24 15:17:01 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-10-24 15:17:01 -0400 |
commit | 541b44b873738a6b954125b31bca5f18c328bade (patch) | |
tree | 4d1c00892b2d91e6943ccc5c1e3944e9e774ec59 /indra/llcommon/resultset.h | |
parent | b611324db58def7d65f4bfc721e7dc1c378b7fa3 (diff) |
Add LL::ResultSet subclass VectorResultSet for the simple case.
Update existing simple LL::ResultSet subclasses.
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); |