Skip to content

Commit d06b863

Browse files
committed
Fixed issue #1: Update README file
1 parent 239ba03 commit d06b863

File tree

1 file changed

+128
-19
lines changed

1 file changed

+128
-19
lines changed

README.md

Lines changed: 128 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ It is designed to be easy to use by developers and to provide easy call function
2929

3030
The generated functions that reads and extracts the embedded content does not rely on external libraries so you don't need to setup your projects to use any third party library to start using bin2cpp. All your embedded data can be accessed right away.
3131

32-
# Usage
32+
# Command Line Usage
3333

3434
**Usage:** bin2cpp [input file] [output folder] [header filename] [function identifier] [chunk size] [-override].
3535

@@ -46,6 +46,7 @@ The generated functions that reads and extracts the embedded content does not
4646
# Example
4747

4848
### Input File:
49+
html5skeleton.html
4950
```html
5051
<!DOCTYPE html>
5152
<html lang="en">
@@ -182,6 +183,124 @@ namespace bin2cpp
182183
}; //bin2cpp
183184
```
184185

186+
### Code sample
187+
```cpp
188+
#include <stdio.h>
189+
#include <string>
190+
#include "base64.h"
191+
#include "resourcehtml5skeleton.h" //a single include file is all you need
192+
193+
int main(int argc, char* argv[])
194+
{
195+
//get a reference to the embedded file
196+
const bin2cpp::File & resource = bin2cpp::getHtmlSampleFile();
197+
198+
//print information about the file.
199+
printf("Embedded file '%s' is %d bytes long.\n", resource.getFilename(), resource.getSize());
200+
printf("The MD5 of the file is %s.\n", resource.getMd5());
201+
202+
//Saving content back to a file.
203+
printf("Saving embedded file to 'html5skeleton_copy.html'...\n");
204+
bool saved = resource.save("html5skeleton_copy.html");
205+
if (saved)
206+
printf("saved\n");
207+
else
208+
printf("failed\n");
209+
210+
//encoding content as base64
211+
char * buffer = resource.newBuffer(); //returns a new buffer with a copy of the file. Ownership is transfered to the local function
212+
size_t bufferSize = resource.getSize();
213+
std::string encodedFile = toBase64(buffer, bufferSize); //binary to base64 encoder
214+
delete buffer; //delete allocatd buffer from newBuffer()
215+
buffer = NULL;
216+
217+
//do something with the base64 encoded file
218+
//...
219+
220+
return 0;
221+
}
222+
```
223+
224+
# Installing
225+
226+
This section explains how to compile and build the software and how to get a development environment running.
227+
228+
## Compatible with
229+
230+
bin2cpp is only available for the Windows platform and has been tested with the following version of Windows:
231+
232+
* Windows XP
233+
* Windows Vista
234+
* Windows 7
235+
236+
## Prerequisites
237+
238+
The following software must be installed on the system for compiling source code:
239+
240+
* Visual Studio 2010 (or newer) (There are plans to migrate the software to other platform. See [issue #9](https://github.com/end2endzone/bin2cpp/issues/9))
241+
* [Google Test v1.6.0](https://github.com/google/googletest/tree/release-1.6.0) (untested with other versions)
242+
* [CMake](http://www.cmake.org/) for compilation of Google Test library. (Tested with CMake 3.9.6)
243+
* [bin2cpp source code](https://github.com/end2endzone/bin2cpp)
244+
245+
## Build steps
246+
247+
### Google Test
248+
249+
1) Download googletest source code to your computer using one of the following:
250+
1) Download googletest as a [zip file](https://github.com/google/googletest/archive/release-1.6.0.zip) and extract to a temporary directory (for example c:\projects\third_party\googletest).
251+
2) Clone the git repository using the following commands:
252+
* git clone https://github.com/google/googletest.git c:\projects\third_party\googletest
253+
* cd /d c:\projects\third_party\googletest
254+
* git checkout release-1.6.0
255+
256+
2) Generate googletest Visual Studio 2010 solution using cmake. Enter the following commands:
257+
* cd c:\projects\third_party\googletest
258+
* mkdir msvc2010
259+
* cd msvc2010
260+
* cmake -G "Visual Studio 10 2010" -Dgtest_force_shared_crt=ON -DCMAKE_CXX_FLAGS_DEBUG=/MDd -DCMAKE_CXX_FLAGS_RELEASE=/MD "c:\projects\third_party\googletest"
261+
262+
3) Open the generated Visual Studio 2010 solution file located in
263+
***c:\projects\third_party\googletest\msvc2010\gtest.sln***
264+
265+
### Define environment variables
266+
Note: this step need to be executed once.
267+
268+
bin2cpp needs to know where the libraries of googletest are located (debug & release).
269+
Define the following environement variables:
270+
271+
| Name | Value |
272+
|--------------------------|----------------------------------------------|
273+
| GTEST_DEBUG_LIBRARIES | gtest.lib |
274+
| GTEST_RELEASE_LIBRARIES | gtest.lib |
275+
| GTEST_INCLUDE | c:\projects\third_party\googletest\include |
276+
| GTEST_LIBRARY_DIR | c:\projects\third_party\googletest\msvc2010 |
277+
278+
### bin2cpp
279+
280+
1) Download the [bin2cpp source code](https://github.com/end2endzone/bin2cpp/tags) and extract the content to a temporary directory (for example c:\projects\bin2cpp).
281+
282+
2) Open the Visual Studio 2010 solution file located in
283+
***c:\projects\bin2cpp\msvc\bin2cpp.sln***
284+
285+
## Testing
286+
bin2cpp comes with unit tests which tests for multiple combinations to make sure that input files are always encoded without errors.
287+
288+
Test are build using the Google Test v1.6.0 framework. For more information on how googletest is working, see the [google test documentation primer](https://github.com/google/googletest/blob/release-1.8.0/googletest/docs/V1_6_Primer.md).
289+
290+
Test are automatically build when building the solution. Please see the '*build step*' section for details on how to build the software.
291+
292+
Test can be executed from the following two locations:
293+
294+
1) From the Visual Studio IDE:
295+
1) Select the project '*bin2cpp_unittest*' as StartUp project.
296+
2) Hit CTRL+F5 (Start Without Debugging)
297+
2) From the output binaries folder:
298+
1) Open a file navigator and browse to the output folder(for example c:\projects\bin2cpp\msvc\Win32\Release)
299+
2) Run the '*generate_test_files.bat*' batch script. The script will generate all required input files.
300+
3) Run the '*bin2cpp_unittest.exe*'
301+
302+
See also the latest test results at the beginning of the document.
303+
185304
# Screenshots
186305
187306
bin2cpp v1.3 Sample[![bin2cpp v1.3 Sample](http://www.end2endzone.com/wp-content/uploads/2015/01/bin2cpp-v1.3-done.png)](http://www.end2endzone.com/wp-content/uploads/2015/01/bin2cpp-v1.3-done.png)
@@ -196,27 +315,17 @@ bin2cpp is only available for the Windows platform and has been tested with the
196315
* Windows XP
197316
* Windows Vista
198317
* Windows 7
318+
319+
# Versioning
199320
200-
# License
321+
We use [Semantic Versioning 2.0.0](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/end2endzone/bin2cpp/tags).
201322
202-
MIT License
323+
# Authors
203324
204-
Copyright (c) 2017 end2endzone
325+
* **Antoine Beauchamp** - *Initial work* - [end2endzone](https://github.com/end2endzone)
205326
206-
Permission is hereby granted, free of charge, to any person obtaining a copy
207-
of this software and associated documentation files (the "Software"), to deal
208-
in the Software without restriction, including without limitation the rights
209-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
210-
copies of the Software, and to permit persons to whom the Software is
211-
furnished to do so, subject to the following conditions:
327+
See also the list of [contributors](https://github.com/end2endzone/bin2cpp/blob/master/AUTHORS) who participated in this project.
212328
213-
The above copyright notice and this permission notice shall be included in all
214-
copies or substantial portions of the Software.
329+
# License
215330
216-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
217-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
218-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
219-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
220-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
221-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
222-
SOFTWARE.
331+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

0 commit comments

Comments
 (0)