cppwriter


Namecppwriter JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryC++ code writer library
upload_time2024-07-02 11:10:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords cpp arduino c++
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # C++ writer [![Quality assurance](https://github.com/mishamyrt/cppwriter/actions/workflows/qa.yaml/badge.svg)](https://github.com/mishamyrt/cppwriter/actions/workflows/qa.yaml) [![PyPI version](https://badge.fury.io/py/cppwriter.svg)](https://badge.fury.io/py/cppwriter)

The library provides an iterative interface for generating C/C++ code from Python.

## Installation

```sh
pip install cppwriter
```

## Usage

```python
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:

```c
#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.  

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cppwriter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "cpp, arduino, c++",
    "author": null,
    "author_email": "Mikhael Khrustik <misha@myrt.co>",
    "download_url": "https://files.pythonhosted.org/packages/52/2d/7c921f52fdc480cccc23b10b15b2a924a8a0e939ee205ba13b1aeb207992/cppwriter-0.0.4.tar.gz",
    "platform": null,
    "description": "# C++ writer [![Quality assurance](https://github.com/mishamyrt/cppwriter/actions/workflows/qa.yaml/badge.svg)](https://github.com/mishamyrt/cppwriter/actions/workflows/qa.yaml) [![PyPI version](https://badge.fury.io/py/cppwriter.svg)](https://badge.fury.io/py/cppwriter)\n\nThe library provides an iterative interface for generating C/C++ code from Python.\n\n## Installation\n\n```sh\npip install cppwriter\n```\n\n## Usage\n\n```python\nfrom cppwriter import FileBlock\n\nfile = FileBlock(indent_char=\"  \")\nfile.include(\"stdio.h\", is_global=True)\nfile.line()\nmain = file.function(\"main\", \"int\")\nmain.if_statement(\"PI > 4\").line(\"return 1\")\nmain.line(\"return 0\")\nprint(str(file))\n```\n\nThis will generate the following code:\n\n```c\n#include <stdio.h>\n\nint main() {\n  if (PI > 4) {\n    return 1;\n  }\n  return 0;\n}\n```\n\n## Relationship to cwriter\n\nWhen 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.  \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "C++ code writer library",
    "version": "0.0.4",
    "project_urls": null,
    "split_keywords": [
        "cpp",
        " arduino",
        " c++"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9fdcae6cda3504d011e426a53726998f6bdff96b5b9628cbce4888c28533ae16",
                "md5": "feabfc3f145a664197f6eccb015173ff",
                "sha256": "2e2903a5be8d5561112f9068c87442fd68bf018945e20cc5be83e3e1920f2260"
            },
            "downloads": -1,
            "filename": "cppwriter-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "feabfc3f145a664197f6eccb015173ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5541,
            "upload_time": "2024-07-02T11:09:59",
            "upload_time_iso_8601": "2024-07-02T11:09:59.090817Z",
            "url": "https://files.pythonhosted.org/packages/9f/dc/ae6cda3504d011e426a53726998f6bdff96b5b9628cbce4888c28533ae16/cppwriter-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "522d7c921f52fdc480cccc23b10b15b2a924a8a0e939ee205ba13b1aeb207992",
                "md5": "7d5804f72c5888d903ba71933ac4c77a",
                "sha256": "a6f5c66ebca3fda4f07ff3c71e957d7dc314295a42b2479ac26e32198da74de5"
            },
            "downloads": -1,
            "filename": "cppwriter-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "7d5804f72c5888d903ba71933ac4c77a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 6751,
            "upload_time": "2024-07-02T11:10:02",
            "upload_time_iso_8601": "2024-07-02T11:10:02.958441Z",
            "url": "https://files.pythonhosted.org/packages/52/2d/7c921f52fdc480cccc23b10b15b2a924a8a0e939ee205ba13b1aeb207992/cppwriter-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-02 11:10:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cppwriter"
}
        
Elapsed time: 0.28042s