static string showErrorContext(const XmlException &e, const char *query) { ostringstream msg; msg << e.what(); if(e.getQueryLine() != 0 && e.getQueryFile() == 0) { msg << endl; int line = 1; while(line != e.getQueryLine() && *query != 0) { if(*query == '\n' || (*query == '\r' && *(query + 1) != '\n')) ++line; ++query; } if(line == e.getQueryLine()) { while(*query != 0) { msg << (*query); if(*query == '\n' || (*query == '\r' && *(query + 1) != '\n')) break; ++query; } if(e.getQueryColumn() != 0) { if(*query == 0) msg << endl; msg << string(e.getQueryColumn() - 1, ' ') << "^"; } } } return msg.str(); }