https://github.com/lostjared/text2cpp
bin2cpp - Convert binary files to C,C++ or Go arrays text2cpp - convert Text to C++17
https://github.com/lostjared/text2cpp
conversion cplusplus golang text
Last synced: about 1 month ago
JSON representation
bin2cpp - Convert binary files to C,C++ or Go arrays text2cpp - convert Text to C++17
- Host: GitHub
- URL: https://github.com/lostjared/text2cpp
- Owner: lostjared
- Created: 2016-11-07T16:51:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-10T11:40:52.000Z (over 5 years ago)
- Last Synced: 2024-12-31T05:18:30.216Z (over 1 year ago)
- Topics: conversion, cplusplus, golang, text
- Language: C++
- Homepage:
- Size: 33.2 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bin2cpp / text2cpp
Convert Binary file to C,C++ or Go array to embed resources
Convert text files/terminal output into array of C++ std::string, hex values, or const char *
You will need: autotools (autoconf, automake etc.)
Clang or GCC version that supports C++17
To compile run:
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
# How to use the bin2cpp program:
$ bin2cpp sourcefile outputfilename language
langauge option should be c for C, cpp for C++, cpp17 for C++17, and go for Go
The Output filenames will have the source file extension be .c or .cpp, and the header file will have .h appended to it if you are using C++ you can use use memfile.hpp it will be installed to whatever prefix configure was configured for you can use this to manipulate the array similar to a
file. Or you could use this with SDL_RWops. The program will output the names of the array and a length variable.
# How to use the text2cpp:
Simple program that outputs header files using C++17's inline variables to use:
to use const char *:
$ text2cpp inputfile outputfile variable_name c
to use std::string:
$ text2cpp inputfile outputfile variable_name s
to use a character array char arr[]
$ text2cpp inputfile outputfile variable_name b
or
$ cat sourcefile | text2cpp variable_name s
or
$ cat sourcefile | text2cpp variable_name c
or
$ cat sourcefile | text2cpp variable_name b
optional skip blank lines with p argument
$ text2cpp inputfile outputfile varaiblename sp
or skip lines with char array[]:
$ cat source | text2cpp var_name bp
optional sorting use g for greater than, l for less than like this
for greater than sorting use
$ text2cpp inputfile outputfile variable_name sg
or less than sorting use
$ text2cpp inputfile outputfile variablename sl
also works with pipes
$ cat sourcefile | text2cpp variable_name cl