{"id":17263657,"url":"https://github.com/gittiver/libexpatpp","last_synced_at":"2025-04-14T07:53:33.899Z","repository":{"id":43444373,"uuid":"302460887","full_name":"gittiver/libexpatpp","owner":"gittiver","description":" a modern C++ xml parser toolkit using expat","archived":false,"fork":false,"pushed_at":"2024-10-03T18:38:24.000Z","size":2409,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T21:39:01.643Z","etag":null,"topics":["doxygen-xml","expat","modern-cpp","xml","xml-parser","xml-parsers","xml-schema"],"latest_commit_sha":null,"homepage":"https://gittiver.github.io/libexpatpp/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gittiver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-10-08T21:00:56.000Z","updated_at":"2025-03-24T16:33:15.000Z","dependencies_parsed_at":"2024-03-21T14:55:49.688Z","dependency_job_id":"cf10a8c5-2a85-43c0-a26b-8d9a714eee28","html_url":"https://github.com/gittiver/libexpatpp","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gittiver%2Flibexpatpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gittiver%2Flibexpatpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gittiver%2Flibexpatpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gittiver%2Flibexpatpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gittiver","download_url":"https://codeload.github.com/gittiver/libexpatpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248844084,"owners_count":21170486,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["doxygen-xml","expat","modern-cpp","xml","xml-parser","xml-parsers","xml-schema"],"created_at":"2024-10-15T07:57:10.673Z","updated_at":"2025-04-14T07:53:33.863Z","avatar_url":"https://github.com/gittiver.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libexpatpp - a modern C++ xml parser toolkit using expat\n\n[![Build and Test](https://github.com/gittiver/libexpatpp/actions/workflows/ccpp.yml/badge.svg)](https://github.com/gittiver/libexpatpp/actions/workflows/ccpp.yml)\n[![Documentation](https://github.com/gittiver/libexpatpp/actions/workflows/doxygen-gh-pages.yml/badge.svg)](https://github.com/gittiver/libexpatpp/actions/workflows/doxygen-gh-pages.yml)\n[![Packaging status](https://repology.org/badge/tiny-repos/libexpatpp.svg)](https://repology.org/metapackage/libexpatpp/versions)\n\n\u003c!--\n[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/gittiver/libexpatpp?svg=true)](https://ci.appveyor.com/project/gittiver/libexpatpp)\n[![Travis CI Build Status](https://travis-ci.org/gittiver/libexpatpp.svg?branch=main)](https://travis-ci.org/gittiver/libexpatpp)\n[![Documentation Status](https://readthedocs.org/projects/libexpatpp/badge/?version=latest)](https://libexpatpp.readthedocs.io/en/latest/?badge=latest) \n!--\u003e\n\nA lightweight and modern C/C++ library for building xml parsers.\nCurrently a work in progress.\n\n## Features ##\n\n* wraps and build **expat** as part of library\n* runs on all major platforms: Windows, OSX, linux\n* provides an easy to use delegate class to build xml parsers\n* [WORK IN PROGRESS]utilizing lambda for easy adding of handler callbacks\n* [WORK IN PROGRESS]provides implementation of parser with stack of parsestates\n* [WORK IN PROGRESS]xsdgen for generating C++ classes and parser from\n  xsd schemata\n\n## Contents\n- [Features](#features)\n- [Building](#building)\n- [Using libexpatpp in your project](#using-expatpp-library-in-your-project)\n- [API documentation](#api-documentation)\n- [Running tests](#running-tests)\n- [Development and contributing](#development-and-contributing)\n- [Publication](#publication)\n- [Acknowledgements](#acknowledgements)\n\n\n## Building\n\nlibexpatpp can be built with \u003ca href=\"https://cmake.org\"\u003eCMake\u003c/a\u003e.\nCMake is able to produce a build environment for most platforms.\nFor the most important IDE exists a \u003ca href=\"https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html\"\u003egenerator option\u003c/a\u003e which allows to build project files for these systems.\n\nThe simplest (and platform independent) way to build the project using cmake\nis executing the following command:\n\n```\ncmake -B \u003cbuilddir\u003e \u0026\u0026 cmake --build \u003cbuilddir\u003e\n```\n\nFirst command in chain creates the build directory \\\u003cbuilddir\\\u003e and configures the project.\nSecond command does a build of the default target in \\\u003cbuilddir\\\u003e.\n\nCmake can also be called with predefined options,\nhere for configuring and building a Release build:\n```\ncmake -D CMAKE_BUILD_TYPE=Release -B \u003cbuilddir\u003e \u0026\u0026 cmake --build \u003cbuilddir\u003e\n```\n## Using expatpp library in your project\n\n### The \"Hello World\" example\n\nThe 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 \\ref approach1 .\n\nOur \"hello_world\" project has just one source file, `hello_world.cpp` file, and it looks like this:\n\n```cpp\n/**\n * \\file hello_world.cpp the hello_world example for expatpp library\n * \n * See LICENSE for copyright information.\n */\n#include \u003ciostream\u003e\n#include \"expatpp.hpp\"\n\nusing std::cout;\nusing std::endl;\n\n/** a parser delegate which extracts the character data from an xml element*/\nclass element_delegate : public xmlpp::abstract_delegate {\npublic:\n  std::string fullname;\n  std::string characterData;\n\n  void onStartElement( const XML_Char *fullname, const XML_Char **atts) override {\n    this-\u003efullname = fullname;\n  }\n \n  void onCharacterData(const char *pBuf, int len) override {\n    characterData.append(pBuf,len);\n  }\n};\n\nint main(int argc,char** argv) {\n  // prepare xml input, \n  const char* xml = \"\u003cp\u003ehello world!\u003c/p\u003e\";\n\n  // use the delegate to extract character data from input string\n  element_delegate d;\n\n  // parse xml input using delegate d's callbacks\n  xmlpp::parser::result res = xmlpp::parser::parseString(xml,d);\n\n  switch(res) {\n\n  case xmlpp::parser::result::OK:\n    // and output the extracted data in case of successful parsing\n    cout \u003c\u003c \"element \" \u003c\u003c d.fullName \u003c\u003c endl\n\t \u003c\u003c \" contains this text: \"\u003c\u003c d.characterData \u003c\u003c endl;\n    return EXIT_SUCCESS;\n\n  default:\n    cout \u003c\u003c \"error \" \u003c\u003c static_cast\u003cint\u003e(res)\n\t \u003c\u003c \" on parsing \" \u003c\u003c endl;\n    return -static_cast\u003cint\u003e(res);\n  }\n}\n```\n\nRunning it should output\n\n```\nelement p\ncontains this text: Hello World\n```\n\nfor the CMake based build we have included a simple CMakeLists.txt: \n\n```cmake\ncmake_minimum_required(VERSION 3.1.3)\n\nenable_language(C)\nenable_language(CXX)\nset(CMAKE_CXX_STANDARD 11)\n\nif(POLICY CMP0077)\n    cmake_policy(SET CMP0077 NEW)\nendif()\n\nproject(expatpp_hello_world VERSION 0.0.1 LANGUAGES CXX)\n\ninclude(FetchContent)\n#\n# expatpp Configuration variables\n#\nset(EXPATPP_BUILD_EXAMPLES Off)\nset(EXPATPP_BUILD_TOOLS Off)\nset(EXPATPP_BUILD_TESTS Off)\nset(EXPATPP_BUILD_DOCS Off)\n\n# add expatpp project to the build\nFetchContent_Declare(expatpp\n  \t\t GIT_REPOSITORY https://github.com/gittiver/libexpatpp.git\n\t\t GIT_TAG main\n\t\t )\n\nif(NOT expatpp_POPULATED)\n  FetchContent_Populate(expatpp)\n  add_subdirectory(${expatpp_SOURCE_DIR} ${expatpp_BINARY_DIR})\nendif(NOT expatpp_POPULATED)\n\n# add executable\nadd_executable(hello_world hello_world.cpp)\n\n# link against expatpp library (produced by expatpp)\ntarget_link_libraries(hello_world PUBLIC expatpp)\n```\n\nTo get you started quickly, let's take a look at a few ways to get simple Hello World project working.\n\n### Approach #1: Use Cmake's FetchContent() Command\n\nCMake contains the FetchContent() command to use libraries where a project depends on.\n\nWith:\n```cmake\nFetchContent_Declare(expatpp         \n    GIT_REPOSITORY \"https://github.com/gittiver/libexpatpp\" \n    GIT_TAG \"v0_0_1\" )\nFetchContent_MakeAvailable(expatpp)\n```\n\nwe include the library into the build.\n\nWith: \n```cmake\ntarget_link_libraries(your_exe expatpp)\n```\n\nwe link our executable against libexpatpp.\nThis approach is used in the helloworld example, you can use the CMakeFile.lst from there as starting point for your project.\n\n### Approach #2: Install libexpatpp library on machine.\n\nYou can install libraries by running in libexpatpp directory: \n\n```bash\ncmake --build \u003cbuilddir\u003e --target install\n```\n\nNow, all you have to do to compile your project is `c++ helloWorld.cpp -o helloWorld -llibexpatpp`.\n\nIf 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.\n\n### Approach #3: Use as git submodule and use cmake in your project via CMake.\n\nIf you are using CMake for compilation, we suggest adding libexpatpp as a git submodule with the command\n```bash\ngit submodule add https://github.com/gittiver/libexpatpp vendor/libexpatpp`\n```\n\nAfterwards, modify your top level CMakeLists.txt file accordingly:\n\n```cmake\nadd_subdirectory(vendor/libexpatpp EXCLUDE_FROM_ALL)\ntarget_link_libraries(your_exe expatpp)\n```\n\nThe `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).\n\n## API documentation\n\nFor complete documentation of libexpatpp library API, visit [http://gittiver.github.io/libexpatpp](http://gittiver.github.io/libexpatpp) (should be updated to the latest release).\n\nTo generate the latest API documentation yourself from the source, you need to have [doxygen](www.doxygen.org) installed.\nPosition yourself in the root directory and run `doxygen`, this will generate `docs/` directory. Then open `docs/html/index.html` file with you favorite browser.\n\n## Running tests\n\nTBD describe how to run included Catch2 based tests\n\n## xsdgen - generate C++ code from xsd files\n\nparses xml schemata and generates C++ code for types and elements\nfrom schema\n[TODO] generate also parser class for parsing schema\n\n## Examples\n\n### doxyml - parse doxygen xml output\n\nthe example parses the xml output of doxygen documentation system and\ndoes a simple listing of its elements on standard output.\n\n## Development and contributing\nFeel free to send pull requests and raise issues.\n\nWhen developing, you may want to use `-D CMAKE_BUILD_TYPE=Debug` flag when calling `cmake` in order to get debugging flags passed to compiler. \nThis should also happen if you just run `cmake \u003cbuilddir\u003e` with no flags. \n\nTo check which flags is compiler using, run `make` with `VERBOSE=1`: `make VERBOSE=1`.\n\n## Publication\n\n## Acknowledgements\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgittiver%2Flibexpatpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgittiver%2Flibexpatpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgittiver%2Flibexpatpp/lists"}