From 21ef2d11e90403dbbab65d01ba2a611f34f14845 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 15 Jan 2013 13:08:00 -0500 Subject: [PATCH] fix build, added is_array and is_object to value --- include/fc/value.hpp | 2 ++ src/error_report.cpp | 20 ++++++++++---------- src/value.cpp | 6 ++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/fc/value.hpp b/include/fc/value.hpp index 0f15134..d94c2ed 100644 --- a/include/fc/value.hpp +++ b/include/fc/value.hpp @@ -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; diff --git a/src/error_report.cpp b/src/error_report.cpp index 8ecd192..3dbecfb 100644 --- a/src/error_report.cpp +++ b/src/error_report.cpp @@ -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<val.cast(); - } 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<val.cast(); + } else { + ss << fc::json::to_string( itr->val ); + } } else { ss << "???"; } - } + // } prev = next + 1; // find the next $ next = format.find( '$', prev ); diff --git a/src/value.cpp b/src/value.cpp index a69a042..a12db0f 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -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; }