| 3204 | } |
| 3205 | |
| 3206 | void write(const char_t* data, size_t length) |
| 3207 | { |
| 3208 | if (bufsize + length > bufcapacity) |
| 3209 | { |
| 3210 | // flush the remaining buffer contents |
| 3211 | flush(); |
| 3212 | |
| 3213 | // handle large chunks |
| 3214 | if (length > bufcapacity) |
| 3215 | { |
| 3216 | if (encoding == get_write_native_encoding()) |
| 3217 | { |
| 3218 | // fast path, can just write data chunk |
| 3219 | writer.write(data, length * sizeof(char_t)); |
| 3220 | return; |
| 3221 | } |
| 3222 | |
| 3223 | // need to convert in suitable chunks |
| 3224 | while (length > bufcapacity) |
| 3225 | { |
| 3226 | // get chunk size by selecting such number of characters that are guaranteed to fit into scratch buffer |
| 3227 | // and form a complete codepoint sequence (i.e. discard start of last codepoint if necessary) |
| 3228 | size_t chunk_size = get_valid_length(data, bufcapacity); |
| 3229 | |
| 3230 | // convert chunk and write |
| 3231 | flush(data, chunk_size); |
| 3232 | |
| 3233 | // iterate |
| 3234 | data += chunk_size; |
| 3235 | length -= chunk_size; |
| 3236 | } |
| 3237 | |
| 3238 | // small tail is copied below |
| 3239 | bufsize = 0; |
| 3240 | } |
| 3241 | } |
| 3242 | |
| 3243 | memcpy(buffer + bufsize, data, length * sizeof(char_t)); |
| 3244 | bufsize += length; |
| 3245 | } |
| 3246 | |
| 3247 | void write(const char_t* data) |
| 3248 | { |
nothing calls this directly
no test coverage detected