Ok, here's the deal. I have a program that records in Python. I wanted this log to be protected from changes when the program does not use it, so I wrote a python script that creates a C ++ source, designed to retype the log in Python. Once I compile this source, I can make the log quite secure, and then just run the executable to get it. Its confusing but it works
Problem: . When I create a Python log, I replace the 'equivalent literal ( \') so that it does not break my lines when they are saved. But, when I pick it up with C ++ and it rolls back, I lose the literal, so I get broken lines. There is an easy way to replace 'C ++ with the appropriate literal, similar to a function replacein Python.
Some snippets of code that may help:
How do I write a string in a log in Python
logFile.write(" '{}'".format(somestring.replace("'","\\'").encode('ascii', 'ignore'))
What the Python log looks like:
CRDict = {"ID number string":[list of a bunch of items], "Another ID number: [Another list of things]}
How do I write C ++ lines that store lines from a log in Python (where CR {} is struct)
CFile.write(' CR{}.somestring = "{}";\n'.format(num,somestring))
What C ++ string that stores the string looks like
CR0.somestring = "This is a string and it doesn't keep track of literals";
C ++ line that writes a string back to Python (file called CRPYLog)
CRPYLog << " '" + CR0.somestring + "'," << endl;
And this is what the string looks like when it returns to the Python log
'This is a string and it doesn't keep track of literals'
, , Python