1 #ifndef JSON_SPIRIT_WRITER_TEMPLATE 2 #define JSON_SPIRIT_WRITER_TEMPLATE 21 const char ch =
static_cast< char >(
c );
23 if( ch < 10 )
return '0' +
ch;
28 template<
class String_type >
31 String_type result( 6,
'\\' );
43 template<
typename Char_type,
class String_type >
48 case '"': s += to_str< String_type >(
"\\\"" );
return true;
49 case '\\': s += to_str< String_type >(
"\\\\" );
return true;
50 case '\b': s += to_str< String_type >(
"\\b" );
return true;
51 case '\f': s += to_str< String_type >(
"\\f" );
return true;
52 case '\n': s += to_str< String_type >(
"\\n" );
return true;
53 case '\r': s += to_str< String_type >(
"\\r" );
return true;
54 case '\t': s += to_str< String_type >(
"\\t" );
return true;
60 template<
class String_type >
63 typedef typename String_type::const_iterator Iter_type;
64 typedef typename String_type::value_type Char_type;
68 const Iter_type end( s.end() );
70 for( Iter_type i = s.begin(); i != end; ++i )
72 const Char_type
c( *i );
76 const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c );
78 if( iswprint( unsigned_c ) )
84 result += non_printable_to_string< String_type >( unsigned_c );
94 template<
class Value_type,
class Ostream_type >
118 switch( value.type() )
125 case real_type:
os_ << std::showpoint << std::setprecision( 16 )
126 << value.get_real();
break;
142 void output(
const Obj_member_type& member )
144 output( Config_type::get_name( member ) );
space();
151 if( value.is_uint64() )
153 os_ << value.get_uint64();
157 os_ << value.get_int64();
168 os_ << to_str< String_type >( b ?
"true" :
"false" );
178 for(
typename T::const_iterator i = t.begin(); i != t.end(); ++i )
182 typename T::const_iterator next = i;
184 if( ++next != t.end())
224 template<
class Value_type,
class Ostream_type >
230 template<
class Value_type >
233 typedef typename Value_type::String_type::value_type
Char_type;
235 std::basic_ostringstream< Char_type > os;
String_type non_printable_to_string(unsigned int c)
String_type::value_type Char_type
void output(const Obj_member_type &member)
void output_array_or_obj(const T &t, Char_type start_char, Char_type end_char)
void output_int(const Value_type &value)
Config_type::Array_type Array_type
assert(len-trim+(2 *lenIndices)<=WIDTH)
Config_type::String_type String_type
void output(const Value_type &value)
string pretty(h160 _a, dev::eth::State const &_st)
void write_stream(const Value_type &value, Ostream_type &os, bool pretty)
Object_type::value_type Obj_member_type
bool add_esc_char(Char_type c, String_type &s)
char to_hex_char(unsigned int c)
void output(const Object_type &obj)
Generator(const Value_type &value, Ostream_type &os, bool pretty)
int get_value(const Value &value, Type_to_type< int >)
void output(const Array_type &arr)
Config_type::Object_type Object_type
Value_type::String_type write_string(const Value_type &value, bool pretty)
void output(const String_type &s)
uint32_t ch(uint32_t x, uint32_t y, uint32_t z)
String_type add_esc_chars(const String_type &s)
Value_type::Config_type Config_type
Generator & operator=(const Generator &)