Skip to content
Snippets Groups Projects
Commit 64e57519 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Add direct array and map access to LLSD for range-for usage - Shyotl

parent ff9084ed
No related branches found
No related tags found
No related merge requests found
...@@ -141,10 +141,15 @@ class LLSD::Impl ...@@ -141,10 +141,15 @@ class LLSD::Impl
virtual void erase(Integer) { } virtual void erase(Integer) { }
virtual const LLSD& ref(Integer) const { return undef(); } virtual const LLSD& ref(Integer) const { return undef(); }
virtual LLSD::map_const_iterator beginMap() const { return endMap(); } virtual const std::map<String, LLSD>& map() const { static const std::map<String, LLSD> empty; return empty; }
virtual LLSD::map_const_iterator endMap() const { static const std::map<String, LLSD> empty; return empty.end(); } virtual std::map<String, LLSD>& map() { static std::map<String, LLSD> empty; return empty; }
virtual LLSD::array_const_iterator beginArray() const { return endArray(); } LLSD::map_const_iterator beginMap() const { return endMap(); }
virtual LLSD::array_const_iterator endArray() const { static const std::vector<LLSD> empty; return empty.end(); } LLSD::map_const_iterator endMap() const { return map().end(); }
virtual const std::vector<LLSD>& array() const { static const std::vector<LLSD> empty; return empty; }
virtual std::vector<LLSD>& array() { static std::vector<LLSD> empty; return empty; }
LLSD::array_const_iterator beginArray() const { return endArray(); }
LLSD::array_const_iterator endArray() const { return array().end(); }
virtual void dumpStats() const; virtual void dumpStats() const;
virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; virtual void calcStats(S32 type_counts[], S32 share_counts[]) const;
...@@ -389,10 +394,8 @@ namespace ...@@ -389,10 +394,8 @@ namespace
virtual int size() const { return mData.size(); } virtual int size() const { return mData.size(); }
LLSD::map_iterator beginMap() { return mData.begin(); } DataMap& map() final override { return mData; }
LLSD::map_iterator endMap() { return mData.end(); } const DataMap& map() const final override { return mData; }
virtual LLSD::map_const_iterator beginMap() const { return mData.begin(); }
virtual LLSD::map_const_iterator endMap() const { return mData.end(); }
virtual void dumpStats() const; virtual void dumpStats() const;
virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; virtual void calcStats(S32 type_counts[], S32 share_counts[]) const;
...@@ -521,12 +524,8 @@ namespace ...@@ -521,12 +524,8 @@ namespace
LLSD& ref(LLSD::Integer); LLSD& ref(LLSD::Integer);
virtual const LLSD& ref(LLSD::Integer) const; virtual const LLSD& ref(LLSD::Integer) const;
LLSD::array_iterator beginArray() { return mData.begin(); } DataVector& array() final override { return mData; }
LLSD::array_iterator endArray() { return mData.end(); } const DataVector& array() const final override { return mData; }
LLSD::reverse_array_iterator rbeginArray() { return mData.rbegin(); }
LLSD::reverse_array_iterator rendArray() { return mData.rend(); }
virtual LLSD::array_const_iterator beginArray() const { return mData.begin(); }
virtual LLSD::array_const_iterator endArray() const { return mData.end(); }
virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; virtual void calcStats(S32 type_counts[], S32 share_counts[]) const;
}; };
...@@ -957,18 +956,24 @@ const char *LLSD::dump(const LLSD &llsd) ...@@ -957,18 +956,24 @@ const char *LLSD::dump(const LLSD &llsd)
return llsd_dump(llsd, false); return llsd_dump(llsd, false);
} }
LLSD::map_iterator LLSD::beginMap() { return makeMap(impl).beginMap(); } std::map<LLSD::String, LLSD>& LLSD::map() { return makeMap(impl).map(); }
LLSD::map_iterator LLSD::endMap() { return makeMap(impl).endMap(); } const std::map<LLSD::String, LLSD>& LLSD::map() const { return safe(impl).map(); }
LLSD::map_const_iterator LLSD::beginMap() const { return safe(impl).beginMap(); }
LLSD::map_const_iterator LLSD::endMap() const { return safe(impl).endMap(); } LLSD::map_iterator LLSD::beginMap() { return map().begin(); }
LLSD::map_iterator LLSD::endMap() { return map().end(); }
LLSD::map_const_iterator LLSD::beginMap() const { return map().cbegin(); }
LLSD::map_const_iterator LLSD::endMap() const { return map().cend(); }
std::vector<LLSD>& LLSD::array() { return makeArray(impl).array(); }
const std::vector<LLSD>& LLSD::array() const { return safe(impl).array(); }
LLSD::array_iterator LLSD::beginArray() { return makeArray(impl).beginArray(); } LLSD::array_iterator LLSD::beginArray() { return array().begin(); }
LLSD::array_iterator LLSD::endArray() { return makeArray(impl).endArray(); } LLSD::array_iterator LLSD::endArray() { return array().end(); }
LLSD::array_const_iterator LLSD::beginArray() const{ return safe(impl).beginArray(); } LLSD::array_const_iterator LLSD::beginArray() const{ return array().cbegin(); }
LLSD::array_const_iterator LLSD::endArray() const { return safe(impl).endArray(); } LLSD::array_const_iterator LLSD::endArray() const { return array().cend(); }
LLSD::reverse_array_iterator LLSD::rbeginArray() { return makeArray(impl).rbeginArray(); } LLSD::reverse_array_iterator LLSD::rbeginArray() { return array().rbegin(); }
LLSD::reverse_array_iterator LLSD::rendArray() { return makeArray(impl).rendArray(); } LLSD::reverse_array_iterator LLSD::rendArray() { return array().rend(); }
namespace llsd namespace llsd
{ {
......
...@@ -317,6 +317,9 @@ class LL_COMMON_API LLSD ...@@ -317,6 +317,9 @@ class LL_COMMON_API LLSD
typedef std::map<String, LLSD>::iterator map_iterator; typedef std::map<String, LLSD>::iterator map_iterator;
typedef std::map<String, LLSD>::const_iterator map_const_iterator; typedef std::map<String, LLSD>::const_iterator map_const_iterator;
std::map<String, LLSD>& map();
const std::map<String, LLSD>& map() const;
map_iterator beginMap(); map_iterator beginMap();
map_iterator endMap(); map_iterator endMap();
map_const_iterator beginMap() const; map_const_iterator beginMap() const;
...@@ -326,6 +329,9 @@ class LL_COMMON_API LLSD ...@@ -326,6 +329,9 @@ class LL_COMMON_API LLSD
typedef std::vector<LLSD>::const_iterator array_const_iterator; typedef std::vector<LLSD>::const_iterator array_const_iterator;
typedef std::vector<LLSD>::reverse_iterator reverse_array_iterator; typedef std::vector<LLSD>::reverse_iterator reverse_array_iterator;
std::vector<LLSD>& array();
const std::vector<LLSD>& array() const;
array_iterator beginArray(); array_iterator beginArray();
array_iterator endArray(); array_iterator endArray();
array_const_iterator beginArray() const; array_const_iterator beginArray() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment