// not very clean, but fast...
#define to_string(from, to, stringstream) \
stringstream.clear(); \
stringstream.str(""); \
stringstream << from; \
to = stringstream.str();
#define from_string(from, to, stringstream) \
stringstream.clear(); \
stringstream.str(from); \
stringstream >> to;
int main(int argc, char ** argv) {
int FOOTNOTE_HEADER_LEN = strlen(FOOTNOTE_HEADER);
int FOOTNOTE_ALLOWEDCHARS_LEN = strlen(FOOTNOTE_ALLOWEDCHARS);
ifstream input(argv[1]);
string line; // ... for reading from file
string strold; // old footnote as string
string strnew; // new footnote as string
string::size_type pos1 = 0;
string::size_type pos2 = 0;
bool found = false; // indicates whether we've found the footnote header
size_t last = 0; // last used footnote
size_t old = 0; // old footnote as number
std::vector<size_t> mapping(1024, 0); // mapping between old and new footnote numbers
stringstream ss; // for conversions (string <-> size_t)
// process input until footnote header has been found
while (!found && getline(input, line)) {
// check for footnote header
if (line.compare(0, FOOTNOTE_HEADER_LEN, FOOTNOTE_HEADER) == 0) {
found = true;
cout << line << endl;
continue;
}