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
//! [Codespawn](https://github.com/kondrak/codespawn) is a basic C++ and Rust code generator.
//! Desired API can be defined using either JSON or XML and the crate supports both reading
//! from a file or a string.
//!
//! Currently it's possible to generate enums, structs, functions, function pointers, variables
//! and bitflags with all applicable attributes and properties.
//!
//! See [example XML](https://github.com/kondrak/codespawn/blob/master/examples/sample.xml) for instructions
//! on how to construct the API definition.
//!
//!# Quick Start
//!
//!```
//!extern crate codespawn;
//!
//!fn main()
//!{
//! // generate from XML definition
//! let raw_code = codespawn::from_xml("examples/sample.xml").unwrap();
//! // generate from JSON definition
//! //let raw_code = codespawn::from_json("examples/sample.json").unwrap();
//!
//! // generate code, store as String
//! let cpp_code = raw_code.to_cpp().unwrap().to_string();
//! let rust_code = raw_code.to_rust().unwrap().to_string();
//!
//! // generate C++ and save directly to file
//! raw_code.to_cpp().unwrap().to_file("examples/sample.cpp");
//! // generate Rust and save directly to file
//! //raw_code.to_rust().unwrap().to_file("examples/sample.rs");
//!}
//!```
use Result;
use ;
/// Reads XML data from file and compiles it into `RawCode`
///
/// # Examples
///
/// ```
/// extern crate codespawn;
///
/// let raw_code = codespawn::from_xml("examples/sample.xml").unwrap();
/// ```
/// Reads XML data from a `&str` and compiles it into `RawCode`
///
/// # Examples
///
/// ```
/// extern crate codespawn;
///
/// let raw_code = codespawn::from_xml_str("<enum name=\"Foo\"><var name=\"EnumVal1\" type=\"int\" /></enum>").unwrap();
/// ```
/// Reads JSON data from file and compiles it into `RawCode`
///
/// # Examples
///
/// ```
/// extern crate codespawn;
///
/// let raw_code = codespawn::from_json("examples/sample.json").unwrap();
/// ```
/// Reads JSON data from a `&str` and compiles it into `RawCode`
///
/// # Examples
///
/// ```
/// extern crate codespawn;
///
/// let raw_code = codespawn::from_json_str("{\"enum\": { \"name\": \"Foo\",\"var\": {\"name\": \"EnumVal1\",\"type\": \"int\" }}}").unwrap();
/// ```