C++ code writer library
Project description
C++ writer
The library provides an iterative interface for generating C/C++ code from Python.
Installation
pip install cppwriter
Usage
from cppwriter import FileBlock
file = FileBlock(indent_char=" ")
file.include("stdio.h", is_global=True)
file.line()
main = file.function("main", "int")
main.if_statement("PI > 4").line("return 1")
main.line("return 0")
print(str(file))
This will generate the following code:
#include <stdio.h>
int main() {
if (PI > 4) {
return 1;
}
return 0;
}
Relationship to cwriter
When I started making this library I didn't know about the existence of cwriter. I came across it while searching for a package name, but decided to give up and still finish my version.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cppwriter-0.0.4.tar.gz
(6.8 kB
view details)
Built Distribution
File details
Details for the file cppwriter-0.0.4.tar.gz
.
File metadata
- Download URL: cppwriter-0.0.4.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6f5c66ebca3fda4f07ff3c71e957d7dc314295a42b2479ac26e32198da74de5 |
|
MD5 | 7d5804f72c5888d903ba71933ac4c77a |
|
BLAKE2b-256 | 522d7c921f52fdc480cccc23b10b15b2a924a8a0e939ee205ba13b1aeb207992 |
File details
Details for the file cppwriter-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: cppwriter-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e2903a5be8d5561112f9068c87442fd68bf018945e20cc5be83e3e1920f2260 |
|
MD5 | feabfc3f145a664197f6eccb015173ff |
|
BLAKE2b-256 | 9fdcae6cda3504d011e426a53726998f6bdff96b5b9628cbce4888c28533ae16 |