@@ -471,7 +471,7 @@ namespace json
471
471
// / Throws <see cref="json_exception"/> if the value is not a number
472
472
// / </summary>
473
473
// / <returns>An instance of number class</returns>
474
- _ASYNCRTIMP json::number as_number () const ;
474
+ _ASYNCRTIMP const json::number& as_number () const ;
475
475
476
476
// / <summary>
477
477
// / Converts the JSON value to a C++ bool, if and only if it is a Boolean value.
@@ -509,7 +509,7 @@ namespace json
509
509
// / Converts the JSON value to a C++ STL string, if and only if it is a string value.
510
510
// / </summary>
511
511
// / <returns>A C++ STL string representation of the value</returns>
512
- _ASYNCRTIMP utility::string_t as_string () const ;
512
+ _ASYNCRTIMP const utility::string_t & as_string () const ;
513
513
514
514
// / <summary>
515
515
// / Compares two JSON values for equality.
@@ -644,15 +644,13 @@ namespace json
644
644
private:
645
645
std::string _message;
646
646
public:
647
- json_exception () {}
648
647
json_exception (const utility::char_t * const &message) : _message(utility::conversions::to_utf8string(message)) { }
649
648
650
649
// Must be narrow string because it derives from std::exception
651
650
const char * what () const CPPREST_NOEXCEPT
652
651
{
653
652
return _message.c_str ();
654
653
}
655
- ~json_exception () CPPREST_NOEXCEPT {}
656
654
};
657
655
658
656
namespace details
@@ -1386,15 +1384,15 @@ namespace json
1386
1384
virtual bool is_integer () const { throw json_exception (_XPLATSTR (" not a number" )); }
1387
1385
virtual bool is_double () const { throw json_exception (_XPLATSTR (" not a number" )); }
1388
1386
1389
- virtual json::number as_number () { throw json_exception (_XPLATSTR (" not a number" )); }
1387
+ virtual const json::number& as_number () { throw json_exception (_XPLATSTR (" not a number" )); }
1390
1388
virtual double as_double () const { throw json_exception (_XPLATSTR (" not a number" )); }
1391
1389
virtual int as_integer () const { throw json_exception (_XPLATSTR (" not a number" )); }
1392
1390
virtual bool as_bool () const { throw json_exception (_XPLATSTR (" not a boolean" )); }
1393
1391
virtual json::array& as_array () { throw json_exception (_XPLATSTR (" not an array" )); }
1394
1392
virtual const json::array& as_array () const { throw json_exception (_XPLATSTR (" not an array" )); }
1395
1393
virtual json::object& as_object () { throw json_exception (_XPLATSTR (" not an object" )); }
1396
1394
virtual const json::object& as_object () const { throw json_exception (_XPLATSTR (" not an object" )); }
1397
- virtual utility::string_t as_string () const { throw json_exception (_XPLATSTR (" not a string" )); }
1395
+ virtual const utility::string_t & as_string () const { throw json_exception (_XPLATSTR (" not a string" )); }
1398
1396
1399
1397
virtual size_t size () const { return 0 ; }
1400
1398
@@ -1464,7 +1462,7 @@ namespace json
1464
1462
return m_number.to_int32 ();
1465
1463
}
1466
1464
1467
- virtual number as_number () { return m_number; }
1465
+ virtual const number& as_number () { return m_number; }
1468
1466
1469
1467
protected:
1470
1468
virtual void format (std::basic_string<char >& stream) const ;
@@ -1554,7 +1552,7 @@ namespace json
1554
1552
1555
1553
virtual json::value::value_type type () const { return json::value::String; }
1556
1554
1557
- virtual utility::string_t as_string () const ;
1555
+ virtual const utility::string_t & as_string () const ;
1558
1556
1559
1557
virtual void serialize_impl (std::string& str) const
1560
1558
{
0 commit comments