LLSD update. LLSD::insert no longer returns self. Use LLSD::with if return value is required.

This commit is contained in:
Shyotl
2011-03-27 19:06:15 -05:00
parent acf31bb885
commit de109f9f97
4 changed files with 44 additions and 42 deletions

View File

@@ -349,13 +349,13 @@ namespace
virtual LLSD::Boolean asBoolean() const { return !mData.empty(); }
virtual bool has(const LLSD::String&) const;
using LLSD::Impl::get; // Unhiding get(LLSD::Integer)
using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer)
using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer)
virtual bool has(const LLSD::String&) const;
virtual LLSD get(const LLSD::String&) const;
LLSD& insert(const LLSD::String& k, const LLSD& v);
void insert(const LLSD::String& k, const LLSD& v);
virtual void erase(const LLSD::String&);
LLSD& ref(const LLSD::String&);
virtual const LLSD& ref(const LLSD::String&) const;
@@ -394,14 +394,9 @@ namespace
return (i != mData.end()) ? i->second : LLSD();
}
LLSD& ImplMap::insert(const LLSD::String& k, const LLSD& v)
void ImplMap::insert(const LLSD::String& k, const LLSD& v)
{
mData.insert(DataMap::value_type(k, v));
#ifdef LL_MSVC7
return *((LLSD*)this);
#else
return *dynamic_cast<LLSD*>(this);
#endif
}
void ImplMap::erase(const LLSD::String& k)
@@ -444,15 +439,13 @@ namespace
virtual LLSD::Boolean asBoolean() const { return !mData.empty(); }
using LLSD::Impl::get; // Unhiding get(LLSD::String)
using LLSD::Impl::erase; // Unhiding erase(LLSD::String)
using LLSD::Impl::ref; // Unhiding ref(LLSD::String)
virtual int size() const;
using LLSD::Impl::get; // Unhiding get(LLSD::Integer)
using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer)
using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer)
virtual LLSD get(LLSD::Integer) const;
void set(LLSD::Integer, const LLSD&);
LLSD& insert(LLSD::Integer, const LLSD&);
void insert(LLSD::Integer, const LLSD&);
void append(const LLSD&);
virtual void erase(LLSD::Integer);
LLSD& ref(LLSD::Integer);
@@ -501,14 +494,10 @@ namespace
mData[index] = v;
}
LLSD& ImplArray::insert(LLSD::Integer i, const LLSD& v)
void ImplArray::insert(LLSD::Integer i, const LLSD& v)
{
if (i < 0) {
#ifdef LL_MSVC7
return *((LLSD*)this);
#else
return *dynamic_cast<LLSD*>(this);
#endif
return;
}
DataVector::size_type index = i;
@@ -518,11 +507,6 @@ namespace
}
mData.insert(mData.begin() + index, v);
#ifdef LL_MSVC7
return *((LLSD*)this);
#else
return *dynamic_cast<LLSD*>(this);
#endif
}
void ImplArray::append(const LLSD& v)
@@ -765,11 +749,16 @@ LLSD LLSD::emptyMap()
bool LLSD::has(const String& k) const { return safe(impl).has(k); }
LLSD LLSD::get(const String& k) const { return safe(impl).get(k); }
void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); }
LLSD& LLSD::insert(const String& k, const LLSD& v)
LLSD& LLSD::with(const String& k, const LLSD& v)
{
makeMap(impl).insert(k, v);
return *dynamic_cast<LLSD*>(this);
#ifdef LL_MSVC7
return *dynamic_cast<LLSD*>(this);
#else
return *this;
#endif
}
void LLSD::erase(const String& k) { makeMap(impl).erase(k); }
@@ -790,11 +779,16 @@ int LLSD::size() const { return safe(impl).size(); }
LLSD LLSD::get(Integer i) const { return safe(impl).get(i); }
void LLSD::set(Integer i, const LLSD& v){ makeArray(impl).set(i, v); }
void LLSD::insert(Integer i, const LLSD& v) { makeArray(impl).insert(i, v); }
LLSD& LLSD::insert(Integer i, const LLSD& v)
LLSD& LLSD::with(Integer i, const LLSD& v)
{
makeArray(impl).insert(i, v);
return *this;
#ifdef LL_MSVC7
return *dynamic_cast<LLSD*>(this);
#else
return *this;
#endif
}
void LLSD::append(const LLSD& v) { makeArray(impl).append(v); }
void LLSD::erase(Integer i) { makeArray(impl).erase(i); }
@@ -821,9 +815,15 @@ static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat)
{
std::ostringstream out;
if (useXMLFormat)
out << LLSDXMLStreamer(llsd);
{
LLSDXMLStreamer xml_streamer(llsd);
out << xml_streamer;
}
else
out << LLSDNotationStreamer(llsd);
{
LLSDNotationStreamer notation_streamer(llsd);
out << notation_streamer;
}
out_string = out.str();
}
int len = out_string.length();

