Skip to content

Commit c467606

Browse files
committed
Add initial version based on v1.13
1 parent 3e151c8 commit c467606

File tree

8 files changed

+3796
-13
lines changed

8 files changed

+3796
-13
lines changed

.gitignore

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
CMakeLists.txt.user
2-
CMakeCache.txt
3-
CMakeFiles
4-
CMakeScripts
5-
Testing
6-
Makefile
7-
cmake_install.cmake
8-
install_manifest.txt
9-
compile_commands.json
10-
CTestTestfile.cmake
11-
_deps
1+
build/

CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
project("rapidxml" VERSION 1.13
3+
DESCRIPTION "Header-only library for C++11 to parse (read) XML data"
4+
HOMEPAGE_URL "https://github.com/CodeFinder2/rapidxml")
5+
include(GNUInstallDirs)
6+
7+
add_library(${PROJECT_NAME} INTERFACE)
8+
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
9+
target_include_directories(${PROJECT_NAME} SYSTEM
10+
INTERFACE $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
11+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
12+
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11)
13+
14+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME} DESTINATION include)

README.md

+62-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,62 @@
1-
# rapidxml
2-
CMake compatible and restructured mirror of http://rapidxml.sourceforge.net/
1+
# Overview
2+
3+
RapidXml is an attempt to create the fastest XML parser possible, while retaining useability, portability and reasonable W3C compatibility. It is an in-situ parser written in modern C++, with parsing speed approaching that of strlen function executed on the same data.
4+
5+
RapidXml has been around since 2006, and is being used by lots of people. HTC uses it in some of its mobile phones.
6+
7+
If you are looking for a stable and fast parser, look no further. Integration with your project will be trivial, because entire library is contained in a single header file, and requires no building or configuration.
8+
9+
This is a CMake compatible and restructured mirror of http://rapidxml.sourceforge.net/.
10+
11+
# Integration
12+
It is recommended to use [CPM](https://github.com/cpm-cmake/CPM.cmake) for integrating this libray. After adding [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake/blob/master/cmake/CPM.cmake) to your `cmake/` directory, simply add the following to your top-level `CMakeLists.txt` to include the library in your project:
13+
```cmake
14+
include(cmake/CPM.cmake)
15+
CPMAddPackage("gh:CodeFinder2/rapidxml@1.13")
16+
17+
add_executable(my_app ...)
18+
target_link_libraries(my_app rapidxml)
19+
```
20+
21+
# Usage
22+
Here's a small example on how to use it to parse a [GraphML](https://en.wikipedia.org/wiki/GraphML):
23+
```c++
24+
#include <iostream>
25+
26+
#include <rapidxml/rapidxml.hpp>
27+
#include <rapidxml/rapidxml_utils.hpp>
28+
29+
using namespace std;
30+
31+
int main(int argc, char *argv[])
32+
{
33+
try {
34+
namespace rx = rapidxml;
35+
// Read graph properties manually:
36+
rx::file<> file(argv[1]); // (default template is char)
37+
rx::xml_document<> doc;
38+
doc.parse<0>(file.data());
39+
40+
rx::xml_node<> *n_graphml = doc.first_node("graphml"); // root tag of the document
41+
if (n_graphml) {
42+
for (rx::xml_node<> *n = n_graphml->first_node("key"); n; n = n->next_sibling("key")) {
43+
rx::xml_attribute<> *intent = n->first_attribute("for");
44+
if (!intent || !intent->value()) {
45+
continue;
46+
}
47+
// Get an attribute from <key> tag:
48+
rx::xml_attribute<> *id = n->first_attribute("id");
49+
50+
// If everything is valid, try to extract the data:
51+
string data;
52+
getData(n->first_node("default"), data, false);
53+
// ...
54+
}
55+
}
56+
} catch (exception &e) {
57+
cerr << e.what() << endl;
58+
return EXIT_FAILURE;
59+
}
60+
return EXIT_SUCCESS;
61+
}
62+
```

doc/manual.html

+406
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)