https://github.com/johelegp/rapidxml
Project to improve and modernize the RapidXml 1.13 public API.
https://github.com/johelegp/rapidxml
xml xml-parser
Last synced: 12 months ago
JSON representation
Project to improve and modernize the RapidXml 1.13 public API.
- Host: GitHub
- URL: https://github.com/johelegp/rapidxml
- Owner: JohelEGP
- License: other
- Created: 2016-10-31T03:52:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T04:20:12.000Z (over 9 years ago)
- Last Synced: 2025-03-01T20:30:32.924Z (over 1 year ago)
- Topics: xml, xml-parser
- Language: C++
- Size: 4.59 MB
- Stars: 1
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# jegp/RapidXml
Project to improve and modernize the [RapidXml 1.13](http://rapidxml.sourceforge.net/) public API.
This project uses [Semantic Versioning 2.0.0](http://semver.org/).
## Getting started
### Dependencies
* [GSL](https://github.com/Microsoft/GSL)
* [jegp 3.0.0](https://github.com/johelegp/jegp)
### Installation
RapidXml is header-only. It is enough to make the headers visible to your building process to start using the library.
We support [CMake](https://cmake.org/). Just execute these commands from the root of the project:
```
cmake -E make_directory build
cmake -E chdir build cmake ..
```
And optionally install the library (commands for linux):
```
cd build
make install
```
## Features
* [String view/ref support](#string-viewref-support)
* [Policy type for case sensitivity](#policy-type-for-case-sensitivity)
* Convenience `xml_document::parse` overload for constant XML strings.
* [Ranges of node children and attributes](#ranges-of-node-children-and-attributes)
### String view/ref support
Wherever a RapidXml 1.13 member function has `const Ch*` and `std::size_t` parameter pairs representing string spans, there is an overload taking `std::basic_string_view` parameters, which passes to the overloaded member function the `data()` and `size()` values of the string views through the string spans' components they represent. [ Note: An empty string view can have non-`nullptr` `data()`. Some overloaded member functions interpret the non-`nullptr` `const Ch*` value of a string span with `0` `std::size_t` value as a [`gsl::czstring`](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#SS-views) and attempt to calculate its size. To match this meaning of emptiness, when a string view is empty, `nullptr` is passed instead of its `data()` to those overloaded member functions. -- end note ]
The `memory_pool::allocate_string` overload returns a `jegp::Basic_string_ref`.
For `xml_base`, the `name_ref` and `value_ref` member functions return a `jegp::Basic_string_ref` constructed with the string span components returned from the `name` and `name_size`, and `value` and `value_size` member functions respectively.
### Policy type for case sensitivity
To request or not case sensitive comparisons, the `bool case_sensitive` parameters of the overloads with string span support have been replaced with a dedicated type, `case_sensitivity`.
```C++
namespace rapidxml {
struct case_sensitivity { /*unspecified*/ };
// Requests that the comparisons are case sensitive (default).
constexpr case_sensitivity case_sensitive {/*unspecified*/};
// Requests that the comparisons are not case sensitive.
constexpr case_sensitivity non_case_sensitive {/*unspecified*/};
} // rapidxml namespace
```
These constants can also be used in place of the `bool case_sensitive` parameters.
### Ranges of node children and attributes
```C++
// In header
//...
template
/*unspecified*/ node_range(const xml_node *parent,
std::basic_string_view name = {}) noexcept;
template
/*unspecified*/ attribute_range(const xml_node *node,
std::basic_string_view name = {}) noexcept;
```
The functions return a range of pointers to the children/attributes of the node, optionally filtered by `name`.
The ranges offers minimal range-based for loop support.