pub struct Preprocessor { /* private fields */ }Expand description
The main C preprocessor struct
Implementations§
Source§impl Preprocessor
impl Preprocessor
Sourcepub fn with_config(config: &PreprocessorConfig) -> Self
pub fn with_config(config: &PreprocessorConfig) -> Self
Create a preprocessor with the given configuration
Sourcepub fn apply_config(&mut self, config: &PreprocessorConfig)
pub fn apply_config(&mut self, config: &PreprocessorConfig)
Apply configuration to the preprocessor
Sourcepub fn with_include_resolver<F>(self, f: F) -> Self
pub fn with_include_resolver<F>(self, f: F) -> Self
Add a custom include resolver function
Sourcepub fn set_recursion_limit(&mut self, limit: usize)
pub fn set_recursion_limit(&mut self, limit: usize)
Set the maximum recursion depth for macro expansion
Sourcepub fn set_current_file(&mut self, file: String)
pub fn set_current_file(&mut self, file: String)
Set the current file name for error reporting
Sourcepub fn define<S: AsRef<str>>(
&mut self,
name: S,
params: Option<Vec<String>>,
body: S,
is_variadic: bool,
)
pub fn define<S: AsRef<str>>( &mut self, name: S, params: Option<Vec<String>>, body: S, is_variadic: bool, )
Define a preprocessor macro
Sourcepub fn get_macros(&self) -> &HashMap<String, Macro>
pub fn get_macros(&self) -> &HashMap<String, Macro>
Get a reference to the defined macros
Sourcepub fn is_defined(&self, name: &str) -> bool
pub fn is_defined(&self, name: &str) -> bool
Check if a macro is defined
Sourcepub fn process(&mut self, input: &str) -> Result<String, PreprocessError>
pub fn process(&mut self, input: &str) -> Result<String, PreprocessError>
Process the input C code and return the preprocessed result
§Errors
Returns PreprocessError if there’s a malformed directive,
macro recursion limit is exceeded, or conditional blocks are unterminated.
Sourcepub fn parse_expression(&self, expr: &str) -> Result<bool, PreprocessError>
pub fn parse_expression(&self, expr: &str) -> Result<bool, PreprocessError>
Parse a preprocessor expression with full operator support
§Errors
Returns PreprocessError if the expression is malformed or has invalid operators.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Preprocessor
impl !RefUnwindSafe for Preprocessor
impl !Send for Preprocessor
impl !Sync for Preprocessor
impl Unpin for Preprocessor
impl !UnwindSafe for Preprocessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more