Skip to main content

C++ code writer library

Project description

C++ writer Quality assurance PyPI version

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 hashes)

Uploaded Source

Built Distribution

cppwriter-0.0.4-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page