Thursday, December 12, 2019

File concatenation tool made big progress

The file concatenation tool made a huge progress yesterday. I was able to parse all interfaces and its implementations into one single header, currently this is just a working prototype, it is big in file size. My next step in to implement filtering to remove files that has already been included.

Here is a code that preprocesses each file (i.e. replacing hpp with its content):

void DotHFile::Preprocess()
{
for (size_t i = 0; i < includeFiles.size(); ++i)
includeFiles[i]->Preprocess();
unsigned int index = 0;
std::string newRawData = rawData;
for (auto iter = std::sregex_iterator(rawData.begin(), rawData.end(), rgexInclude); iter != std::sregex_iterator(); ++iter)
{
std::smatch match = *iter;
std::string lineString = match.str(0);
std::regex regex(lineString);
newRawData = std::regex_replace(newRawData, regex, includeFiles[index++]->GetRawData());
}
rawData.clear();
rawData = newRawData;
}

No comments:

Post a Comment