|
9 | 9 |
|
10 | 10 | namespace bin2cpp |
11 | 11 | { |
| 12 | + std::string& operator<<(std::string& str, const std::string & value) |
| 13 | + { |
| 14 | + str.append(value); |
| 15 | + return str; |
| 16 | + } |
| 17 | + |
| 18 | + std::string& operator<<(std::string& str, int value) |
| 19 | + { |
| 20 | + char buffer[1024]; |
| 21 | + sprintf(buffer, "%d", value); |
| 22 | + str.append(buffer); |
| 23 | + return str; |
| 24 | + } |
| 25 | + |
| 26 | + std::string& operator<<(std::string& str, uint64_t value) |
| 27 | + { |
| 28 | + std::stringstream out; |
| 29 | + out << value; |
| 30 | + str.append( out.str() ); |
| 31 | + return str; |
| 32 | + } |
12 | 33 |
|
13 | 34 | BaseGenerator::BaseGenerator() |
14 | 35 | { |
@@ -47,17 +68,30 @@ namespace bin2cpp |
47 | 68 | return cppPath; |
48 | 69 | } |
49 | 70 |
|
50 | | - bin2cpp::ErrorCodes BaseGenerator::createHeaderEmbededFile(const char * iHeaderFilePath, const char * iFunctionIdentifier) |
| 71 | + std::string BaseGenerator::getHeaderComments(const char * iInputFilename) |
| 72 | + { |
| 73 | + std::string filename = getFilename(iInputFilename); |
| 74 | + uint64_t fileDateModified = getFileModifiedDate(iInputFilename); |
| 75 | + |
| 76 | + std::string header; |
| 77 | + header << |
| 78 | + header << "/**\n"; |
| 79 | + header << " * This file was generated by bin2cpp v" << getVersionString() << "\n"; |
| 80 | + header << " * Copyright (C) 2013-" << bin2cpp::getCopyrightYear() << " end2endzone.com. All rights reserved.\n"; |
| 81 | + header << " * Source code for file '" << filename << "', last modified " << fileDateModified << ".\n"; |
| 82 | + header << " * Do not modify this file.\n"; |
| 83 | + header << " */\n"; |
| 84 | + return header; |
| 85 | + } |
| 86 | + |
| 87 | + bin2cpp::ErrorCodes BaseGenerator::createHeaderEmbededFile(const char * iInputFilename, const char * iHeaderFilePath, const char * iFunctionIdentifier) |
51 | 88 | { |
52 | 89 | FILE * header = fopen(iHeaderFilePath, "w"); |
53 | 90 | if (!header) |
54 | 91 | return bin2cpp::ErrorCodes::UnableToCreateOutputFiles; |
55 | 92 |
|
56 | | - fprintf(header, "/**\n"); |
57 | | - fprintf(header, " * This file was generated by bin2cpp v%s.\n", getVersionString() ); |
58 | | - fprintf(header, " * Copyright (C) 2013-%d end2endzone.com. All rights reserved.\n", bin2cpp::getCopyrightYear()); |
59 | | - fprintf(header, " * Do not modify this file.\n"); |
60 | | - fprintf(header, " */\n"); |
| 93 | + std::string headercomments = getHeaderComments(iInputFilename); |
| 94 | + fprintf(header, "%s", headercomments.c_str()); |
61 | 95 | fprintf(header, "#pragma once\n"); |
62 | 96 | fprintf(header, "#include <stddef.h>\n"); |
63 | 97 | fprintf(header, "namespace bin2cpp\n"); |
|
0 commit comments