SL-18330: Adapt LLSDSerialize and tests to llssize max_bytes params.
parent
761d8337fb
commit
590e158cf3
|
|
@ -128,7 +128,7 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, S32 max_bytes)
|
|||
* specified buffer. In the usual case when max_bytes exceeds
|
||||
* sizeof(hdr_buf), get() will read no more than sizeof(hdr_buf)-2.
|
||||
*/
|
||||
str.get(hdr_buf, std::min(max_bytes+1, sizeof(hdr_buf)-1), '\n');
|
||||
str.get(hdr_buf, llmin(max_bytes+1, sizeof(hdr_buf)-1), '\n');
|
||||
auto inbuf = str.gcount();
|
||||
// https://en.cppreference.com/w/cpp/io/basic_istream/get
|
||||
// When the get() above sees the specified delimiter '\n', it stops there
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ using namespace boost::phoenix;
|
|||
#include <functional>
|
||||
|
||||
typedef std::function<void(const LLSD& data, std::ostream& str)> FormatterFunction;
|
||||
typedef std::function<bool(std::istream& istr, LLSD& data, size_t max_bytes)> ParserFunction;
|
||||
typedef std::function<bool(std::istream& istr, LLSD& data, llssize max_bytes)> ParserFunction;
|
||||
|
||||
std::vector<U8> string_to_vector(const std::string& str)
|
||||
{
|
||||
|
|
@ -263,7 +263,7 @@ namespace tut
|
|||
};
|
||||
// this lambda must be mutable since otherwise the bound 'parser'
|
||||
// is assumed to point to a const LLSDParser
|
||||
mParser = [parser](std::istream& istr, LLSD& data, size_t max_bytes) mutable
|
||||
mParser = [parser](std::istream& istr, LLSD& data, llssize max_bytes) mutable
|
||||
{
|
||||
// reset() call is needed since test code re-uses parser object
|
||||
parser->reset();
|
||||
|
|
@ -271,10 +271,10 @@ namespace tut
|
|||
};
|
||||
}
|
||||
|
||||
void setParser(bool (*parser)(LLSD&, std::istream&, size_t))
|
||||
void setParser(bool (*parser)(LLSD&, std::istream&, llssize))
|
||||
{
|
||||
// why does LLSDSerialize::deserialize() reverse the parse() params??
|
||||
mParser = [parser](std::istream& istr, LLSD& data, size_t max_bytes)
|
||||
mParser = [parser](std::istream& istr, LLSD& data, llssize max_bytes)
|
||||
{
|
||||
return (parser(data, istr, max_bytes) > 0);
|
||||
};
|
||||
|
|
@ -2059,7 +2059,7 @@ namespace tut
|
|||
// helper for test<8> - test<12>
|
||||
void fromPythonUsing(const std::string& pyformatter,
|
||||
const ParserFunction& parse=
|
||||
[](std::istream& istr, LLSD& data, size_t max_bytes)
|
||||
[](std::istream& istr, LLSD& data, llssize max_bytes)
|
||||
{ return LLSDSerialize::deserialize(data, istr, max_bytes); })
|
||||
{
|
||||
// Create an empty data file. This is just a placeholder for our
|
||||
|
|
@ -2140,7 +2140,7 @@ namespace tut
|
|||
set_test_name("from Python XML using fromXML()");
|
||||
// fromXML()'s optional 3rd param isn't max_bytes, it's emit_errors
|
||||
fromPythonUsing("format_xml",
|
||||
[](std::istream& istr, LLSD& data, size_t)
|
||||
[](std::istream& istr, LLSD& data, llssize)
|
||||
{ return LLSDSerialize::fromXML(data, istr) > 0; });
|
||||
}
|
||||
|
||||
|
|
@ -2149,7 +2149,7 @@ namespace tut
|
|||
{
|
||||
set_test_name("from Python notation using fromNotation()");
|
||||
fromPythonUsing("format_notation",
|
||||
[](std::istream& istr, LLSD& data, size_t max_bytes)
|
||||
[](std::istream& istr, LLSD& data, llssize max_bytes)
|
||||
{ return LLSDSerialize::fromNotation(data, istr, max_bytes) > 0; });
|
||||
}
|
||||
|
||||
|
|
@ -2161,7 +2161,7 @@ namespace tut
|
|||
// We don't expect this to work because format_binary() emits a
|
||||
// header, but fromBinary() won't recognize a header.
|
||||
fromPythonUsing("format_binary",
|
||||
[](std::istream& istr, LLSD& data, size_t max_bytes)
|
||||
[](std::istream& istr, LLSD& data, llssize max_bytes)
|
||||
{ return LLSDSerialize::fromBinary(data, istr, max_bytes) > 0; });
|
||||
}
|
||||
|*==========================================================================*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue