mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Add msgpack reflection for Point/Range
This commit is contained in:
parent
34aac56ff0
commit
ed880f50dd
@ -148,26 +148,54 @@ bool Range::operator<(const Range& that) const {
|
||||
void Reflect(Reader& visitor, Position& value) {
|
||||
if (!visitor.IsString())
|
||||
value = Position();
|
||||
else {
|
||||
else if (visitor.Format() == SerializeFormat::Json) {
|
||||
std::string s = visitor.GetString();
|
||||
value = Position(s.c_str());
|
||||
} else {
|
||||
REFLECT_MEMBER_START(2);
|
||||
Reflect(visitor, value.line);
|
||||
Reflect(visitor, value.column);
|
||||
REFLECT_MEMBER_END();
|
||||
}
|
||||
}
|
||||
void Reflect(Writer& visitor, Position& value) {
|
||||
std::string output = value.ToString();
|
||||
visitor.String(output.c_str(), output.size());
|
||||
if (visitor.Format() == SerializeFormat::Json) {
|
||||
std::string output = value.ToString();
|
||||
visitor.String(output.c_str(), output.size());
|
||||
} else {
|
||||
REFLECT_MEMBER_START(2);
|
||||
Reflect(visitor, value.line);
|
||||
Reflect(visitor, value.column);
|
||||
REFLECT_MEMBER_END();
|
||||
}
|
||||
}
|
||||
|
||||
// Range
|
||||
void Reflect(Reader& visitor, Range& value) {
|
||||
if (!visitor.IsString())
|
||||
value = Range();
|
||||
else {
|
||||
else if (visitor.Format() == SerializeFormat::Json) {
|
||||
std::string s = visitor.GetString();
|
||||
value = Range(s.c_str());
|
||||
} else {
|
||||
REFLECT_MEMBER_START(4);
|
||||
Reflect(visitor, value.start.line);
|
||||
Reflect(visitor, value.start.column);
|
||||
Reflect(visitor, value.end.line);
|
||||
Reflect(visitor, value.end.column);
|
||||
REFLECT_MEMBER_END();
|
||||
}
|
||||
}
|
||||
void Reflect(Writer& visitor, Range& value) {
|
||||
std::string output = value.ToString();
|
||||
visitor.String(output.c_str(), output.size());
|
||||
if (visitor.Format() == SerializeFormat::Json) {
|
||||
std::string output = value.ToString();
|
||||
visitor.String(output.c_str(), output.size());
|
||||
} else {
|
||||
REFLECT_MEMBER_START(4);
|
||||
Reflect(visitor, value.start.line);
|
||||
Reflect(visitor, value.start.column);
|
||||
Reflect(visitor, value.end.line);
|
||||
Reflect(visitor, value.end.column);
|
||||
REFLECT_MEMBER_END();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user