fisherro / cpplibxml2

Experimenting with libxml2 & std::unique_ptr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Experiments in another C++ wrapper for libxml2

The biggest issue I've seen with the use of libxml2 in a large project is memory management. It isn't always clear to programmers when a libxml2 pointer should be freed directly and when it will be freed implicitly when freeing an owning structure.

With modern C++, smart pointers not only make ownership clear, they also handle freeing resources automatically.

So, the primary goal here is to create an API where all pointers that should be freed by the application programmer are returned via std::unique_ptr.

Guiding principles (subject to change)

  • Any pointers returned that should be freed by the caller will be returned as a std::unique_ptr with the proper deleter.
  • When it makes sense, provide functions that return collections or operate on collections.
  • Functions that take callback parameters should be provided to capture common patterns.
  • This library intends to follow the standard library naming conventions, so the names from libxml2 will be converted from camelCase to snake_case.
  • The "xml" prefix on identifiers will be dropped in favor of a namespace.
  • Other elements of a function's name should be dropped when overloading makes them unnecessary

About

Experimenting with libxml2 & std::unique_ptr


Languages

Language:C++ 98.3%Language:Makefile 1.7%