From: Steve Brokenshire Date: Fri, 6 Nov 2015 20:05:09 +0000 (+0000) Subject: Removed out commented code for the Boost library & fixed line tab issues. X-Git-Tag: release-0.05~18 X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=commitdiff_plain;h=ba675a8314831779d6415311a7ea5d7558af9464 Removed out commented code for the Boost library & fixed line tab issues. --- diff --git a/source/tools/bitmapcode.cpp b/source/tools/bitmapcode.cpp index b5e6cf8..5130be8 100644 --- a/source/tools/bitmapcode.cpp +++ b/source/tools/bitmapcode.cpp @@ -2,8 +2,8 @@ // bitmapcode: Helper application which coverts PNG files into // C++ code outputting binary code. // -// This application also is a simple test if the wxWidgets & Boost -// header files and library files are there. +// This application also is a simple test if the wxWidgets header +// files and library files are there. // // This file is licenced under the GNU General Public License // version 3 only. (GPLv3 only). @@ -13,17 +13,12 @@ #include #include #include - -/*#include -#include -#include */ #include #include #include #include using namespace std; -//namespace boostfs = boost::filesystem; void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) { @@ -34,15 +29,10 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) // filename wxString of the filename. // counter Pointer to a integer counter. //------------------------------------------------------------------- - char pngfile_char; - int pageseek = 0; - /*boostfs::path PNGFilename(filename.c_str()); - boostfs::path CPPFilename = PNGFilename; - boostfs::path CPPFilenameOnly(CPPFilename.filename()); - boostfs::path DirFilename(dirfilename.c_str()); - boostfs::path DirFilenameOnly(DirFilename.filename()); - CPPFilename.replace_extension(".cpp");*/ - wxString outname; + + char pngfile_char; + int pageseek = 0; + wxString outname; wxString CPPFilename; CPPFilename = PNGFilename; CPPFilename.RemoveLast(4); @@ -77,46 +67,46 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) } - // Setup the PNG file reading and cpp file. + // Setup the PNG file reading and cpp file. - fstream cppfile, pngfile; + fstream cppfile, pngfile; #if defined(__WIN32__) - pngfile.open(PNGFilename.wc_str(), ios::in | ios::binary ); - cppfile.open(CPPFilename.wc_str(), ios::out | ios::trunc ); + pngfile.open(PNGFilename.wc_str(), ios::in | ios::binary ); + cppfile.open(CPPFilename.wc_str(), ios::out | ios::trunc ); # else - pngfile.open(PNGFilename.c_str(), ios::in | ios::binary ); - cppfile.open(CPPFilename.c_str(), ios::out | ios::trunc ); + pngfile.open(PNGFilename.c_str(), ios::in | ios::binary ); + cppfile.open(CPPFilename.c_str(), ios::out | ios::trunc ); #endif - outname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); - outname.Append(wxT("_")); - outname.Append(wxString::FromUTF8(CPPFilenameOnly.c_str())); - outname.MakeUpper(); + outname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); + outname.Append(wxT("_")); + outname.Append(wxString::FromUTF8(CPPFilenameOnly.c_str())); + outname.MakeUpper(); outname.RemoveLast(4); - // Setup the inclusion guard. + // Setup the inclusion guard. - cppfile << "#include " << endl << endl; - cppfile << "#ifndef " << outname.c_str() << "_CPP" << endl; - cppfile << "#define " << outname.c_str() << "_CPP" << endl << endl; + cppfile << "#include " << endl << endl; + cppfile << "#ifndef " << outname.c_str() << "_CPP" << endl; + cppfile << "#define " << outname.c_str() << "_CPP" << endl << endl; - outname.Clear(); - outname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); - outname.Append(wxT("_")); - outname.Append(wxString::FromUTF8(CPPFilenameOnly.c_str())); + outname.Clear(); + outname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); + outname.Append(wxT("_")); + outname.Append(wxString::FromUTF8(CPPFilenameOnly.c_str())); outname.RemoveLast(4); outname.Append(wxT("_png")); - outname.MakeLower(); + outname.MakeLower(); - // Convert the PNG file into an unsigned char array. + // Convert the PNG file into an unsigned char array. - cppfile << "static unsigned char " << outname.c_str() << - "[] = {" << endl; + cppfile << "static unsigned char " << outname.c_str() << + "[] = {" << endl; while (pngfile){ pngfile.get(pngfile_char); @@ -144,15 +134,15 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter) } - // End the file, close it and increment the counter. + // End the file, close it and increment the counter. - cppfile << "};" << endl << endl; - cppfile << "#endif" << endl << endl; - cppfile.close(); + cppfile << "};" << endl << endl; + cppfile << "#endif" << endl << endl; + cppfile.close(); - cout << "CPP\t" << CPPFilename.c_str() << endl; + cout << "CPP\t" << CPPFilename.c_str() << endl; - ++*counter; + ++*counter; } @@ -168,16 +158,11 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, // filelist wxArrayString of the directory filelist. // counter Pointer to a integer counter. //------------------------------------------------------------------- - /* boostfs::path HPPFilename(dirfilename.c_str()); - boostfs::path CPPFile; - boostfs::path CPPFileOnly(CPPFile.filename()); - boostfs::path DirFilename(dirfilename.c_str()); - boostfs::path DirFilenameOnly(DirFilename.filename()); - HPPFilename.replace_extension(".h");*/ - fstream hppfile; - - bool fmatch = FALSE; - wxString finaldirname; + + fstream hppfile; + + bool fmatch = FALSE; + wxString finaldirname; wxString HPPFilename = dirfilename.c_str(); wxString DirFilenameOnly; @@ -208,34 +193,34 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, } - // Make the directory filename upper case for writing to the - // header file. + // Make the directory filename upper case for writing to the + // header file. wxString CPPFileOnly; - finaldirname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); - finaldirname.MakeUpper(); + finaldirname.Append(wxString::FromUTF8(DirFilenameOnly.c_str())); + finaldirname.MakeUpper(); - // Write out the header file inclusion guard. + // Write out the header file inclusion guard. HPPFilename.Append(wxT(".h")); #if defined(__WIN32__) - hppfile.open(HPPFilename.wc_str(), ios::out | ios::trunc ); + hppfile.open(HPPFilename.wc_str(), ios::out | ios::trunc ); #else - hppfile.open(HPPFilename.c_str(), ios::out | ios::trunc ); + hppfile.open(HPPFilename.c_str(), ios::out | ios::trunc ); #endif - hppfile << "#include " << endl << endl; - hppfile << "#ifndef " << finaldirname.c_str() << "_H" << endl; - hppfile << "#define " << finaldirname.c_str() << "_H" << endl << endl; - hppfile << "// List all CPP files in the directory." << endl << endl; + hppfile << "#include " << endl << endl; + hppfile << "#ifndef " << finaldirname.c_str() << "_H" << endl; + hppfile << "#define " << finaldirname.c_str() << "_H" << endl << endl; + hppfile << "// List all CPP files in the directory." << endl << endl; - // Write each CPP file into the header file. + // Write each CPP file into the header file. for (int f = 0; f < filelist.GetCount() ; f++){ @@ -266,49 +251,30 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, "/" << CPPFileOnly.c_str() << "\"" << endl; } - - /*for (int f = 0; f < filelist.GetCount(); f++){ - boostfs::path CPPFile(filelist[f].c_str()); - boostfs::path CPPFileOnly(CPPFile.filename()); - CPPFileOnly.replace_extension(".cpp"); - - for (boostfs::path::iterator filet = CPPFile.begin(); - filet != CPPFile.end(); ++filet){ - if (*filet == DirFilename.filename()){ - fmatch = TRUE; - - } - if (fmatch == TRUE){ - - } - } - - hppfile << "#include \"" << DirFilenameOnly.c_str() << - "/" << CPPFileOnly.c_str() << "\"" << endl; - }*/ - // Write the end if and close the file. + // Write the end if and close the file. - hppfile << endl << "#endif" << endl << endl; - hppfile.close(); + hppfile << endl << "#endif" << endl << endl; + hppfile.close(); - // Increment the HPP file counter. + // Increment the HPP file counter. - cout << "HPPDIR\t" << HPPFilename.c_str() << endl; - ++*counter; + cout << "HPPDIR\t" << HPPFilename.c_str() << endl; + ++*counter; } int main(int argc, char *argv[]) { - int fp = 0; - int cppg = 0; - int hppg = 0; + + int fp = 0; + int cppg = 0; + int hppg = 0; - wxArrayString dirlist; - wxArrayString filelist; + wxArrayString dirlist; + wxArrayString filelist; wxString BitmapHeaderFilename; - wxString DirFilenameWxS; + wxString DirFilenameWxS; // Check if completed file exists before doing anything // else and write an error message if it does exist. @@ -323,17 +289,17 @@ int main(int argc, char *argv[]) } - fstream finalhppfile; + fstream finalhppfile; if (!argv[1]){ std::cout << "Error: No directory name given!" << std::endl; return -1; } - // Look in the subdirectories of the bitmaps directory and - // collect the names of the directories. + // Look in the subdirectories of the bitmaps directory and + // collect the names of the directories. - std::cout << "Working out directories in bitmaps directory..." << + std::cout << "Working out directories in bitmaps directory..." << std::endl; const char *dirarg = argv[1]; @@ -354,12 +320,7 @@ int main(int argc, char *argv[]) #endif - /*boostfs::path BitmapsDir(argv[1]); - boostfs::path BitmapsDirSubName; - boostfs::path BitmapsFilename; - boostfs::directory_iterator dir_end;*/ - - if ( wxDirExists(BitmapDirName) ){ + if ( wxDirExists(BitmapDirName) ){ wxDir BitmapDir(BitmapDirName); @@ -398,55 +359,40 @@ int main(int argc, char *argv[]) BitmapSubDirFull.Clear(); } - - /*for (boostfs::directory_iterator bitmapsidr_iter(BitmapsDir); - bitmapsidr_iter != dir_end; ++bitmapsidr_iter){ - - if (boostfs::is_directory(bitmapsidr_iter->status())){ - - BitmapsDirSubName = boostfs::path(bitmapsidr_iter->path()).filename(); - DirFilenameWxS.Append(wxString::FromUTF8(argv[1])); - DirFilenameWxS.Append(wxString::FromUTF8(BitmapsDirSubName.c_str())); - dirlist.Add(DirFilenameWxS, 1); - DirFilenameWxS = wxT(""); - - } - - }*/ } else { std::cout << "Error: Bitmaps Directory doesn't exist!" << std::endl; return 1; } - // Process each directory, generating a .cpp and .hpp file - // for each image and then a final .hpp for the directory - // containing the .hpp's for the directories. + // Process each directory, generating a .cpp and .hpp file + // for each image and then a final .hpp for the directory + // containing the .hpp's for the directories. if (dirlist.GetCount() == 0){ cout << "Error: No directories in the bitmaps folder. Unexpected behaviour!" << endl; return 1; } - std::cout << "Looking in bitmaps folder for PNGs..." << std::endl; + std::cout << "Looking in bitmaps folder for PNGs..." << std::endl; - DirFilenameWxS.Empty(); + DirFilenameWxS.Empty(); std::cout << BitmapHeaderFilename.c_str() << std::endl; #if defined(__WIN32__) - finalhppfile.open(BitmapHeaderFilename.wc_str(), ios::out | ios::trunc); + finalhppfile.open(BitmapHeaderFilename.wc_str(), ios::out | ios::trunc); #else - finalhppfile.open(BitmapHeaderFilename.c_str(), ios::out | ios::trunc); + finalhppfile.open(BitmapHeaderFilename.c_str(), ios::out | ios::trunc); #endif - finalhppfile << "#include " << endl << endl; - finalhppfile << "#ifndef BITMAPS_H" << endl; - finalhppfile << "#define BITMAPS_H" << endl << endl; + finalhppfile << "#include " << endl << endl; + finalhppfile << "#ifndef BITMAPS_H" << endl; + finalhppfile << "#define BITMAPS_H" << endl << endl; for (int bi = 0; bi < dirlist.GetCount(); bi++) { @@ -460,6 +406,7 @@ int main(int argc, char *argv[]) while (ContinueProcess){ if (BitmapFilename.Right(4) == wxT(".PNG") || + BitmapFilename.Right(4) == wxT(".png")){ #if defined(__HAIKU__) @@ -490,37 +437,19 @@ int main(int argc, char *argv[]) } - /*boostfs::path BitmapsSubDir(dirlist[bi].c_str()); - for (boostfs::directory_iterator bitmapsidr_iter(BitmapsSubDir); - bitmapsidr_iter != dir_end; - ++bitmapsidr_iter){ - - if (boostfs::path(bitmapsidr_iter->path()).extension() == ".png" || - boostfs::path(bitmapsidr_iter->path()).extension() == ".PNG"){ - - BitmapsFilename = boostfs::path(bitmapsidr_iter->path()).filename(); - DirFilenameWxS.Append(wxString::FromUTF8(dirlist[bi].mb_str())); - DirFilenameWxS.Append(wxString::FromUTF8("/")); - DirFilenameWxS.Append(wxString::FromUTF8(BitmapsFilename.c_str())); - - filelist.Add(DirFilenameWxS, 1); - DirFilenameWxS = wxT(""); - - - - } - - }*/ - for (int fi = 0; fi < filelist.GetCount(); fi++) { + CreateCPPFile(dirlist[bi].wc_str(), filelist[fi].wc_str(), &cppg); fp++; + } if (filelist.GetCount() > 0) { + CreateHPPFileDir(dirlist[bi].wc_str(), filelist, &hppg); + } filelist.Clear(); @@ -562,16 +491,16 @@ int main(int argc, char *argv[]) } - finalhppfile << endl << "#endif" << endl; - finalhppfile.close(); - ++hppg; + finalhppfile << endl << "#endif" << endl; + finalhppfile.close(); + ++hppg; - // Print out the results. + // Print out the results. - std::cout << "Finished processing PNGs into code." << std::endl; - std::cout << fp << " files processed." << std::endl; - std::cout << cppg << " .cpp files generated." << std::endl; - std::cout << hppg << " .hpp files generated." << std::endl; + std::cout << "Finished processing PNGs into code." << std::endl; + std::cout << fp << " files processed." << std::endl; + std::cout << cppg << " .cpp files generated." << std::endl; + std::cout << hppg << " .hpp files generated." << std::endl; // Write a success flag so that future runs won't take // place thus speeding up the compilation process as @@ -583,6 +512,6 @@ int main(int argc, char *argv[]) bitmapflag << "Bitmaps as code generated. To recreate, simply delete this file and run the bitmap code generation tool again." << endl; bitmapflag.close(); - return 0; + return 0; }