began expanding Parser::write()

This commit is contained in:
Josh Holtrop 2010-04-29 15:51:01 -04:00
parent 6d3a5403c3
commit b7dab7f0a6

View File

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <pcre.h> #include <pcre.h>
#include <ctype.h> /* toupper() */
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@ -21,9 +22,26 @@ Parser::Parser()
void Parser::write(const string & fname) void Parser::write(const string & fname)
{ {
ofstream ofs(fname.c_str()); string header_fname = fname + ".h";
ofs << "Content goes here" << endl; string body_fname = fname + "." + m_extension;
ofs.close(); ofstream header(header_fname.c_str());
ofstream body(body_fname.c_str());
string ifndef_name = m_namespace + "_" + m_classname + "_classes_defined";
for (string::iterator i = ifndef_name.begin(); i != ifndef_name.end(); i++)
{
*i = toupper(*i);
}
header << "#ifndef " << ifndef_name << endl;
header << "#define " << ifndef_name << endl << endl;
header << "#endif /* #ifndef " << ifndef_name << " */" << endl;
body << "#include \"" << header_fname << "\"" << endl;
body << endl;
header.close();
body.close();
} }
bool Parser::parseInputFile(char * buff, int size) bool Parser::parseInputFile(char * buff, int size)