@@ -57,15 +57,69 @@ namespace detail {
5757 }
5858 };
5959
60+ template <typename T>
61+ struct is_signed {
62+ static const bool value = std::numeric_limits<T>::is_signed;
63+ };
64+
6065 template <typename T>
6166 static inline T convert_integer (object o)
6267 {
63- return detail::convert_integer_sign<T, std::numeric_limits<T>::is_signed>::convert (o);
68+ return detail::convert_integer_sign<T, is_signed<T>::value>::convert (o);
69+ }
70+
71+ template <bool Signed>
72+ struct pack_char_sign ;
73+
74+ template <>
75+ struct pack_char_sign <true > {
76+ template <typename Stream>
77+ static inline packer<Stream>& pack (packer<Stream>& o, char v) {
78+ o.pack_int8 (v); return o;
79+ }
80+ };
81+
82+ template <>
83+ struct pack_char_sign <false > {
84+ template <typename Stream>
85+ static inline packer<Stream>& pack (packer<Stream>& o, char v) {
86+ o.pack_uint8 (v); return o;
87+ }
88+ };
89+
90+ template <typename Stream>
91+ static inline packer<Stream>& pack_char (packer<Stream>& o, char v) {
92+ return pack_char_sign<is_signed<char >::value>::pack (o, v);
93+ }
94+
95+ template <bool Signed>
96+ struct object_char_sign ;
97+
98+ template <>
99+ struct object_char_sign <true > {
100+ static inline void make (object& o, char v) {
101+ v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via .i64 = v
102+ : o.type = type::POSITIVE_INTEGER, o.via .u64 = v;
103+ }
104+ };
105+
106+ template <>
107+ struct object_char_sign <false > {
108+ static inline void make (object& o, char v) {
109+ o.type = type::POSITIVE_INTEGER, o.via .u64 = v;
110+ }
111+ };
112+
113+ static inline void object_char (object& o, char v) {
114+ return object_char_sign<is_signed<char >::value>::make (o, v);
64115 }
65116
66117} // namespace detail
67118} // namespace type
68119
120+ inline char & operator >> (object const & o, char & v)
121+ { v = type::detail::convert_integer<char >(o); return v; }
122+
69123
70124inline signed char & operator >> (object o, signed char & v)
71125 { v = type::detail::convert_integer<signed char >(o); return v; }
@@ -98,49 +152,56 @@ inline unsigned long& operator>> (object o, unsigned long& v)
98152inline unsigned long long & operator >> (object o, unsigned long long & v)
99153 { v = type::detail::convert_integer<unsigned long long >(o); return v; }
100154
155+ template <typename Stream>
156+ inline packer<Stream>& operator << (packer<Stream>& o, char v)
157+ { return type::detail::pack_char (o, v); }
101158
102159template <typename Stream>
103- inline packer<Stream>& operator << (packer<Stream>& o, const signed char & v)
160+ inline packer<Stream>& operator << (packer<Stream>& o, signed char v)
104161 { o.pack_int8 (v); return o; }
105162
106163template <typename Stream>
107- inline packer<Stream>& operator << (packer<Stream>& o, const signed short & v)
164+ inline packer<Stream>& operator << (packer<Stream>& o, signed short v)
108165 { o.pack_short (v); return o; }
109166
110167template <typename Stream>
111- inline packer<Stream>& operator << (packer<Stream>& o, const signed int & v)
168+ inline packer<Stream>& operator << (packer<Stream>& o, signed int v)
112169 { o.pack_int (v); return o; }
113170
114171template <typename Stream>
115- inline packer<Stream>& operator << (packer<Stream>& o, const signed long & v)
172+ inline packer<Stream>& operator << (packer<Stream>& o, signed long v)
116173 { o.pack_long (v); return o; }
117174
118175template <typename Stream>
119- inline packer<Stream>& operator << (packer<Stream>& o, const signed long long & v)
176+ inline packer<Stream>& operator << (packer<Stream>& o, signed long long v)
120177 { o.pack_long_long (v); return o; }
121178
122179
123180template <typename Stream>
124- inline packer<Stream>& operator << (packer<Stream>& o, const unsigned char & v)
181+ inline packer<Stream>& operator << (packer<Stream>& o, unsigned char v)
125182 { o.pack_uint8 (v); return o; }
126183
127184template <typename Stream>
128- inline packer<Stream>& operator << (packer<Stream>& o, const unsigned short & v)
185+ inline packer<Stream>& operator << (packer<Stream>& o, unsigned short v)
129186 { o.pack_unsigned_short (v); return o; }
130187
131188template <typename Stream>
132- inline packer<Stream>& operator << (packer<Stream>& o, const unsigned int & v)
189+ inline packer<Stream>& operator << (packer<Stream>& o, unsigned int v)
133190 { o.pack_unsigned_int (v); return o; }
134191
135192template <typename Stream>
136- inline packer<Stream>& operator << (packer<Stream>& o, const unsigned long & v)
193+ inline packer<Stream>& operator << (packer<Stream>& o, unsigned long v)
137194 { o.pack_unsigned_long (v); return o; }
138195
139196template <typename Stream>
140- inline packer<Stream>& operator << (packer<Stream>& o, const unsigned long long & v)
197+ inline packer<Stream>& operator << (packer<Stream>& o, unsigned long long v)
141198 { o.pack_unsigned_long_long (v); return o; }
142199
143200
201+ inline void operator << (object& o, char v)
202+ { type::detail::object_char (o, v); }
203+
204+
144205inline void operator << (object& o, signed char v)
145206 { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via .i64 = v : o.type = type::POSITIVE_INTEGER, o.via .u64 = v; }
146207
@@ -173,6 +234,10 @@ inline void operator<< (object& o, unsigned long long v)
173234 { o.type = type::POSITIVE_INTEGER, o.via .u64 = v; }
174235
175236
237+ inline void operator << (object::with_zone& o, char v)
238+ { static_cast <object&>(o) << v; }
239+
240+
176241inline void operator << (object::with_zone& o, signed char v)
177242 { static_cast <object&>(o) << v; }
178243
@@ -185,7 +250,7 @@ inline void operator<< (object::with_zone& o, signed int v)
185250inline void operator << (object::with_zone& o, signed long v)
186251 { static_cast <object&>(o) << v; }
187252
188- inline void operator << (object::with_zone& o, signed long long v)
253+ inline void operator << (object::with_zone& o, const signed long long & v)
189254 { static_cast <object&>(o) << v; }
190255
191256
@@ -201,7 +266,7 @@ inline void operator<< (object::with_zone& o, unsigned int v)
201266inline void operator << (object::with_zone& o, unsigned long v)
202267 { static_cast <object&>(o) << v; }
203268
204- inline void operator << (object::with_zone& o, unsigned long long v)
269+ inline void operator << (object::with_zone& o, const unsigned long long & v)
205270 { static_cast <object&>(o) << v; }
206271
207272
0 commit comments