Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Changes for 3.1.0:

* Fixed issue #29: Create arguments to filter files found with '--dir' argument.
* Fixed issue #63: Context class redesign. Move arguments handling into a Context class.
* Fixed issue #64: Remove build artifacts of samples from installation packages.
* Fixed issue #72: Move the code FileManager class generation code into its own IGenerator implementation.
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ SET(BIN2CPP_VERSION_PATCH 0)
set(BIN2CPP_VERSION ${BIN2CPP_VERSION_MAJOR}.${BIN2CPP_VERSION_MINOR}.${BIN2CPP_VERSION_PATCH})
FILE(WRITE ${CMAKE_BINARY_DIR}/version "${BIN2CPP_VERSION}")

# Force c++ 11
# https://www.reddit.com/r/cpp_questions/comments/1d4tt8a/comment/l6gqea5/
# My guess is that you are on mac and using g++ to compile. For godforsaken reasons, g++ by default is an alias to clang++ forced into some crazy C++98 mode.
# https://stackoverflow.com/questions/10851247/how-do-i-activate-c-11-in-cmake
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED TRUE)

# Create a c++ file header from the project LICENSE file.
# The c++ header will be added to all generated files.
include(MakeCplusplusHeader)
Expand Down Expand Up @@ -180,6 +187,9 @@ add_subdirectory(src/bin2cpp)

# unit tests
if(BIN2CPP_BUILD_TEST)
# Create a temp directory under the build directory to output temporary files.
make_directory(${CMAKE_CURRENT_BINARY_DIR}/temp)

