Write the content of buf to jsonfile between prevIdx (inclusive) and idx (not * inclusive). * * This function is used to help deal with escaped characters with a low number * of write calls. This is meant to be used like so: the caller inspects every * character in a buffer, doing one of two things with each character: * * - The character does not need to be escaped. In this case, no call
| 62 | * @param[out] jsonfile The stream to conditionally write buffer content to. |
| 63 | */ |
| 64 | inline void |
| 65 | write_buffered_context(char const *buf, int64_t &prevIdx, int64_t idx, std::ostream &jsonfile) |
| 66 | { |
| 67 | if (prevIdx < idx) { |
| 68 | jsonfile.write(buf + prevIdx, idx - prevIdx); |
| 69 | } |
| 70 | prevIdx = idx + 1; |
| 71 | } |
| 72 | |
| 73 | int |
| 74 | esc_json_out(const char *buf, int64_t len, std::ostream &jsonfile) |