Skip to content

Commit c235caa

Browse files
committed
clang-tidy: use auto
Found with modernize-use-auto Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent 44ae82b commit c235caa

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

examples/dom_parser/main.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
6565
else if(nodeContent)
6666
{
6767
std::cout << indent << "content = " << nodeContent->get_content() << std::endl;
68-
}
69-
else if(const xmlpp::Element* nodeElement = dynamic_cast<const xmlpp::Element*>(node))
70-
{
68+
} else if (const auto nodeElement =
69+
dynamic_cast<const xmlpp::Element *>(node)) {
7170
//A normal Element node:
7271

7372
//line() works only for ElementNodes.

examples/dom_xinclude/main.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
6464
else if (nodeContent)
6565
{
6666
std::cout << indent << "content = " << nodeContent->get_content() << std::endl;
67-
}
68-
else if (const xmlpp::Element* nodeElement = dynamic_cast<const xmlpp::Element*>(node))
69-
{
67+
} else if (const auto nodeElement =
68+
dynamic_cast<const xmlpp::Element *>(node)) {
7069
//A normal Element node:
7170
std::cout << indent << " Element line = " << node->get_line() << std::endl;
7271

@@ -86,13 +85,9 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
8685
{
8786
std::cout << indent << "title = " << attribute->get_value() << std::endl;
8887
}
89-
}
90-
else if (dynamic_cast<const xmlpp::XIncludeStart*>(node))
91-
{
88+
} else if (dynamic_cast<const xmlpp::XIncludeStart *>(node)) {
9289
std::cout << indent << " " << "XIncludeStart line = " << node->get_line() << std::endl;
93-
}
94-
else if (dynamic_cast<const xmlpp::XIncludeEnd*>(node))
95-
{
90+
} else if (dynamic_cast<const xmlpp::XIncludeEnd *>(node)) {
9691
std::cout << indent << " " << "XIncludeEnd" << std::endl;
9792
}
9893

libxml++/nodes/node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ ustring Node::get_namespace_prefix() const
463463
else if (impl_->type == XML_ATTRIBUTE_DECL)
464464
{
465465
//impl_ is actually of type xmlAttribute, instead of just xmlNode.
466-
const xmlAttribute* const attr = reinterpret_cast<const xmlAttribute*>(impl_);
466+
const auto attr = reinterpret_cast<const xmlAttribute *>(impl_);
467467
return attr->prefix ? (const char*)attr->prefix : "";
468468
}
469469
else if(impl_->ns && impl_->ns->prefix)

libxml++/parsers/domparser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ namespace {
180180
char * buffer,
181181
int len)
182182
{
183-
std::istream *in = static_cast<std::istream*>(context);
183+
auto in = static_cast<std::istream *>(context);
184184
in->read(buffer, len);
185185
return in->gcount();
186186
}

libxml++/parsers/saxparser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ namespace {
215215
char * buffer,
216216
int len)
217217
{
218-
std::istream *in = static_cast<std::istream*>(context);
218+
auto in = static_cast<std::istream *>(context);
219219
in->read(buffer, len);
220220
return in->gcount();
221221
}

libxml++/validators/dtdvalidator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ void DtdValidator::validate(const Document* document)
164164
xmlResetLastError();
165165
initialize_context();
166166

167-
const bool res = (bool)xmlValidateDtd(pimpl_->context, (xmlDoc*)document->cobj(),
168-
pimpl_->dtd->cobj());
167+
const auto res = (bool)xmlValidateDtd(
168+
pimpl_->context, (xmlDoc *)document->cobj(), pimpl_->dtd->cobj());
169169

170170
if (!res)
171171
{

0 commit comments

Comments
 (0)