GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lostjared/bin2cpp20: Unix Utility for Transforming a Stream into a C++20 Array, Vector, or Array of Strings

BranchesTags
Open more actions menu

Latest commit

 

History

44 Commits
44 Commits

Folders and files

NameName
Last commit message
Last commit date
bin2cpp20-gui
bin2cpp20-gui
 
 
bin2cpp20
bin2cpp20
 
 
.clang-format
.clang-format
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

bin2cpp20 - Binary to C++20 Source Conversion Tool

image

Now contains GUI in Qt6.

Overview

bin2cpp20 is a versatile command-line utility designed to convert binary files/string data into C++20 compliant source code. This enables the embedding of binary/string data directly within C++ applications in a portable and efficient manner. The tool offers flexibility in output formats, including vectors, arrays, and strings, and supports additional options like sorting and Unicode handling.

Motivation

The motivation for this application was to be able to quickly generate arrays of binary/string data that I could embed in my C++20 code. Also to test out my new argument parsing header file argz.hpp.

Demonstration

Here is a video demo of the application: https://youtu.be/umDLwADWRmM

Requirements

  • Fully C++20 compliant environment

Compilation

To compile bin2cpp20, use the following command:

make -f Makefile.ux 

or

mkdir build && cd build
cmake ..
make -j4
sudo make install 

Usage

The basic usage of the tool can be invoked as follows:

bin2cpp20 [options]

Key Features

  • Input from file or standard input: Specify an input binary file or use standard input.
  • Output to standard output or file: Direct the converted C++ source to standard output or a specified file.
  • Variable naming: Define custom variable names for the generated code.
  • Output formats: Choose between vector, array, or string representations of the binary data.
  • Sorting and Unicode options: Sort strings in the output or handle Unicode data correctly.

Options

  • -i, --input <file/stdin>: Specify the input source. Use "stdin" to read from standard input.
  • -o, --output <file>: Specify the output file. If not provided, output will be directed to standard output.
  • -v, --variable <name>: Set the name of the generated variable. This is required.
  • -s, --string output: Generate output as a string.
  • -z, --sort: Sort the output string. Applicable only with string output.
  • -u, --unicode: Treat the input as Unicode. Applicable only with string output.
  • -h, --help: Display the help message and exit.

Examples

Convert a binary file to a array:

bin2cpp20 -i path/to/input/file -o path/to/output.hpp -v variable_name

Convert standard input to a sorted Unicode string:

cat path/to/input | bin2cpp20 -i stdin -s -u -z -v variable_name -o path/to/output.hpp

Additional Notes

  • Ensure variable names are valid C++ identifiers.
  • Input files are read in binary mode, preserving the integrity of binary data.
  • The tool automatically appends .hpp to output filenames if not present.

About

Unix Utility for Transforming a Stream into a C++20 Array, Vector, or Array of Strings

lostsidedead.biz/bin2cpp20

Topics

conversion-toolcpp20text-to-cppunix-toolutility

Resources

Readme
GPL-3.0 license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.