mirror of
https://github.com/nlohmann/json.git
synced 2026-10-28 16:55:41 +00:00
Address review: clearer position code and docs
- position_source gets clear(); set_scalar() returns early for new values, switches on node_kind, and uses no local copies; the one position_source per materialize() call is documented - no npos + 1 for containers without a position; a comment on why the end of a container is reported as its closing bracket - less duplication under #if in materialize() and the builder - diagnostic_positions sets npos explicitly - docs: positions of basic_json values after changes, positions in images depend on how the document was parsed, when next is set, and the cost of positions while parsing Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
7 files changed
+221
-138
No files matched your search
@@ -233,7 +233,7 @@ struct diagnostic_positions
|
||||
// (npos: a value without a source position, see materialize() of
|
||||
// json_view)
|
||||
const std::size_t read = lexer->get_chars_read_total();
|
||||
v.start_position = read == std::string::npos ? read : read - 1;
|
||||
v.start_position = read == std::string::npos ? std::string::npos : read - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ struct diagnostic_positions
|
||||
{
|
||||
// a range has both ends or none (exception::diagnostics()
|
||||
// prints only complete ones)
|
||||
v.start_position = v.end_position;
|
||||
v.start_position = std::string::npos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ struct diagnostic_positions
|
||||
if (v.end_position == std::string::npos)
|
||||
{
|
||||
// a value without a source position
|
||||
v.start_position = v.end_position;
|
||||
v.start_position = std::string::npos;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user