From 541b44b873738a6b954125b31bca5f18c328bade Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 24 Oct 2024 15:17:01 -0400 Subject: Add LL::ResultSet subclass VectorResultSet for the simple case. Update existing simple LL::ResultSet subclasses. --- indra/llcommon/resultset.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/resultset.h') 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 // std::ostream #include // std::pair +#include namespace LL { @@ -41,11 +42,6 @@ struct ResultSet: public LLIntTracker LLSD getSlice(int index, int count) const; // Like getSlice(), but also return adjusted start position. std::pair 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 virtual ~ResultSet(); }; +// VectorResultSet is for the simple case of a ResultSet managing a single +// std::vector. +template +struct VectorResultSet: public ResultSet +{ + using super = VectorResultSet; + + 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 mVector; +}; + } // namespace LL std::ostream& operator<<(std::ostream& out, const LL::ResultSet& self); -- cgit v1.2.3