@@ -150,8 +150,7 @@ Hello World!
150150### Command:
151151
152152```
153- bin2cpp.exe --file=helloworld.html --output=.\outdir --headerfile=generated_helloworld.h
154- --identifier=HelloWorldHtml --chunksize=50
153+ bin2cpp.exe --file=helloworld.html --output=.\outdir
155154```
156155
157156
@@ -161,13 +160,13 @@ bin2cpp.exe --file=helloworld.html --output=.\outdir --headerfile=generated_hell
161160bin2cpp v3.0.0 - Convert binary files into C++ source code.
162161Copyright (C) 2013-2021 end2endzone.com. All rights reserved.
163162bin2cpp is open source software, see http://github.com/end2endzone/bin2cpp
164- Embedding "helloworld.html" using chunks of 50 bytes ...
165- Writing file ".\outdir\generated_helloworld .h"...
166- Writing file ".\outdir\generated_helloworld .cpp"...
163+ Embedding "helloworld.html"...
164+ Writing file ".\outdir\helloworld .h"...
165+ Writing file ".\outdir\helloworld .cpp"...
167166```
168167
169168
170- ### Output file: generated_helloworld .h
169+ ### Output file: helloworld .h
171170
172171``` cpp
173172/* *
@@ -177,8 +176,8 @@ Writing file ".\outdir\generated_helloworld.cpp"...
177176 * Source code for file 'helloworld.html', last modified 1548537787.
178177 * Do not modify this file.
179178 */
180- #ifndef GENERATED_HELLOWORLD_H
181- #define GENERATED_HELLOWORLD_H
179+ #ifndef HELLOWORLD_H
180+ #define HELLOWORLD_H
182181
183182#include <stddef.h>
184183
@@ -197,14 +196,14 @@ namespace bin2cpp
197196 virtual bool save(const char * filename) const = 0;
198197 };
199198 #endif // BIN2CPP_EMBEDDEDFILE_CLASS
200- const File & getHelloWorldHtmlFile ();
199+ const File & getHelloworldhtmlFile ();
201200}; // bin2cpp
202201
203- #endif // GENERATED_HELLOWORLD_H
202+ #endif // HELLOWORLD_H
204203```
205204
206205
207- ### Output file: generated_helloworld .cpp
206+ ### Output file: helloworld .cpp
208207
209208``` cpp
210209/* *
@@ -217,17 +216,17 @@ namespace bin2cpp
217216#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
218217#define _ CRT_SECURE_NO_WARNINGS
219218#endif
220- #include " generated_helloworld .h"
219+ #include " helloworld .h"
221220#include < string> // for std::string
222221#include < iostream>
223222#include < fstream> // for ofstream
224223namespace bin2cpp
225224{
226- class HelloWorldHtmlFile : public virtual bin2cpp::File
225+ class HelloworldhtmlFile : public virtual bin2cpp::File
227226 {
228227 public:
229- HelloWorldHtmlFile () { build(); }
230- virtual ~ HelloWorldHtmlFile () {}
228+ HelloworldhtmlFile () { build(); }
229+ virtual ~ HelloworldhtmlFile () {}
231230 virtual size_t getSize() const { return 238; }
232231 virtual const char * getFileName() const { return "helloworld.html"; }
233232 virtual const char * getFilePath() const { return getFileName(); }
@@ -236,15 +235,12 @@ namespace bin2cpp
236235 {
237236 mBuffer.clear();
238237 mBuffer.reserve(getSize()); //allocate all required memory at once to prevent reallocations
239- mBuffer.append("<! DOCTYPE html> \r\n<html lang=\" en\" >\r\n<head >\r\n <meta", 50);
240- mBuffer.append(" charset=\" utf-8\" >\r\n <meta name=\" viewport\" content", 50);
241- mBuffer.append("=\" width=device-width, initial-scale=1, user-scalab", 50);
242- mBuffer.append("le=yes\" >\r\n <title >Hello World!</title >\r\n</head >\r\n", 50);
238+ mBuffer.append("<! DOCTYPE html> \r\n<html lang=\" en\" >\r\n<head >\r\n <meta charset=\" utf-8\" >\r\n <meta name=\" viewport\" content=\" width=device-width, initial-scale=1, user-scalable=yes\" >\r\n <title >Hello World!</title >\r\n</head >\r\n", 200);
243239 mBuffer.append("<body >\r\nHello World!\r\n</body >\r\n</html >", 38);
244240 }
245241 virtual bool save(const char * filename) const
246242 {
247- std::ofstream f(filename, std::ios::out | std::ios::binary);
243+ std::ofstream f(filename, std::ios::out | std::ios::binary | std::ios::trunc );
248244 if (f.fail()) return false;
249245 size_t fileSize = getSize();
250246 const char * buffer = getBuffer();
@@ -255,7 +251,7 @@ namespace bin2cpp
255251 private:
256252 std::string mBuffer;
257253 };
258- const File & getHelloWorldHtmlFile () { static HelloWorldHtmlFile _ instance; return _ instance; }
254+ const File & getHelloworldhtmlFile () { static HelloworldhtmlFile _ instance; return _ instance; }
259255}; // bin2cpp
260256```
261257
@@ -268,12 +264,13 @@ At runtime, show file properties and save/export data back to a file.
268264#include < stdio.h>
269265#include < string>
270266#include < iostream>
271- #include " generated_helloworld.h" // a single include file is all you need
267+
268+ #include " helloworld.h" // a single include file is all you need
272269
273270int main (int argc, char* argv[ ] )
274271{
275272 //get a reference to the embedded file
276- const bin2cpp::File & resource = bin2cpp::getHelloWorldHtmlFile ();
273+ const bin2cpp::File & resource = bin2cpp::getHelloworldhtmlFile ();
277274
278275 //print information about the file.
279276 std::cout << "Embedded file '" << resource.getFileName() << "' is " << resource.getSize() << " bytes long.\n";
0 commit comments