Skip to content

Commit cc6bcc9

Browse files
committed
* Fixed ci/appveyor/version_info_update.bat script which was hardcoding application number to v1.2.3
* Modified output of testfilegenerator to only show size in other units if size is > than 1024 bytes * Modified output of bin2cpp to not show "into file 'foo.h'" which is not required if the next 2 lines says 'writing file foo.h'.
1 parent e7042aa commit cc6bcc9

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

ci/appveyor/version_info_update.bat

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ echo REPOSITORY_ROOT=%REPOSITORY_ROOT%
1010
echo done.
1111
echo.
1212

13-
set APPVEYOR_BUILD_VERSION=1.2.3
14-
1513
REM **************** version_info.bat ****************
1614
set OUTPUTFILE=%REPOSITORY_ROOT%\version_info.bat
1715
echo Updating %OUTPUTFILE%...

src/common.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ namespace bin2cpp
467467
return str;
468468
}
469469

470+
std::string& operator<<(std::string& str, const size_t & value)
471+
{
472+
std::stringstream out;
473+
out << value;
474+
str.append( out.str() );
475+
return str;
476+
}
477+
470478
std::string& operator<<(std::string& str, const uint64_t & value)
471479
{
472480
std::stringstream out;

src/common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ namespace bin2cpp
181181
///<return>Returns the given string.<return>
182182
std::string& operator<<(std::string& str, const int & value);
183183

184+
///<summary>
185+
///Streams a value to an existing string.
186+
///</summary>
187+
///<param name="value">The value to append to the given string.</param>
188+
///<return>Returns the given string.<return>
189+
std::string& operator<<(std::string& str, const size_t & value);
190+
184191
///<summary>
185192
///Streams a value to an existing string.
186193
///</summary>

src/main.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <windows.h>
2424
#endif
2525

26+
using namespace bin2cpp;
27+
2628
void printHeader()
2729
{
2830
printf("bin2cpp v%s - Convert binary files into C++ source code.\n", bin2cpp::getVersionString() );
@@ -194,20 +196,19 @@ int main(int argc, char* argv[])
194196
}
195197

196198
// printing info
197-
std::string chunkInfo = "";
199+
std::string info;
200+
info << "Embedding \"" << inputFile << "\"";
198201
if (chunkSize != DEFAULT_CHUNK_SIZE)
199202
{
200-
std::stringstream ss;
201-
ss << " using chunks of ";
202-
ss << chunkSize;
203-
ss << " bytes";
204-
chunkInfo.append(ss.str());
203+
info << " using chunks of ";
204+
info << chunkSize;
205+
info << " bytes";
205206
}
206-
std::string overrideInfo = "";
207207
if (overrideExisting)
208-
overrideInfo = " overriding existing files";
209-
bin2cpp::log(bin2cpp::LOG_INFO, "Embedding \"%s\" into \"%s\"%s%s...", inputFile.c_str(), headerFilename.c_str(), chunkInfo.c_str(), overrideInfo.c_str());
210-
208+
info << " overriding existing files";
209+
info << "...";
210+
bin2cpp::log(bin2cpp::LOG_INFO, info.c_str());
211+
211212
//generate header
212213
std::string outputHeaderPath = outputFolder + "\\" + headerFilename;
213214
bin2cpp::log(bin2cpp::LOG_INFO, "Writing file \"%s\"...", outputHeaderPath.c_str());

test/testfilegenerator.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@
1111
#include "common.h"
1212
#include "..\version_info.h"
1313

14+
using namespace bin2cpp;
15+
1416
const char * getVersionString()
1517
{
1618
return BINCPP_VERSION;
1719
}
1820

21+
std::string getSizeAdditionalInfo(int size)
22+
{
23+
std::string output;
24+
if (size > 1024)
25+
{
26+
output << " (" << getUserFriendlySize(size) << ")";
27+
}
28+
return output;
29+
}
30+
1931
void printVersion()
2032
{
2133
printf("testfilegenerator v%s\n", bin2cpp::getVersionString() );
@@ -152,10 +164,9 @@ int main(int argc, char **argv)
152164
}
153165

154166
//building info string
155-
static const int BUFFER_SIZE = 4096;
156-
char infostr[BUFFER_SIZE];
157-
sprintf(infostr, "Writing %d bytes (%s) of %s data into '%s'.", size, bin2cpp::getUserFriendlySize(size).c_str(), fill.c_str(), file.c_str());
158-
bin2cpp::log(bin2cpp::LOG_INFO, "%s", infostr);
167+
std::string infostr;
168+
infostr << "Writing " << size << " bytes" << getSizeAdditionalInfo(size) << " of " << fill << " data into \'" << file << "\'.";
169+
bin2cpp::log(bin2cpp::LOG_INFO, "%s", infostr.c_str());
159170

160171
//process with file generation
161172
FILE * f = fopen(file.c_str(), "wb");

0 commit comments

Comments
 (0)