2012-10-21 06:28:59 +00:00
|
|
|
#pragma once
|
2012-09-08 02:50:37 +00:00
|
|
|
#include <fc/string.hpp>
|
2012-10-21 06:28:59 +00:00
|
|
|
#include <fc/value.hpp>
|
|
|
|
|
#include <fc/value_cast.hpp>
|
|
|
|
|
#include <fc/vector_fwd.hpp>
|
2012-09-08 02:50:37 +00:00
|
|
|
|
|
|
|
|
namespace fc {
|
|
|
|
|
class istream;
|
|
|
|
|
class ostream;
|
2012-10-21 06:28:59 +00:00
|
|
|
class path;
|
2012-09-08 02:50:37 +00:00
|
|
|
|
|
|
|
|
namespace json {
|
2012-10-21 06:28:59 +00:00
|
|
|
string to_string( const value& o );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value from_string( const string& s );
|
|
|
|
|
value from_string( const char* s, const char* e );
|
|
|
|
|
value from_string( const fc::vector<char>& v );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string escape_string( const string& );
|
|
|
|
|
string unescape_string( const string& );
|
|
|
|
|
|
|
|
|
|
void write( ostream& out, const value& val );
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
void write( ostream& out, const T& val ) {
|
|
|
|
|
write( out, value(val) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
string to_string( const T& o ) {
|
|
|
|
|
return json::to_string(value(o));
|
|
|
|
|
}
|
2012-09-08 02:50:37 +00:00
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
T from_string( const string& s ) {
|
2012-10-21 06:28:59 +00:00
|
|
|
return value_cast<T>( from_string(s) );
|
2012-09-08 02:50:37 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-21 06:28:59 +00:00
|
|
|
value from_file( const fc::path& s );
|
|
|
|
|
template<typename T>
|
|
|
|
|
T from_file( const fc::path& s ) {
|
|
|
|
|
return value_cast<T>( fc::json::from_file(s) );
|
|
|
|
|
}
|
|
|
|
|
} // namespace json
|
|
|
|
|
} // fc
|
|
|
|
|
|