View File

@@ -226,8 +226,9 @@ public:
bool has(const String&) const;
LLSD get(const String&) const;
LLSD& insert(const String&, const LLSD&);
void insert(const String&, const LLSD&);
void erase(const String&);
LLSD& with(const String&, const LLSD&);
LLSD& operator[](const String&);
LLSD& operator[](const char* c) { return (*this)[String(c)]; }
@@ -241,9 +242,10 @@ public:
LLSD get(Integer) const;
void set(Integer, const LLSD&);
LLSD& insert(Integer, const LLSD&);
void insert(Integer, const LLSD&);
void append(const LLSD&);
void erase(Integer);
LLSD& with(Integer, const LLSD&);
const LLSD& operator[](Integer) const;
LLSD& operator[](Integer);

View File

@@ -734,7 +734,7 @@ void LLNotificationChannelBase::connectChanged(const LLStandardSignal::slot_type
// only about new notifications
for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
slot.get_slot_function()(LLSD().insert("sigtype", "load").insert("id", (*it)->id()));
slot.get_slot_function()(LLSD().with("sigtype", "load").with("id", (*it)->id()));
}
// and then connect the signal so that all future notifications will also be
// forwarded.
@@ -922,7 +922,7 @@ void LLNotificationChannel::setComparator(LLNotificationComparator comparator)
mItems.swap(s2);
// notify clients that we've been resorted
mChanged(LLSD().insert("sigtype", "sort"));
mChanged(LLSD().with("sigtype", "sort"));
}
bool LLNotificationChannel::isEmpty() const
@@ -1432,7 +1432,7 @@ void LLNotifications::add(const LLNotificationPtr pNotif)
llerrs << "Notification added a second time to the master notification channel." << llendl;
}
updateItem(LLSD().insert("sigtype", "add").insert("id", pNotif->id()), pNotif);
updateItem(LLSD().with("sigtype", "add").with("id", pNotif->id()), pNotif);
}
void LLNotifications::cancel(LLNotificationPtr pNotif)
@@ -1442,7 +1442,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif)
{
llerrs << "Attempted to delete nonexistent notification " << pNotif->getName() << llendl;
}
updateItem(LLSD().insert("sigtype", "delete").insert("id", pNotif->id()), pNotif);
updateItem(LLSD().with("sigtype", "delete").with("id", pNotif->id()), pNotif);
pNotif->cancel();
}
@@ -1451,7 +1451,7 @@ void LLNotifications::update(const LLNotificationPtr pNotif)
LLNotificationSet::iterator it=mItems.find(pNotif);
if (it != mItems.end())
{
updateItem(LLSD().insert("sigtype", "change").insert("id", pNotif->id()), pNotif);
updateItem(LLSD().with("sigtype", "change").with("id", pNotif->id()), pNotif);
}
}

View File

@@ -476,7 +476,7 @@ bool idle_startup()
{
std::string diagnostic = "Could not start address resolution system";
LL_WARNS("AppInit") << diagnostic << LL_ENDL;
LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().insert("DIAGNOSTIC", diagnostic));
LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().with("DIAGNOSTIC", diagnostic));
}
//
@@ -536,7 +536,7 @@ bool idle_startup()
{
std::string diagnostic = llformat(" Error: %d", gMessageSystem->getErrorCode());
LL_WARNS("AppInit") << diagnostic << LL_ENDL;
LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().insert("DIAGNOSTIC", diagnostic));
LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().with("DIAGNOSTIC", diagnostic));
}
#if LL_WINDOWS
@@ -559,7 +559,7 @@ bool idle_startup()
}
else
{
LLAppViewer::instance()->earlyExit("MessageTemplateNotFound", LLSD().insert("PATH", message_template_path));
LLAppViewer::instance()->earlyExit("MessageTemplateNotFound", LLSD().with("PATH", message_template_path));
}
if(gMessageSystem && gMessageSystem->isOK())