libexpatpp 0.1.8
|
A lightweight and modern C/C++ library for building xml parsers.
Currently a work in progress.
libexpatpp can be built with CMake. CMake is able to produce a build environment for most platforms. For the most important IDE exists a generator option which allows to build project files for these systems.
The simplest (and platform independent) way to build the project using cmake is executing the following command:
First command in chain creates the build directory <builddir> and configures the project. Second command does a build of the default target in <builddir>.
Cmake can also be called with predefined options, here for configuring and building a Release build:
The example hello_world contains a complete sample project using libexpatcpp and makes use of Cmake's FetchContent() Command to include, build and link expatpp library(explained more detailed in Approach #1: Use Cmake's FetchContent() Command .
Our "hello_world" project has just one source file, hello_world.cpp
file, and it looks like this:
Running it should output
element p contains this text: Hello World
for the CMake based build we have included a simple CMakeLists.txt:
To get you started quickly, let's take a look at a few ways to get simple Hello World project working.
CMake contains the FetchContent() command to use libraries where a project depends on.
With:
we include the library into the build.
With:
we link our executable against libexpatpp. This approach is used in the helloworld example, you can use the CMakeFile.lst from there as starting point for your project.
You can install libraries by running in libexpatpp directory:
Now, all you have to do to compile your project is c++ helloWorld.cpp -o helloWorld -llibexpatpp
.
If you get error message like cannot open shared object file: No such file or directory
, make sure that your linker includes path where libexpatpp was installed.
If you are using CMake for compilation, we suggest adding libexpatpp as a git submodule with the command
Afterwards, modify your top level CMakeLists.txt file accordingly:
The add_subdirectory
command adds a folder to the build tree, meaning it will run CMakeLists.txt from the included folder as well. Flag EXCLUDE_FROM_ALL
disables building (and instalment) of targets in the added folder which are not needed in your project. In the above example only the (static) library libexpatpp
will be build, while libexpatpp-aligner
, hello_world
and the rest won't. In order to access the libexpatpp
API, add #include "expatpp.hpp"
in your source file (CMake will automatically update your include path).
For complete documentation of libexpatpp library API, visit http://gittiver.github.io/libexpatpp (should be updated to the latest release).
To generate the latest API documentation yourself from the source, you need to have doxygen installed. Position yourself in the root directory and run doxygen
, this will generate docs/
directory. Then open docs/html/index.html
file with you favorite browser.
parses xml schemata and generates C++ code for types and elements from schema [TODO] generate also parser class for parsing schema
the example parses the xml output of doxygen documentation system and does a simple listing of its elements on standard output.
Feel free to send pull requests and raise issues.
When developing, you may want to use -D CMAKE_BUILD_TYPE=Debug
flag when calling cmake
in order to get debugging flags passed to compiler. This should also happen if you just run cmake ..
with no flags, but I think I have noticed it does not always works as expected (probably has something to do with cmake cache). To check which flags is compiler using, run make
with VERBOSE=1
: make VERBOSE=1
.