summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/resultset.cpp14
-rw-r--r--indra/llcommon/resultset.h21
2 files changed, 16 insertions, 19 deletions
diff --git a/indra/llcommon/resultset.cpp b/indra/llcommon/resultset.cpp
index 4d7b00eabd..8bdfbec272 100644
--- a/indra/llcommon/resultset.cpp
+++ b/indra/llcommon/resultset.cpp
@@ -61,20 +61,6 @@ LLSD ResultSet::getSlice(int index, int count) const
return getSliceStart(index, count).first;
}
-/*==========================================================================*|
-LLSD ResultSet::getSingle(int index) const
-{
- if (0 <= index && index < getLength())
- {
- return getSingle_(index);
- }
- else
- {
- return {};
- }
-}
-|*==========================================================================*/
-
ResultSet::ResultSet(const std::string& name):
mName(name)
{
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);