本文整理汇总了C++中LLSD::asReal方法的典型用法代码示例。如果您正苦于以下问题:C++ LLSD::asReal方法的具体用法?C++ LLSD::asReal怎么用?C++ LLSD::asReal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLSD
的用法示例。
在下文中一共展示了LLSD::asReal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: llsd_equals
bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits)
{
// We're comparing strict equality of LLSD representation rather than
// performing any conversions. So if the types aren't equal, the LLSD
// values aren't equal.
if (lhs.type() != rhs.type())
{
return false;
}
// Here we know both types are equal. Now compare values.
switch (lhs.type())
{
case LLSD::TypeUndefined:
// Both are TypeUndefined. There's nothing more to know.
return true;
case LLSD::TypeReal:
// This is where the 'bits' argument comes in handy. If passed
// explicitly, it means to use is_approx_equal_fraction() to compare.
if (bits >= 0)
{
return is_approx_equal_fraction(lhs.asReal(), rhs.asReal(), bits);
}
// Otherwise we compare bit representations, and the usual caveats
// about comparing floating-point numbers apply. Omitting 'bits' when
// comparing Real values is only useful when we expect identical bit
// representation for a given Real value, e.g. for integer-valued
// Reals.
return (lhs.asReal() == rhs.asReal());
#define COMPARE_SCALAR(type) \
case LLSD::Type##type: \
/* LLSD::URI has operator!=() but not operator==() */ \
/* rely on the optimizer for all others */ \
return (! (lhs.as##type() != rhs.as##type()))
COMPARE_SCALAR(Boolean);
COMPARE_SCALAR(Integer);
COMPARE_SCALAR(String);
COMPARE_SCALAR(UUID);
COMPARE_SCALAR(Date);
COMPARE_SCALAR(URI);
COMPARE_SCALAR(Binary);
#undef COMPARE_SCALAR
case LLSD::TypeArray:
{
LLSD::array_const_iterator
lai(lhs.beginArray()), laend(lhs.endArray()),
rai(rhs.beginArray()), raend(rhs.endArray());
// Compare array elements, walking the two arrays in parallel.
for ( ; lai != laend && rai != raend; ++lai, ++rai)
{
// If any one array element is unequal, the arrays are unequal.
if (! llsd_equals(*lai, *rai, bits))
return false;
}
// Here we've reached the end of one or the other array. They're equal
// only if they're BOTH at end: that is, if they have equal length too.
return (lai == laend && rai == raend);
}
case LLSD::TypeMap:
{
// Build a set of all rhs keys.
std::set<LLSD::String> rhskeys;
for (LLSD::map_const_iterator rmi(rhs.beginMap()), rmend(rhs.endMap());
rmi != rmend; ++rmi)
{
rhskeys.insert(rmi->first);
}
// Now walk all the lhs keys.
for (LLSD::map_const_iterator lmi(lhs.beginMap()), lmend(lhs.endMap());
lmi != lmend; ++lmi)
{
// Try to erase this lhs key from the set of rhs keys. If rhs has
// no such key, the maps are unequal. erase(key) returns count of
// items erased.
if (rhskeys.erase(lmi->first) != 1)
return false;
// Both maps have the current key. Compare values.
if (! llsd_equals(lmi->second, rhs[lmi->first], bits))
return false;
}
// We've now established that all the lhs keys have equal values in
// both maps. The maps are equal unless rhs contains a superset of
// those keys.
return rhskeys.empty();
}
default:
// We expect that every possible type() value is specifically handled
// above. Failing to extend this switch to support a new LLSD type is
// an error that must be brought to the coder's attention.
LL_ERRS("llsd_equals") << "llsd_equals(" << lhs << ", " << rhs << ", " << bits << "): "
"unknown type " << lhs.type() << LL_ENDL;
return false; // pacify the compiler
}
//.........这里部分代码省略.........
示例2: handleFlexLODChanged
static bool handleFlexLODChanged(const LLSD& newvalue)
{
LLVolumeImplFlexible::sUpdateFactor = (F32) newvalue.asReal();
return true;
}
示例3: handleBandwidthChanged
static bool handleBandwidthChanged(const LLSD& newvalue)
{
gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
return true;
}
示例4: handleTerrainScaleChanged
static bool handleTerrainScaleChanged(const LLSD& inputvalue)
{
LLSD newvalue = 1.f / inputvalue.asReal();
LLDrawPoolTerrain::sDetailScale = newvalue.asReal();
return true;
}
示例5: handleAvatarPhysicsLODChanged
static bool handleAvatarPhysicsLODChanged(const LLSD& newvalue)
{
LLVOAvatar::sPhysicsLODFactor = (F32) newvalue.asReal();
return true;
}
示例6: handleAvatarBoobXYInfluence
static bool handleAvatarBoobXYInfluence(const LLSD& newvalue)
{
LLVOAvatar::sBoobConfig.XYInfluence = (F32) newvalue.asReal();
return true;
}
示例7: switch
void LLFilterSD2XMLRPC::streamOut(std::ostream& ostr, const LLSD& sd)
{
ostr << "<value>";
switch(sd.type())
{
case LLSD::TypeMap:
{
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(map) BEGIN" << llendl;
#endif
ostr << "<struct>";
if(ostr.fail())
{
llinfos << "STREAM FAILURE writing struct" << llendl;
}
LLSD::map_const_iterator it = sd.beginMap();
LLSD::map_const_iterator end = sd.endMap();
for(; it != end; ++it)
{
ostr << "<member><name>" << xml_escape_string((*it).first)
<< "</name>";
streamOut(ostr, (*it).second);
if(ostr.fail())
{
llinfos << "STREAM FAILURE writing '" << (*it).first
<< "' with sd type " << (*it).second.type() << llendl;
}
ostr << "</member>";
}
ostr << "</struct>";
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(map) END" << llendl;
#endif
break;
}
case LLSD::TypeArray:
{
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(array) BEGIN" << llendl;
#endif
ostr << "<array><data>";
LLSD::array_const_iterator it = sd.beginArray();
LLSD::array_const_iterator end = sd.endArray();
for(; it != end; ++it)
{
streamOut(ostr, *it);
if(ostr.fail())
{
llinfos << "STREAM FAILURE writing array element sd type "
<< (*it).type() << llendl;
}
}
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(array) END" << llendl;
#endif
ostr << "</data></array>";
break;
}
case LLSD::TypeUndefined:
// treat undefined as a bool with a false value.
case LLSD::TypeBoolean:
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(bool)" << llendl;
#endif
ostr << "<boolean>" << (sd.asBoolean() ? "1" : "0") << "</boolean>";
break;
case LLSD::TypeInteger:
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(int)" << llendl;
#endif
ostr << "<i4>" << sd.asInteger() << "</i4>";
break;
case LLSD::TypeReal:
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(real)" << llendl;
#endif
ostr << "<double>" << sd.asReal() << "</double>";
break;
case LLSD::TypeString:
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(string)" << llendl;
#endif
ostr << "<string>" << xml_escape_string(sd.asString()) << "</string>";
break;
case LLSD::TypeUUID:
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(uuid)" << llendl;
#endif
// serialize it as a string
ostr << "<string>" << sd.asString() << "</string>";
break;
case LLSD::TypeURI:
{
#if LL_SPEW_STREAM_OUT_DEBUGGING
llinfos << "streamOut(uri)" << llendl;
#endif
// serialize it as a string
ostr << "<string>" << xml_escape_string(sd.asString()) << "</string>";
break;
}
//.........这里部分代码省略.........
示例8: handleAvatarBoobVelMaxChanged
static bool handleAvatarBoobVelMaxChanged(const LLSD& newvalue)
{
LLVOAvatar::sBoobConfig.velMax = Meta7BoobUtils::convertVelMax((F32) newvalue.asReal());
LLVOAvatar::sBoobConfig.velMin = LLVOAvatar::sBoobConfig.velMin*LLVOAvatar::sBoobConfig.velMax;
return true;
}
示例9: format
// virtual
S32 LLSDBinaryFormatter::format(const LLSD& data, std::ostream& ostr, U32 options) const
{
S32 format_count = 1;
switch(data.type())
{
case LLSD::TypeMap:
{
ostr.put('{');
U32 size_nbo = htonl(data.size());
ostr.write((const char*)(&size_nbo), sizeof(U32));
LLSD::map_const_iterator iter = data.beginMap();
LLSD::map_const_iterator end = data.endMap();
for(; iter != end; ++iter)
{
ostr.put('k');
formatString((*iter).first, ostr);
format_count += format((*iter).second, ostr);
}
ostr.put('}');
break;
}
case LLSD::TypeArray:
{
ostr.put('[');
U32 size_nbo = htonl(data.size());
ostr.write((const char*)(&size_nbo), sizeof(U32));
LLSD::array_const_iterator iter = data.beginArray();
LLSD::array_const_iterator end = data.endArray();
for(; iter != end; ++iter)
{
format_count += format(*iter, ostr);
}
ostr.put(']');
break;
}
case LLSD::TypeUndefined:
ostr.put('!');
break;
case LLSD::TypeBoolean:
if(data.asBoolean()) ostr.put(BINARY_TRUE_SERIAL);
else ostr.put(BINARY_FALSE_SERIAL);
break;
case LLSD::TypeInteger:
{
ostr.put('i');
U32 value_nbo = htonl(data.asInteger());
ostr.write((const char*)(&value_nbo), sizeof(U32));
break;
}
case LLSD::TypeReal:
{
ostr.put('r');
F64 value_nbo = ll_htond(data.asReal());
ostr.write((const char*)(&value_nbo), sizeof(F64));
break;
}
case LLSD::TypeUUID:
{
ostr.put('u');
LLUUID value = data.asUUID();
ostr.write((const char*)(&value.mData), UUID_BYTES);
break;
}
case LLSD::TypeString:
ostr.put('s');
formatString(data.asString(), ostr);
break;
case LLSD::TypeDate:
{
ostr.put('d');
F64 value = data.asReal();
ostr.write((const char*)(&value), sizeof(F64));
break;
}
case LLSD::TypeURI:
ostr.put('l');
formatString(data.asString(), ostr);
break;
case LLSD::TypeBinary:
{
// *FIX: memory inefficient.
ostr.put('b');
std::vector<U8> buffer = data.asBinary();
U32 size_nbo = htonl(buffer.size());
ostr.write((const char*)(&size_nbo), sizeof(U32));
if(buffer.size()) ostr.write((const char*)&buffer[0], buffer.size());
break;
}
//.........这里部分代码省略.........
示例10: handleAvMorphTimeChanged
static bool handleAvMorphTimeChanged(const LLSD& newvalue)
{
LLVOAvatar::sAvMorphTime = (F32) newvalue.asReal();
return true;
}
示例11: handleAvatarBoobMassChanged
static bool handleAvatarBoobMassChanged(const LLSD& newvalue)
{
LLVOAvatar::sBoobConfig.mass = Meta7BoobUtils::convertMass((F32) newvalue.asReal());
return true;
}
示例12: updatePivotZ
//static
void LLManip::updatePivotZ(const LLSD &data)
{
sPivotZ = (F32)data.asReal();
}
示例13:
template <> void jc_rebind::rebind_callback<F32>(const LLSD &data, F32 *reciever){ *reciever = data.asReal(); }
示例14: setValue
void LLStatGraph::setValue(const LLSD& value)
{
mValue = (F32)value.asReal();
}
示例15: handleAvatarBoobVelMinChanged
static bool handleAvatarBoobVelMinChanged(const LLSD& newvalue)
{
LLVOAvatar::sBoobConfig.velMin = EmeraldBoobUtils::convertVelMin((F32) newvalue.asReal())*LLVOAvatar::sBoobConfig.velMax;
return true;
}