Value::tryAs() tryFrom()

This commit is contained in:
Michael Davidsaver
2019-12-18 18:25:11 -08:00
parent d2c4457a08
commit 35dd24f46f
2 changed files with 43 additions and 14 deletions
+24
View File
@@ -241,6 +241,18 @@ void Value::copyOut(void *ptr, StoreType type) const
throw NoConvert();
}
bool Value::tryCopyOut(void *ptr, StoreType type) const
{
try {
copyOut(ptr, type);
return true;
}catch(NoField&){
return false;
}catch(NoConvert&){
return false;
}
}
namespace {
// C-style cast between scalar storage types, and print to string (base 10)
template<typename Dest>
@@ -342,6 +354,18 @@ void Value::copyIn(const void *ptr, StoreType type)
mark();
}
bool Value::tryCopyIn(const void *ptr, StoreType type)
{
try {
copyIn(ptr, type);
return true;
}catch(NoField&){
return false;
}catch(NoConvert&){
return false;
}
}
void Value::traverse(const std::string &expr, bool modify)
{
size_t pos=0;