add_subdirectory(test/testfilegenerator)
add_subdirectory(test/bin2cpp_unittest)
endif()
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Build:
| Service/Platform | Build | Tests |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AppVeyor | [![Build status](https://img.shields.io/appveyor/ci/end2endzone/bin2cpp/master.svg?logo=AppVeyor&logoColor=white)](https://ci.appveyor.com/project/end2endzone/bin2cpp) | [![Tests status](https://img.shields.io/appveyor/tests/end2endzone/bin2cpp/master.svg?logo=AppVeyor&logoColor=white)](https://ci.appveyor.com/project/end2endzone/bin2cpp/branch/master/tests) |
| Travis CI | [![Build Status](https://img.shields.io/travis/end2endzone/bin2cpp/master.svg?logo=Travis-CI&style=flat&logoColor=white)](https://travis-ci.org/end2endzone/bin2cpp) | |
| Windows Server 2019 | [![Build on Windows](https://github.com/end2endzone/bin2cpp/actions/workflows/build_windows.yml/badge.svg)](https://github.com/end2endzone/bin2cpp/actions/workflows/build_windows.yml) | [![Tests on Windows](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/end2endzone/58cf6c72c08e706335337d5ef9ca48e8/raw/bin2cpp.master.Windows.json)](https://github.com/end2endzone/bin2cpp/actions/workflows/build_windows.yml) |
| Ubuntu 20.04 | [![Build on Linux](https://github.com/end2endzone/bin2cpp/actions/workflows/build_linux.yml/badge.svg)](https://github.com/end2endzone/bin2cpp/actions/workflows/build_linux.yml) | [![Tests on Linux](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/end2endzone/58cf6c72c08e706335337d5ef9ca48e8/raw/bin2cpp.master.Linux.json)](https://github.com/end2endzone/bin2cpp/actions/workflows/build_linux.yml) |
| macOS 10.15 | [![Build on macOS](https://github.com/end2endzone/bin2cpp/actions/workflows/build_macos.yml/badge.svg)](https://github.com/end2endzone/bin2cpp/actions/workflows/build_macos.yml) | [![Tests on macOS](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/end2endzone/58cf6c72c08e706335337d5ef9ca48e8/raw/bin2cpp.master.macOS.json)](https://github.com/end2endzone/bin2cpp/actions/workflows/build_macos.yml) |
Expand Down Expand Up @@ -86,7 +85,6 @@ The following section shows how to use bin2cpp with code examples:


## Command Line Usage

```
bin2cpp --file=<path> --output=<path> [--headerfile=<name>] [--identifier=<name>]
[--generator=<name>] [--encoding=<name>] [--chunksize=<value>] [--namespace=<value>]
Expand All @@ -95,6 +93,7 @@ bin2cpp --file=<path> --output=<path> [--headerfile=<name>] [--identifier=<name>
bin2cpp --dir=<path> --output=<path> [--keepdirs]
[--generator=<name>] [--encoding=<name>] [--chunksize=<value>] [--namespace=<value>]
[--baseclass=<name>] [--managerfile=<name>] [--registerfile]
[--dirincludefilter=<value>] [--direxcludefilter=<value>]
[--override] [--noheader] [--quiet]
bin2cpp --help
bin2cpp --version
Expand All @@ -117,12 +116,33 @@ bin2cpp --version
| --reportedfilepath=&lt;path&gt; | The relative reported path of the File. Path returned when calling method getFilePath() of the File class. Automatically calculated when --dir mode is used.<br>ie: images/DCIM/IMG_0001.jpg |
| --managerfile=&lt;path&gt; | File name or relative path of the generated C++ header file for the FileManager class.<br>ie: FileManager.h. |
| --registerfile | Register the generated file to the FileManager class. This flags is automatically set when parameter 'managerfile' is specified. |
| --dirincludefilter=&lt;value&gt;| Set a positive filter on the input directory to only select files matching the filter. Wildcard characters are accepted. Separate each filter with the character ':'. Valid only when --dir is used. See wildcard characters definition below. |
| --direxcludefilter=&lt;value&gt;| Set a negative filter on the input directory to skip files matching the filter. Wildcard characters are accepted. Separate each filter with the character ':'. Valid only when --dir is used. See wildcard characters definition below. The exclude filter has precedence over the include filter. |
| --keepdirs | Keep the directory structure. Forces the output files to have the same directory structure as the input files. Valid only when --dir is used. |
| --plainoutput | Print the encoded string in plain format to stdout. Useful for scripts and integration with third party application. |
| --override | Tells bin2cpp to overwrite the destination files. |
| --noheader | Do not print program header to standard output. |
| --quiet | Do not log any message to standard output. |

&nbsp;

Wildcard characters:
| Wildcard | Description |
|:-----------:|--------------------------------------------------------------|
| `?` | Matches any single character. |
| `*` | Matches zero or more characters. |
| `#` | Matches exactly one numeric digit (0-9). |
| [charlist] | Matches any single character inside the brackets. |
| [a-z] | Matches any single lowercase letter between 'a' and 'z'. |
| [A-Z] | Matches any single uppercase letter between 'A' and 'A'. |
| [0-9] | Matches any single digit between '0' and '9'. |
| [a-zA-Z0-9] | Matches any single letter (uppercase or lowercase) or digit. |

For example:
* `ker*##.???` matches files that starts with `ker`, and ends with 2 digits, a dot and then 3 characters.
* `--dir-include-filter="*.jpg:*.png"` includes all files whose file extension is `jpg` or `png`.
* `--dir-exclude-filter="*.bak"` excludes all backup files.
* `--dir-include-filter="*.log" --dir-exclude-filter="debug.log"` includes all log files but not the one specificaly named `debug.log`.


## Example 1 - single file
Expand Down
Binary file added samples/demo_website/www/contact/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 24 additions & 15 deletions samples/demo_website/www/contact/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
<title>Contact</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
.container { max-width: 600px; margin: auto; }
label { display: block; margin-top: 10px; }
input, textarea { width: 100%; padding: 10px; margin-top: 5px; }
button { margin-top: 15px; padding: 10px 20px; background-color: blue; color: white; border: none; cursor: pointer; }
.profile-image-container {
text-align: center; /* Centers the image horizontally */
}
.profile-image-container img {
width: 300px;
height: auto; /* Keeps aspect ratio */
}
</style>
</head>
<body>
<article id="post-13" class="post-13 page type-page status-publish hentry wpautop">
<header class="entry-header">
<h1 class="entry-title">Contact</h1>
</header>
<div class="entry-content">
<p>Feel free to contact me about your DIY projects!</p>
<div role="form" class="wpcf7" id="wpcf7-f2524-p13-o1" lang="en-US" dir="ltr">
<div class="screen-reader-response">
<p role="status" aria-live="polite" aria-atomic="true"></p>
<ul></ul>

<div class="container">
<h2>Contact Me</h2>
<div class="profile-image-container">
<img class="foobar" src="../static/profile-picture.jpg">
</div>
<form action="/contact/#wpcf7-f2524-p13-o1" method="post" class="wpcf7-form init" novalidate="novalidate" data-status="init">
<p>Your Name (required)<br>
Expand All @@ -37,7 +46,7 @@ <h1 class="entry-title">Contact</h1>
<p><input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit" aria-invalid="false"><span class="ajax-loader"></span></p>
<div class="wpcf7-response-output" aria-hidden="true"></div>
</form>
</div>
</article>
</div>

</body>
</html>
Binary file added samples/demo_website/www/favicon.ico
Binary file not shown.
73 changes: 69 additions & 4 deletions samples/demo_website/www/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
<title>Website root</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nature & Outdoors Blog</title>
<link id="theme-style" rel="stylesheet" href="static/light-mode.css">
<style>
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #4CAF50;
padding: 15px;
}
.navbar a {
color: white;
text-decoration: none;
padding: 15px 20px;
font-size: 18px;
}
.navbar a:hover {
background-color: rgba(255, 255, 255, 0.2);
border-radius: 5px;
}
.nav-right {
margin-left: auto;
}
.switch-theme {
background-color: #FFA726;
padding: 10px;
border: none;
color: white;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
transition: background 0.3s ease;
}
.switch-theme:hover {
background-color: #FB8C00;
}
.content {
max-width: 800px;
margin: 50px auto;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>
Website root!

<nav class="navbar">
<a href="index.html">Home</a>
<a href="blog/index.html">Blog</a>
<a href="contact/index.html">Contact</a>
<button class="switch-theme nav-right" onclick="toggleTheme()">Switch Theme</button>
</nav>

<div class="content">
<h1>Welcome to the Nature & Outdoors Blog</h1>
<p>Immerse yourself in the beauty of nature. Discover breathtaking landscapes, essential hiking tips, and the wonders of wildlife.</p>

<p>Our goal is to inspire adventure and share knowledge on preserving the great outdoors. From national parks to hidden gems, we've got it all.</p>

<p>Whether you're a seasoned explorer or a beginner, join us in appreciating the natural world like never before.</p>
</div>

<script>
function toggleTheme() {
const themeStyle = document.getElementById("theme-style");
themeStyle.href = themeStyle.href.includes("light-mode.css") ? "static/dark-mode.css" : "static/light-mode.css";
}
</script>

</body>
</html>
74 changes: 74 additions & 0 deletions samples/demo_website/www/index.html.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nature & Outdoors Blog</title>
<link id="theme-style" rel="stylesheet" href="static/light-mode.css">
<link id="theme-style" rel="stylesheet" href="static/dark-mode.css">
<style>
.navbar {
display: flex;
justify-content: center;
background-color: #4CAF50;
padding: 15px;
}
.navbar a {
color: white;
text-decoration: none;
padding: 15px 20px;
font-size: 18px;
}
.navbar a:hover {
background-color: rgba(255, 255, 255, 0.2);
border-radius: 5px;
}
.content {
max-width: 800px;
margin: 50px auto;
padding: 20px;
text-align: center;
}
.switch-theme {
background-color: #FFA726;
padding: 10px;
border: none;
color: white;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
transition: background 0.3s ease;
}
.switch-theme:hover {
background-color: #FB8C00;
}
</style>
</head>
<body>

<nav class="navbar">
<a href="home/index.html">Home</a>
<a href="blog/index.html">Blog</a>
<a href="contact/index.html">Contact</a>
</nav>

<div class="content">
<h1>Welcome to the Nature & Outdoors Blog</h1>
<p>Immerse yourself in the beauty of nature. Discover breathtaking landscapes, essential hiking tips, and the wonders of wildlife.</p>

<p>Our goal is to inspire adventure and share knowledge on preserving the great outdoors. From national parks to hidden gems, we've got it all.</p>

<p>Whether you're a seasoned explorer or a beginner, join us in appreciating the natural world like never before.</p>

<button class="switch-theme" onclick="toggleTheme()">Switch Theme</button>
</div>

<script>
function toggleTheme() {
const themeStyle = document.getElementById("theme-style");
themeStyle.href = themeStyle.href.includes("light-mode.css") ? "dark-mode.css" : "light-mode.css";
}
</script>

</body>
</html>
Binary file added samples/demo_website/www/static/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions samples/demo_website/www/static/dark-mode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
body {
font-family: 'Arial', sans-serif;
background-color: #1B1F22; /* Deep charcoal */
color: #E3E6D5; /* Soft cream text */
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: auto;
padding: 20px;
}

h1, h2, h3 {
color: #A5C882; /* Muted pastel green */
}

a {
color: #CFAE6D; /* Warm golden brown for links */
text-decoration: none;
transition: color 0.3s ease;
}

a:hover {
color: #E0C085; /* Lightened golden shade */
}

.button {
background-color: #689F38; /* Earthy green */
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s ease;
}

.button:hover {
background-color: #4E7931; /* Slightly darker green */
}
41 changes: 41 additions & 0 deletions samples/demo_website/www/static/light-mode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
body {
font-family: 'Arial', sans-serif;
background-color: #F8F5E1; /* Soft earthy tone */
color: #2E4B30; /* Deep forest green */
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: auto;
padding: 20px;
}

h1, h2, h3 {
color: #4D6B3C; /* Muted green for headers */
}

a {
color: #A15F34; /* Warm brown for links */
text-decoration: none;
transition: color 0.3s ease;
}

a:hover {
color: #C47C45; /* Lightened brown on hover */
}

.button {
background-color: #8BC34A; /* Nature-inspired green */
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s ease;
}

.button:hover {
background-color: #689F38; /* Slightly deeper green */
}
Loading