Commit 3398b888 authored by Murray Cumming's avatar Murray Cumming

C++11: Use auto.

parent d51cb2b4
......@@ -44,11 +44,11 @@ main(int /* argc */, char** /* argv */)
document.add_comment("First comment");
//foo is the default namespace prefix.
xmlpp::Element* nodeRoot = document.create_root_node("exampleroot", "http://foo", "foo"); //Declares the namespace and uses its prefix for this node
auto nodeRoot = document.create_root_node("exampleroot", "http://foo", "foo"); //Declares the namespace and uses its prefix for this node
nodeRoot->set_namespace_declaration("http://foobar", "foobar"); //Also associate this prefix with this namespace:
nodeRoot->set_child_text("\n");
xmlpp::Element* nodeChild = nodeRoot->add_child("examplechild");
auto nodeChild = nodeRoot->add_child("examplechild");
//Associate prefix with namespace:
nodeChild->set_namespace_declaration("http://bar", "bar");
......@@ -67,7 +67,7 @@ main(int /* argc */, char** /* argv */)
nodeChild = nodeRoot->add_child("examplechild", "foobar"); //foobar is the namespace prefix
nodeChild->set_attribute("id", "2", "foobar"); //foobar is the namespace prefix.
Glib::ustring whole = document.write_to_string();
auto whole = document.write_to_string();
std::cout << "XML built at runtime: " << std::endl << whole << std::endl;
std::cout << "namespace of root node: " << nodeRoot->get_namespace_uri() << std::endl;
}
......
......@@ -35,7 +35,7 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int
if (substitute_entities)
{
// Entities have been substituted. Print the text nodes.
const xmlpp::TextNode* nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
const auto nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
if (nodeText && !nodeText->is_white_space())
{
std::cout << indent << "text = " << CatchConvertError(nodeText->get_content()) << std::endl;
......@@ -44,7 +44,7 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int
else
{
// Entities have not been substituted. Print the entity reference nodes.
const xmlpp::EntityReference* nodeEntityReference = dynamic_cast<const xmlpp::EntityReference*>(node);
const auto nodeEntityReference = dynamic_cast<const xmlpp::EntityReference*>(node);
if (nodeEntityReference)
{
std::cout << indent << "entity reference name = " << CatchConvertError(nodeEntityReference->get_name()) << std::endl;
......@@ -53,11 +53,11 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int
}
} // end if (substitute_entities)
const xmlpp::ContentNode* nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
const auto nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
if(!nodeContent)
{
//Recurse through child nodes:
xmlpp::Node::NodeList list = node->get_children();
auto list = node->get_children();
for(xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
print_node(*iter, substitute_entities, indentation + 2); //recursive
......@@ -106,7 +106,7 @@ int main(int argc, char* argv[])
if(parser)
{
//Walk the tree:
const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
const auto pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode, substitute_entities);
}
}
......
......@@ -33,18 +33,18 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
const Glib::ustring indent(indentation, ' ');
std::cout << std::endl; //Separate nodes by an empty line.
const xmlpp::ContentNode* nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
const xmlpp::TextNode* nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
const xmlpp::CommentNode* nodeComment = dynamic_cast<const xmlpp::CommentNode*>(node);
const auto nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
const auto nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
const auto nodeComment = dynamic_cast<const xmlpp::CommentNode*>(node);
if(nodeText && nodeText->is_white_space()) //Let's ignore the indenting - you don't always want to do this.
return;
const Glib::ustring nodename = node->get_name();
const auto nodename = node->get_name();
if(!nodeText && !nodeComment && !nodename.empty()) //Let's not say "name: text".
{
const Glib::ustring namespace_prefix = node->get_namespace_prefix();
const auto namespace_prefix = node->get_namespace_prefix();
std::cout << indent << "Node name = ";
if(!namespace_prefix.empty())
......@@ -77,11 +77,11 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
std::cout << indent << " line = " << node->get_line() << std::endl;
//Print attributes:
const xmlpp::Element::AttributeList& attributes = nodeElement->get_attributes();
const auto attributes = nodeElement->get_attributes();
for(xmlpp::Element::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
{
const xmlpp::Attribute* attribute = *iter;
const Glib::ustring namespace_prefix = attribute->get_namespace_prefix();
const auto attribute = *iter;
const auto namespace_prefix = attribute->get_namespace_prefix();
std::cout << indent << " Attribute ";
if(!namespace_prefix.empty())
......@@ -90,7 +90,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
<< CatchConvertError(attribute->get_value()) << std::endl;
}
const xmlpp::Attribute* attribute = nodeElement->get_attribute("title");
const auto attribute = nodeElement->get_attribute("title");
if(attribute)
{
std::cout << indent;
......@@ -105,7 +105,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
if(!nodeContent)
{
//Recurse through child nodes:
xmlpp::Node::NodeList list = node->get_children();
auto list = node->get_children();
for(xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
print_node(*iter, indentation + 2); //recursive
......@@ -178,7 +178,7 @@ int main(int argc, char* argv[])
if(parser)
{
//Walk the tree:
const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
const auto pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode);
}
}
......
......@@ -33,7 +33,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
std::cout << "Node name = " << node->get_name() << std::endl;
//Recurse through child nodes:
xmlpp::Node::NodeList list = node->get_children();
auto list = node->get_children();
for(xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
print_node(*iter, indentation + 2); //recursive
......@@ -49,7 +49,7 @@ std::string read_from_disk(const std::string& filepath)
{
while(!(fStream.eof()))
{
char chTemp = fStream.get();
auto chTemp = fStream.get();
if(!(fStream.eof()))
result += chTemp;
}
......@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically.
std::string contents = read_from_disk(filepath);
auto contents = read_from_disk(filepath);
std::string contents_ucs2;
try
......@@ -103,7 +103,7 @@ int main(int argc, char* argv[])
if(parser)
{
//Walk the tree:
const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
const auto pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode);
}
}
......
......@@ -60,7 +60,7 @@ main(int argc, char* argv[])
if(parser)
{
//Write it out again.
xmlpp::Document* document = parser.get_document();
auto document = parser.get_document();
if(document)
document->write_to_file(filepath_out);
}
......@@ -72,7 +72,7 @@ main(int argc, char* argv[])
if(parser)
{
//Write it out again.
xmlpp::Document* document = parser.get_document();
auto document = parser.get_document();
if(document)
document->write_to_file(filepath_out2);
}
......
......@@ -84,13 +84,13 @@ void TestNamespace::setup(const std::string& filename)
parser_.set_substitute_entities(true);
parser_.parse_file(filename);
xmlpp::Document* document = parser_.get_document();
auto document = parser_.get_document();
root_ = document->get_root_node();
}
void TestNamespace::test_create_new_node_with_default_namespace()
{
const Glib::ustring filename = "example1.xml";
const auto filename = "example1.xml";
setup(filename);
// Check original document
......@@ -100,7 +100,7 @@ void TestNamespace::test_create_new_node_with_default_namespace()
"Input file shouldn't have any child in alternate default namespace");
// Add child nodes in default namespace and check document again
xmlpp::Element* child = root_->add_child("child");
auto child = root_->add_child("child");
child->set_namespace_declaration(nsmap_["ns1"], "");
root_->add_child_text("\n");
root_->add_child_with_new_ns("child", nsmap_["ns1"]);
......@@ -118,7 +118,7 @@ void TestNamespace::test_create_new_node_with_default_namespace()
void TestNamespace::test_create_new_node_using_existing_namespace_prefix()
{
const Glib::ustring filename = "example2.xml";
const auto filename = "example2.xml";
setup(filename);
// Check original document
......@@ -128,7 +128,7 @@ void TestNamespace::test_create_new_node_using_existing_namespace_prefix()
"Input file shouldn't have any child in child namespace");
// Add child nodes with specific namespace and check document again
xmlpp::Element* child = root_->add_child("child", "ns0");
auto child = root_->add_child("child", "ns0");
child->set_namespace_declaration(nsmap_["ns1"], "");
root_->add_child_text("\n");
root_->add_child_with_new_ns("child", nsmap_["ns1"]);
......
......@@ -28,19 +28,19 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
{
const Glib::ustring indent(indentation, ' ');
const xmlpp::ContentNode* nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
const xmlpp::TextNode* nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
const xmlpp::CommentNode* nodeComment = dynamic_cast<const xmlpp::CommentNode*>(node);
const auto nodeContent = dynamic_cast<const xmlpp::ContentNode*>(node);
const auto nodeText = dynamic_cast<const xmlpp::TextNode*>(node);
const auto nodeComment = dynamic_cast<const xmlpp::CommentNode*>(node);
//Let's ignore the indenting - you don't always want to do this.
if (nodeText && nodeText->is_white_space())
return;
const Glib::ustring nodename = node->get_name();
const auto nodename = node->get_name();
if (!nodeText && !nodeComment && !nodename.empty()) //Let's not say "name: text".
{
const Glib::ustring namespace_prefix = node->get_namespace_prefix();
const auto namespace_prefix = node->get_namespace_prefix();
std::cout << indent << "Node name = ";
if (!namespace_prefix.empty())
......@@ -71,11 +71,11 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
std::cout << indent << " Element line = " << node->get_line() << std::endl;
//Print attributes:
const xmlpp::Element::AttributeList attributes = nodeElement->get_attributes();
const auto attributes = nodeElement->get_attributes();
for (xmlpp::Element::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
{
const xmlpp::Attribute* attribute = *iter;
const Glib::ustring namespace_prefix = attribute->get_namespace_prefix();
const auto attribute = *iter;
const auto namespace_prefix = attribute->get_namespace_prefix();
std::cout << indent << " Attribute ";
if (!namespace_prefix.empty())
......@@ -83,7 +83,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
std::cout << attribute->get_name() << " = " << attribute->get_value() << std::endl;
}
const xmlpp::Attribute* attribute = nodeElement->get_attribute("title");
const auto attribute = nodeElement->get_attribute("title");
if (attribute)
{
std::cout << indent << "title = " << attribute->get_value() << std::endl;
......@@ -101,7 +101,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
if (!nodeContent)
{
//Recurse through child nodes:
xmlpp::Node::NodeList list = node->get_children();
auto list = node->get_children();
for (xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
print_node(*iter, indentation + 2); //recursive
......@@ -173,7 +173,7 @@ int main(int argc, char* argv[])
if (parser)
{
//Walk the tree:
xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
auto pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode);
std::cout << std::endl << ">>>>> Number of XInclude substitutions: "
......@@ -182,7 +182,7 @@ int main(int argc, char* argv[])
pNode = parser.get_document()->get_root_node();
print_node(pNode);
const Glib::ustring whole = parser.get_document()->write_to_string();
const auto whole = parser.get_document()->write_to_string();
std::cout << std::endl << ">>>>> XML after XInclude processing: " << std::endl
<< whole << std::endl;
}
......
......@@ -50,7 +50,7 @@ bool xpath_test(const xmlpp::Node* node, const Glib::ustring& xpath)
try
{
xmlpp::NodeSet set = node->find(xpath);
auto set = node->find(xpath);
std::cout << set.size() << " nodes have been found:" << std::endl;
......@@ -59,22 +59,22 @@ bool xpath_test(const xmlpp::Node* node, const Glib::ustring& xpath)
{
std::cout << " " << (*i)->get_path();
xmlpp::Attribute* attribute = dynamic_cast<xmlpp::Attribute*>(*i);
auto attribute = dynamic_cast<xmlpp::Attribute*>(*i);
if (attribute)
std::cout << ", value=\"" << attribute->get_value() << "\"";
xmlpp::ContentNode* content_node = dynamic_cast<xmlpp::ContentNode*>(*i);
auto content_node = dynamic_cast<xmlpp::ContentNode*>(*i);
if (content_node)
std::cout << ", content=\"" << content_node->get_content() << "\"";
xmlpp::EntityReference* entity_reference = dynamic_cast<xmlpp::EntityReference*>(*i);
auto entity_reference = dynamic_cast<xmlpp::EntityReference*>(*i);
if (entity_reference)
std::cout << ", text=\"" << entity_reference->get_original_text() << "\"";
xmlpp::Element* element = dynamic_cast<xmlpp::Element*>(*i);
auto element = dynamic_cast<xmlpp::Element*>(*i);
if (element)
{
xmlpp::TextNode* text_node = element->get_child_text();
auto text_node = element->get_child_text();
if (text_node)
std::cout << ", child_text=\"" << text_node->get_content() << "\"";
}
......@@ -121,7 +121,7 @@ int main(int argc, char* argv[])
xmlpp::DomParser parser(filepath);
if(parser)
{
const xmlpp::Node* root = parser.get_document()->get_root_node(); //deleted by DomParser.
const auto root = parser.get_document()->get_root_node(); //deleted by DomParser.
if(root)
{
......
......@@ -42,7 +42,7 @@ int main(int argc, char* argv[])
int return_code = EXIT_SUCCESS;
xmlpp::Document document;
/* xmlpp::Element* nodeRoot = */document.create_root_node("incorrect");
/* auto nodeRoot = */document.create_root_node("incorrect");
try
{
......@@ -60,8 +60,8 @@ int main(int argc, char* argv[])
std::cout << ex.what() << std::endl;
}
/* xmlpp::Element* nodeRoot2 = */document.create_root_node("example");
xmlpp::Element * child = document.get_root_node()->add_child("examplechild");
/* auto nodeRoot2 = */document.create_root_node("example");
auto child = document.get_root_node()->add_child("examplechild");
child->set_attribute("id", "an_id");
child->add_child("child_of_child");
......
......@@ -18,21 +18,21 @@ int main (int /* argc */, char** /* argv */)
DomParser example1("example1.xml");
DomParser example2("example2.xml");
Document* doc1 = example1.get_document();
Document* doc2 = example2.get_document();
auto doc1 = example1.get_document();
auto doc2 = example2.get_document();
Element* root1 = doc1->get_root_node();
Element* root2 = doc2->get_root_node();
auto root1 = doc1->get_root_node();
auto root2 = doc2->get_root_node();
// find the first "child" element in example2
Node::NodeList child_list2 = root2->get_children("child");
Node* node_to_add = child_list2.front();
auto child_list2 = root2->get_children("child");
auto node_to_add = child_list2.front();
// import the node under the root element (recursive is default)
root1->import_node(node_to_add);
// Import an attribute that will replace an existing attribute in the root element.
Attribute* attribute_to_add = root2->get_attribute("name");
auto attribute_to_add = root2->get_attribute("name");
root1->import_node(attribute_to_add);
// Import an attribute that will be added to the root element.
......@@ -40,21 +40,21 @@ int main (int /* argc */, char** /* argv */)
root1->import_node(attribute_to_add);
// Find the first text child of the first "child" element in example2.
Element* first_child2 = dynamic_cast<Element*>(child_list2.front());
auto first_child2 = dynamic_cast<Element*>(child_list2.front());
if (!first_child2)
{
cerr << "first_child2 == nullptr" << endl;
return EXIT_FAILURE;
}
TextNode* text_to_add = first_child2->get_child_text();
auto text_to_add = first_child2->get_child_text();
// Import the text under the first "child" element in example1.
// Adjacent text nodes are merged.
Node* first_child1 = root1->get_first_child("child");
auto first_child1 = root1->get_first_child("child");
first_child1->import_node(text_to_add);
// print out the new doc1
string doc1_string = doc1->write_to_string_formatted();
auto doc1_string = doc1->write_to_string_formatted();
cout << doc1_string;
}
catch (std::exception& ex)
......
......@@ -44,7 +44,7 @@ main(int argc, char* argv[])
filepath = "example.xml";
// Parse the entire document in one go:
int return_code = EXIT_SUCCESS;
auto return_code = EXIT_SUCCESS;
try
{
MySaxParser parser;
......
......@@ -60,12 +60,12 @@ main(int argc, char* argv[])
std::cout << doc.write_to_string_formatted() << std::endl;
// Use the custom DOM
SVG::Element* element = doc.get_root();
auto element = doc.get_root();
std::cout << "root's name is \"" << element->get_name() << "\"" << std::endl;
xmlpp::NodeSet nl = element->find("//path[@style != '']");
auto nl = element->find("//path[@style != '']");
if(!nl.empty())
{
SVG::Path* path = dynamic_cast<SVG::Path*>(nl[0]);
auto path = dynamic_cast<SVG::Path*>(nl[0]);
std::cout << "style of first path node with a style = \"" << path->get_style() << "\"" << std::endl;
}
}
......
......@@ -78,7 +78,7 @@ void Parser::on_start_element(const Glib::ustring& name,
//
// Delete the xmlpp::Element created above so we can link the libxml2
// node with the derived Element object we create below.
xmlNode* node = element_normal->cobj(); //Save it for later.
auto node = element_normal->cobj(); //Save it for later.
delete element_normal;
element_normal = nullptr;
......@@ -108,8 +108,8 @@ void Parser::on_start_element(const Glib::ustring& name,
// In theory, you could change the attributes here.
for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
{
Glib::ustring name = (*iter).name;
Glib::ustring value = (*iter).value;
auto name = (*iter).name;
auto value = (*iter).value;
Glib::ustring::size_type idx = name.find(':');
if (idx == Glib::ustring::npos) // If the separator was not found.
{
......@@ -127,15 +127,15 @@ void Parser::on_start_element(const Glib::ustring& name,
else
{
//The separator was found:
Glib::ustring prefix = name.substr(0, idx);
Glib::ustring suffix = name.substr(idx + 1);
auto prefix = name.substr(0, idx);
auto suffix = name.substr(idx + 1);
if (prefix == "xmlns") // This is a namespace declaration.
element_derived->set_namespace_declaration(value, suffix);
else
{
//This is a namespaced attribute value.
//(The namespace must have been declared already)
xmlpp::Attribute* attr = element_derived->set_attribute(suffix, value);
auto attr = element_derived->set_attribute(suffix, value);
attr->set_namespace(prefix); //alternatively, we could have specified the whole name to set_attribute().
}
}
......
......@@ -111,7 +111,7 @@ void remove_found_wrappers(xmlNode* node, NodeMap& node_map)
if (node->_private)
{
const NodeMap::iterator iter =
const auto iter =
node_map.find(static_cast<xmlpp::Node*>(node->_private));
if (iter != node_map.end())
{
......@@ -200,7 +200,7 @@ Glib::ustring Document::get_encoding() const
Dtd* Document::get_internal_subset() const
{
xmlDtd* dtd = xmlGetIntSubset(impl_);
auto dtd = xmlGetIntSubset(impl_);
if(!dtd)
return 0;
......@@ -214,7 +214,7 @@ void Document::set_internal_subset(const Glib::ustring& name,
const Glib::ustring& external_id,
const Glib::ustring& system_id)
{
xmlDtd* dtd = xmlCreateIntSubset(impl_,
auto dtd = xmlCreateIntSubset(impl_,
(const xmlChar*)name.c_str(),
external_id.empty() ? (const xmlChar*)0 : (const xmlChar*)external_id.c_str(),
system_id.empty() ? (const xmlChar*)0 : (const xmlChar*)system_id.c_str());
......@@ -225,7 +225,7 @@ void Document::set_internal_subset(const Glib::ustring& name,
Element* Document::get_root_node() const
{
xmlNode* root = xmlDocGetRootElement(impl_);
auto root = xmlDocGetRootElement(impl_);
if(root == nullptr)
return 0;
else
......@@ -239,7 +239,7 @@ Element* Document::create_root_node(const Glib::ustring& name,
const Glib::ustring& ns_uri,
const Glib::ustring& ns_prefix)
{
xmlNode* node = xmlNewDocNode(impl_, 0, (const xmlChar*)name.c_str(), 0);
auto node = xmlNewDocNode(impl_, 0, (const xmlChar*)name.c_str(), 0);
if (!node)
throw internal_error("Could not create root element node " + name);
......@@ -251,7 +251,7 @@ Element* Document::create_root_node(const Glib::ustring& name,
xmlFreeNode(node);
}
Element* element = get_root_node();
auto element = get_root_node();
if( !ns_uri.empty() && element )
{
......@@ -269,13 +269,13 @@ Element* Document::create_root_node_by_import(const Node* node,
return 0;
//Create the node, by copying:
xmlNode* imported_node = xmlDocCopyNode(const_cast<xmlNode*>(node->cobj()), impl_, recursive);
auto imported_node = xmlDocCopyNode(const_cast<xmlNode*>(node->cobj()), impl_, recursive);
if (!imported_node)
{
throw exception("Unable to copy the node that shall be imported");
}
xmlNode* old_node = xmlDocSetRootElement(impl_, imported_node);
auto old_node = xmlDocSetRootElement(impl_, imported_node);
if (old_node)
{
// An old root element node has been replaced.
......@@ -288,10 +288,10 @@ Element* Document::create_root_node_by_import(const Node* node,
CommentNode* Document::add_comment(const Glib::ustring& content)
{
xmlNode* child = xmlNewComment((const xmlChar*)content.c_str());
auto child = xmlNewComment((const xmlChar*)content.c_str());
// Use the result, because child can be freed when merging text nodes:
xmlNode* node = xmlAddChild((xmlNode*)impl_, child);
auto node = xmlAddChild((xmlNode*)impl_, child);
if (!node)
{
xmlFreeNode(child);
......@@ -304,8 +304,8 @@ CommentNode* Document::add_comment(const Glib::ustring& content)
ProcessingInstructionNode* Document::add_processing_instruction(
const Glib::ustring& name, const Glib::ustring& content)
{
xmlNode* child = xmlNewDocPI(impl_, (const xmlChar*)name.c_str(), (const xmlChar*)content.c_str());
xmlNode* node = xmlAddChild((xmlNode*)impl_, child);
auto child = xmlNewDocPI(impl_, (const xmlChar*)name.c_str(), (const xmlChar*)content.c_str());
auto node = xmlAddChild((xmlNode*)impl_, child);
if (!node)
{
xmlFreeNode(child);
......@@ -411,7 +411,7 @@ void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType t
const Glib::ustring& publicId, const Glib::ustring& systemId,
const Glib::ustring& content)
{
xmlEntity* entity = xmlAddDocEntity( impl_, (const xmlChar*) name.c_str(), type,
auto entity = xmlAddDocEntity( impl_, (const xmlChar*) name.c_str(), type,
publicId.empty() ? (const xmlChar*)0 : (const xmlChar*)publicId.c_str(),
systemId.empty() ? (const xmlChar*)0 : (const xmlChar*)systemId.c_str(),
(const xmlChar*) content.c_str() );
......@@ -423,7 +423,7 @@ int Document::process_xinclude(bool generate_xinclude_nodes)
{
NodeMap node_map;
xmlNode* root = xmlDocGetRootElement(impl_);
auto root = xmlDocGetRootElement(impl_);
find_wrappers(root, node_map);
......
......@@ -89,7 +89,7 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context)
if (!parser_context)
return "Error. xmlpp::format_xml_parser_error() called with parser_context == nullptr\n";
const _xmlError* error = xmlCtxtGetLastError(const_cast<_xmlParserCtxt*>(parser_context));
const auto error = xmlCtxtGetLastError(const_cast<_xmlParserCtxt*>(parser_context));
if (!error)
return ""; // No error
......
......@@ -19,13 +19,13 @@ namespace xmlpp
{
static int on_write(void * context, const char * buffer, int len)
{
OutputBuffer * tmp = static_cast<OutputBuffer*>(context);
auto tmp = static_cast<OutputBuffer*>(context);
return tmp->on_write(buffer, len)?len:-1;
}
static int on_close(void * context)
{
OutputBuffer * tmp = static_cast<OutputBuffer*>(context);
auto tmp = static_cast<OutputBuffer*>(context);
return tmp->on_close()?0:-1;
}
};
......@@ -41,7 +41,7 @@ namespace xmlpp
xmlCharEncodingHandlerPtr handler = nullptr;
if( ! encoding.empty() )
{
xmlCharEncoding enc = xmlParseCharEncoding(encoding.c_str());
auto enc = xmlParseCharEncoding(encoding.c_str());
// TODO we assume that the source will be UTF-8 encoded. Any user of the class
// should pay attention to this.
......
......@@ -20,13 +20,13 @@ namespace xmlpp
{
static int on_read(void * context, char * buffer, int len)
{
ParserInputBuffer * tmp = static_cast<ParserInputBuffer*>(context);
auto tmp = static_cast<ParserInputBuffer*>(context);
return tmp->do_read(buffer, len);
}
static int on_close(void * context)
{
ParserInputBuffer * tmp = static_cast<ParserInputBuffer*>(context);
auto tmp = static_cast<ParserInputBuffer*>(context);
return tmp->do_close();
}
};
......
......@@ -54,7 +54,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name,
// explicitly set attribute (XML_ATTRIBUTE_NODE), or an xmlAttribute*,
// cast to an xmlAttr*, pointing to the declaration of an attribute with a
// default value (XML_ATTRIBUTE_DECL).
xmlAttr* attr = xmlHasNsProp(const_cast<xmlNode*>(cobj()), (const xmlChar*)name.c_str(),
auto attr = xmlHasNsProp(const_cast<xmlNode*>(cobj()), (const xmlChar*)name.c_str(),
ns_uri.empty() ? 0 : (const xmlChar*)ns_uri.c_str());
if (attr)
{
......@@ -67,7 +67,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name,
Glib::ustring Element::get_attribute_value(const Glib::ustring& name, const Glib::ustring& ns_prefix) const
{
const Attribute* attr = get_attribute(name, ns_prefix);
const auto attr = get_attribute(name, ns_prefix);
return attr ? attr->get_value() : Glib::ustring();
}
......@@ -84,7 +84,7 @@ Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring
else
{
//If the namespace exists, then use it:
xmlNs* ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str());
auto ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str());
if (ns)
{
attr = xmlSetNsProp(cobj(), ns, (const xmlChar*)name.c_str(),
......@@ -111,7 +111,7 @@ void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& n
xmlUnsetProp(cobj(), (const xmlChar*)name.c_str());
else
{
xmlNs* ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str());
auto ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str());
if (ns)
xmlUnsetNsProp(cobj(), ns, (const xmlChar*)name.c_str());
}
......@@ -146,7 +146,7 @@ TextNode* Element::get_child_text()
void Element::set_child_text(const Glib::ustring& content)
{
TextNode* node = get_child_text();
auto node = get_child_text();
if(node)
node->set_content(content);
else
......@@ -157,10 +157,10 @@ TextNode* Element::add_child_text(const Glib::ustring& content)
{
if(cobj()->type == XML_ELEMENT_NODE)
{
xmlNode* child = xmlNewText((const xmlChar*)content.c_str());
auto child = xmlNewText((const xmlChar*)content.c_str());
// Use the result, because child can be freed when merging text nodes:
xmlNode* node = xmlAddChild(cobj(), child);
auto node = xmlAddChild(cobj(), child);
if (!node)