public static CppCheckError Parse(XmlReader reader, CppCheckStrings strings)
{
if (!reader.IsStartElement(strings.Error))
{
throw reader.CreateException(ConverterResources.CppCheckElementNotError);
}
string id = null;
string message = null;
string verboseMessage = null;
string severity = null;
while (reader.MoveToNextAttribute())
{
string attributeName = reader.LocalName;
if (Ref.Equal(attributeName, strings.Id))
{
id = reader.Value;
}
else if (Ref.Equal(attributeName, strings.Msg))
{
message = reader.Value;
}
else if (Ref.Equal(attributeName, strings.Verbose))
{
verboseMessage = reader.Value;
}
else if (Ref.Equal(attributeName, strings.Severity))
{
severity = reader.Value;
}
}
reader.MoveToElement();
ImmutableArray<CppCheckLocation> locations = ParseLocationsSubtree(reader, strings);
reader.Read(); // Consumes the end element or self closing element and positions the reader on the next node
try
{
return new CppCheckError(
id,
message,
verboseMessage,
severity,
locations
);
}
catch (ArgumentException ex)
{
throw reader.CreateException(ex.Message);
}
}