1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

/*!
This library is designed to represent SVG data as a tree structure.

Here is simple overview of such structure:

- [`Document`](struct.Document.html)
    - root [`Node`](struct.Node.html)
        - user defined [`Node`](struct.Node.html)
            - [`TagName`](type.TagName.html)
            - [`Attributes`](struct.Attributes.html)
            - unique id
        - user defined [`Node`](struct.Node.html)
        - ...

The [`Document`](struct.Document.html) itself is just a container of `Node`s.
You can create new `Node`s only through the `Document`. Parsing and generating of the SVG data also
done through it.

The [`Node`](struct.Node.html) represents any kind of an XML node.
It can be an element, a comment, a text, etc. There are no different structs for each type.

The [`TagName`](type.TagName.html) represents a tag name of the element node. It's an enum of
[`ElementId`](enum.ElementId.html) and `String` types. The `ElementId` contains all possible
SVG element names and `String` used for non-SVG elements. Such separation used for
performance reasons.

The [`Attributes`](struct.Attributes.html) container wraps a `Vec` of
[`Attribute`](struct.Attribute.html)'s.

At last, the `id` attribute is stored as a separate value and not as part of the `Attributes`.

 

See modules and structs documentation for details.

 

DOM structure itself based on: https://github.com/SimonSapin/rust-forest/tree/master/rctree
*/

#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![deny(unused_import_braces)]

extern crate svgparser;
extern crate simplecss;
extern crate float_cmp;

pub use attribute::*;
pub use dom::*;
pub use error::Error;
pub use name::*;
pub use traits::*;
pub use write_options::*;
#[cfg(feature = "parsing")]
pub use parse_options::*;

pub use svgparser::AttributeId;
pub use svgparser::ElementId;
pub use svgparser::ErrorPos;
pub use svgparser::ValueId;

#[macro_use]
mod traits;

// TODO: #[cfg(test)]
#[macro_export]
macro_rules! assert_eq_text {
    ($left:expr, $right:expr) => ({
        match (&$left, &$right) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    panic!("assertion failed: `(left == right)` \
                           \nleft:  `{}`\nright: `{}`",
                           left_val, right_val)
                }
            }
        }
    })
}

mod attribute;
mod dom;
mod error;
mod name;
#[cfg(feature = "parsing")]
mod parse_options;
#[cfg(feature = "parsing")]
mod parser;
mod write_options;

pub mod types;
pub mod writer;