Struct codespawn::fmt_code::FormattedCode [] [src]

pub struct FormattedCode {
    pub language: Lang,
    pub elements: Vec<CodeItem>,
    pub num_tabs: u8,
    pub tab_char: char,
}

Formatted code data representation. Object of this type is already pre-parsed and ready to generate code for the specific language it's been formatted to.

Fields

Language name.

List of code elements, formatted for current language.

Number of tab characters per line (default: 4).

Tab character to be used (default: space).

Methods

impl FormattedCode
[src]

Saves generated code to file.

Examples

extern crate codespawn;

let raw_code = codespawn::from_xml("examples/sample.xml").unwrap();

// Create a FormattedCode object for C++ language
let cpp_code = raw_code.to_cpp().unwrap();
cpp_code.to_file("examples/sample.cpp");

Generates code and returns it as a String

Examples

extern crate codespawn;

let raw_code = codespawn::from_xml("examples/sample.xml").unwrap();

// Create a FormattedCode object for C++ language
let cpp_code = raw_code.to_cpp().unwrap();
println!("Generated C++ code:\n {}", cpp_code.to_string());

Trait Implementations

impl Display for FormattedCode
[src]

Formats the value using the given formatter. Read more