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: Lang
Language name.
elements: Vec<CodeItem>
List of code elements, formatted for current language.
num_tabs: u8
Number of tab characters per line (default: 4).
tab_char: char
Tab character to be used (default: space).
Methods
impl FormattedCode
[src]
fn to_file(&self, filename: &str) -> Result<()>
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");
fn to_string(&self) -> String
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());