MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / binaryCaseProcess

Function binaryCaseProcess

src/library/tools/tplgen/tplgen.cpp:38–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36using namespace std;
37
38void binaryCaseProcess(const string &inputStr, std::ostream &outFile)
39{
40 //Get the binary location in fileName
41 size_t found = inputStr.find( '@' );
42 string fileName = inputStr.substr (found+1);
43
44 //Open the binary
45 std::ifstream file (fileName.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
46 size_t fileSize;
47 if(!file.is_open())
48 {
49 std::cerr << "fail to open binary file '" << fileName << "'" << std::endl;
50 exit(1);
51 }
52
53 //Get contents of the binary
54 char* fileContents;
55 fileSize = file.tellg();
56 fileContents = new char[fileSize];
57 file.seekg(0, std::ios::beg);
58 if(!file.read(fileContents, fileSize))
59 {
60 std::cerr << "fail to read binary file '" << fileName << "'" << std::endl;
61 exit(1);
62 }
63 file.close();
64
65
66 outFile << "//generated from the binary: " << fileName << "\n";
67
68 //Copy the chars found before the @
69 outFile << inputStr.substr (0,found);
70
71 //Write contents of the binary
72 outFile << "[" << fileSize << "] = {\n";
73 for(int i=0; i < fileSize; i++)
74 {
75 outFile << (int) fileContents[i];
76 if(i < fileSize-1) outFile << ",";
77 if((i+1)%50 == 0) outFile << "\n";
78 }
79 outFile << "\n};\n";
80}
81
82
83bool isModified( char *clFile, char *clTFile )

Callers 1

mainFunction · 0.85

Calls 2

findMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected