d-e-e-p / cpp-fstring-examples

Examples of using cpp-fstring: python style f-strings in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cpp_fstring_examples

Examples of using a C++ preprocessing script cpp-fstring to process python-style f-strings.

This companion repository shows how to incorporate cpp-format in a cmake environment, and has examples of using C++ f-strings.

Credits/Motivation

See cpp-fstring

Getting Started

├── Makefile
├── include
│   └── fstr.h
├── examples
│   ├── CMakeLists.txt
│   ├── psrc
│   │   ├── demo_misc.cpp
│   │   ├── ...
│   │   ├── enum_namespace.cpp
│   │   ├── fixed_size_string_buffer.h
│   │   └── tinyply.h
│   ├── src
│   │   ├── demo_misc.cpp
│   │   ├── ...
│   │   ├── enum_namespace.cpp
│   │   ├── fixed_size_string_buffer.h
│   │   └── tinyply.h
│   ├── out
│   │   ├── demo_misc.log
│   │   ├── ...
│   │   └── enum_namespace.log

Look at the Makefile for debug or release targets. The cmake command generates run files under build dir and then uses cpp-fstring to convert files under psrc dir to src dir. This generated code is compiled and executed. in examples/CMakeLists.txt the following cmake command adds the cpp-fstring step:

COMMAND cpp-fstring ${source} -I src -I ../include > ${target}

for a single file like examples/psrc/class_basic.cpp this is equvalent to:

cpp-fstring examples/psrc/class_basic.cpp -I src -I ../include > examples/src/class_basic.cpp

API

Tests and Benchmark

Using cpp_fstring

Dir Structure

Authors

License

The project is available under the MIT license. See LICENSE file for details

About

Examples of using cpp-fstring: python style f-strings in C++

License:MIT License


Languages

Language:CMake 83.2%Language:Python 7.2%Language:C++ 6.3%Language:Makefile 2.6%Language:Shell 0.7%