@@ -22,15 +22,15 @@ namespace bin2cpp
2222 return " array" ;
2323 }
2424
25- bool ArrayGenerator::createCppSourceFile (const char * iInputFilename, const char * iCppFilePath, const char * iFunctionIdentifier, size_t iChunkSize, const char * iNamespace, const char * iBaseClass )
25+ bool ArrayGenerator::createCppSourceFile (const char * iCppFilePath)
2626 {
2727 // check if input file exists
28- FILE * input = fopen (iInputFilename , " rb" );
28+ FILE * input = fopen (mInputFile . c_str () , " rb" );
2929 if (!input)
3030 return false ;
3131
3232 // Uppercase function identifier
33- std::string functionIdentifier = iFunctionIdentifier ;
33+ std::string functionIdentifier = mFunctionIdentifier ;
3434 functionIdentifier[0 ] = (char )toupper (functionIdentifier[0 ]);
3535
3636 // Build header and cpp file path
@@ -49,43 +49,43 @@ namespace bin2cpp
4949
5050 // determine file properties
5151 long fileSize = getFileSize (input);
52- std::string filename = getFilename (iInputFilename );
52+ std::string filename = getFilename (mInputFile . c_str () );
5353
5454 // Build class name
5555 std::string className;
5656 className.append (functionIdentifier.c_str ());
5757 className.append (" File" );
5858
5959 // Build function
60- std::string getterFunctionName = getGetterFunctionName (functionIdentifier. c_str () );
60+ std::string getterFunctionName = getGetterFunctionName ();
6161
6262 // write cpp file heading
63- fprintf (cpp, " %s" , getFileHeading (iInputFilename ).c_str ());
63+ fprintf (cpp, " %s" , getHeaderTemplate ( ).c_str ());
6464 fprintf (cpp, " #include \" %s\"\n " , headerFilename.c_str () );
6565 fprintf (cpp, " #include <stdio.h> //for FILE\n " );
6666 fprintf (cpp, " #include <string> //for memcpy\n " );
67- fprintf (cpp, " namespace %s\n " , iNamespace );
67+ fprintf (cpp, " namespace %s\n " , mNamespace . c_str () );
6868 fprintf (cpp, " {\n " );
69- fprintf (cpp, " class %s : public virtual %s::%s\n " , className.c_str (), iNamespace, iBaseClass );
69+ fprintf (cpp, " class %s : public virtual %s::%s\n " , className.c_str (), mNamespace . c_str (), mBaseClass . c_str () );
7070 fprintf (cpp, " {\n " );
7171 fprintf (cpp, " public:\n " );
7272 fprintf (cpp, " %s() {}\n " , className.c_str ());
7373 fprintf (cpp, " ~%s() {}\n " , className.c_str ());
7474 fprintf (cpp, " virtual size_t getSize() const { return %d; }\n " , fileSize);
75- fprintf (cpp, " virtual const char * getFilename() const { return \" %s\" ; }\n " , getFilename (iInputFilename ).c_str ());
75+ fprintf (cpp, " virtual const char * getFilename() const { return \" %s\" ; }\n " , getFilename (mInputFile . c_str () ).c_str ());
7676 fprintf (cpp, " virtual const char * getBuffer() const\n " );
7777 fprintf (cpp, " {\n " );
7878 fprintf (cpp, " static const unsigned char buffer[] = {\n " );
7979
8080 // create buffer for each chunks from input buffer
8181 int numLinePrinted = 0 ;
82- unsigned char * buffer = new unsigned char [iChunkSize ];
82+ unsigned char * buffer = new unsigned char [mChunkSize ];
8383 while (!feof (input))
8484 {
8585 // read a chunk of the file
86- size_t readSize = fread (buffer, 1 , iChunkSize , input);
86+ size_t readSize = fread (buffer, 1 , mChunkSize , input);
8787
88- bool isLastChunk = !(readSize == iChunkSize );
88+ bool isLastChunk = !(readSize == mChunkSize );
8989
9090 if (readSize > 0 )
9191 {
@@ -113,10 +113,10 @@ namespace bin2cpp
113113 // write cpp file footer
114114 fprintf (cpp, " return (const char *)buffer;\n " );
115115 fprintf (cpp, " }\n " );
116- fprintf (cpp, " %s" , getSaveMethodImplementation ().c_str ());
116+ fprintf (cpp, " %s" , getSaveMethodTemplate ().c_str ());
117117 fprintf (cpp, " };\n " );
118- fprintf (cpp, " const %s & %s() { static %s _instance; return _instance; }\n " , iBaseClass , getterFunctionName.c_str (), className.c_str ());
119- fprintf (cpp, " }; //%s\n " , iNamespace );
118+ fprintf (cpp, " const %s & %s() { static %s _instance; return _instance; }\n " , mBaseClass . c_str () , getterFunctionName.c_str (), className.c_str ());
119+ fprintf (cpp, " }; //%s\n " , mNamespace . c_str () );
120120
121121 fclose (input);
122122 fclose (cpp);
0 commit comments