fix build, added is_array and is_object to value
This commit is contained in:
parent
2476ae450d
commit
21ef2d11e9
3 changed files with 18 additions and 10 deletions
|
|
@ -139,6 +139,8 @@ namespace fc {
|
|||
const char* type()const;
|
||||
bool is_null()const;
|
||||
bool is_string()const;
|
||||
bool is_object()const;
|
||||
bool is_array()const;
|
||||
|
||||
void visit( const_visitor&& v )const;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ fc::string error_frame::to_detail_string()const {
|
|||
return ss.str();
|
||||
}
|
||||
fc::string error_frame::to_string()const {
|
||||
return substitute( desc, meta );
|
||||
return substitute( desc, meta ? *meta : fc::value() );
|
||||
}
|
||||
#if 0
|
||||
fc::stringstream ss;
|
||||
|
|
@ -158,18 +158,18 @@ fc::string substitute( const fc::string& format, const fc::value& keys ) {
|
|||
// the key is between prev and next
|
||||
fc::string key = format.substr( prev+1, (next-prev-1) );
|
||||
//slog( "key '%s'", key.c_str() );
|
||||
if( keys ) {
|
||||
auto itr = keys->find( key.c_str() );
|
||||
if( itr != keys->end() ) {
|
||||
if( itr->val.is_string() ) {
|
||||
ss<<itr->val.cast<fc::string>();
|
||||
} else {
|
||||
ss << fc::json::to_string( itr->val );
|
||||
}
|
||||
// if( keys ) {
|
||||
auto itr = keys.find( key.c_str() );
|
||||
if( itr != keys.end() ) {
|
||||
if( itr->val.is_string() ) {
|
||||
ss<<itr->val.cast<fc::string>();
|
||||
} else {
|
||||
ss << fc::json::to_string( itr->val );
|
||||
}
|
||||
} else {
|
||||
ss << "???";
|
||||
}
|
||||
}
|
||||
// }
|
||||
prev = next + 1;
|
||||
// find the next $
|
||||
next = format.find( '$', prev );
|
||||
|
|
|
|||
|
|
@ -291,6 +291,12 @@ value& value::operator=( const value& v ){
|
|||
bool value::is_null()const {
|
||||
return strcmp(gh(holder)->type(), "void") == 0;
|
||||
}
|
||||
bool value::is_object()const {
|
||||
return strcmp(gh(holder)->type(), "object") == 0;
|
||||
}
|
||||
bool value::is_array()const {
|
||||
return strcmp(gh(holder)->type(), "array") == 0;
|
||||
}
|
||||
bool value::is_string()const {
|
||||
return strcmp(gh(holder)->type(), "string") == 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue