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;
|
const char* type()const;
|
||||||
bool is_null()const;
|
bool is_null()const;
|
||||||
bool is_string()const;
|
bool is_string()const;
|
||||||
|
bool is_object()const;
|
||||||
|
bool is_array()const;
|
||||||
|
|
||||||
void visit( const_visitor&& v )const;
|
void visit( const_visitor&& v )const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ fc::string error_frame::to_detail_string()const {
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
fc::string error_frame::to_string()const {
|
fc::string error_frame::to_string()const {
|
||||||
return substitute( desc, meta );
|
return substitute( desc, meta ? *meta : fc::value() );
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
fc::stringstream ss;
|
fc::stringstream ss;
|
||||||
|
|
@ -158,9 +158,9 @@ fc::string substitute( const fc::string& format, const fc::value& keys ) {
|
||||||
// the key is between prev and next
|
// the key is between prev and next
|
||||||
fc::string key = format.substr( prev+1, (next-prev-1) );
|
fc::string key = format.substr( prev+1, (next-prev-1) );
|
||||||
//slog( "key '%s'", key.c_str() );
|
//slog( "key '%s'", key.c_str() );
|
||||||
if( keys ) {
|
// if( keys ) {
|
||||||
auto itr = keys->find( key.c_str() );
|
auto itr = keys.find( key.c_str() );
|
||||||
if( itr != keys->end() ) {
|
if( itr != keys.end() ) {
|
||||||
if( itr->val.is_string() ) {
|
if( itr->val.is_string() ) {
|
||||||
ss<<itr->val.cast<fc::string>();
|
ss<<itr->val.cast<fc::string>();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -169,7 +169,7 @@ fc::string substitute( const fc::string& format, const fc::value& keys ) {
|
||||||
} else {
|
} else {
|
||||||
ss << "???";
|
ss << "???";
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
prev = next + 1;
|
prev = next + 1;
|
||||||
// find the next $
|
// find the next $
|
||||||
next = format.find( '$', prev );
|
next = format.find( '$', prev );
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,12 @@ value& value::operator=( const value& v ){
|
||||||
bool value::is_null()const {
|
bool value::is_null()const {
|
||||||
return strcmp(gh(holder)->type(), "void") == 0;
|
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 {
|
bool value::is_string()const {
|
||||||
return strcmp(gh(holder)->type(), "string") == 0;
|
return strcmp(gh(holder)->type(), "string") == 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue