appeasing linux gods ?

This commit is contained in:
samcake 2016-05-12 14:50:41 -07:00
parent c6aeaf308b
commit 670826effc

View file

@ -188,36 +188,36 @@ int main (int argc, char** argv) {
std::ostringstream targetStringStream;
if (makeCPlusPlus) {
// Because there is a maximum size for literal strings declared in source we need to partition the
// full source string stream into pages that seems to be around that value...
const int MAX_STRING_LITERAL = 10000;
std::string lineToken;
auto pageSize = lineToken.length();
std::vector<std::shared_ptr<std::stringstream>> pages(1, std::make_shared<std::stringstream>());
while (!destStringStream.eof()) {
std::getline(destStringStream, lineToken);
auto lineSize = lineToken.length() + 1;
if (pageSize + lineSize > MAX_STRING_LITERAL) {
pages.push_back(std::make_shared<std::stringstream>());
// reset pageStringStream
pageSize = 0;
}
(*pages.back()) << lineToken << std::endl;
pageSize += lineSize;
}
targetStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl;
targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl;
targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl;
targetStringStream << "const char " << targetName << "[] = \n";
// Because there is a maximum size for literal strings declared in source we need to partition the
// full source string stream into pages that seems to be around that value...
const int MAX_STRING_LITERAL = 10000;
std::string lineToken;
auto pageSize = lineToken.length();
std::stringstream pageStringStream;
while (!destStringStream.eof()) {
std::getline(destStringStream, lineToken);
auto lineSize = lineToken.length() + 1;
if (pageSize + lineSize > MAX_STRING_LITERAL) {
targetStringStream << "R\"SCRIBE(\n" << pageStringStream.str() << "\n)SCRIBE\"\n";
// reset pageStringStream
pageStringStream = std::stringstream();
pageSize = 0;
}
pageStringStream << lineToken << std::endl;
pageSize += lineSize;
// Write the pages content
for (auto page : pages) {
targetStringStream << "R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\"\n";
}
// Write the last page content if reached eof
targetStringStream << "R\"SCRIBE(\n" << pageStringStream.str() << "\n)SCRIBE\"\n";
targetStringStream << ";\n" << std::endl << std::endl;
targetStringStream << "#endif" << std::endl;