| 545 | } |
| 546 | |
| 547 | int charset_conv::pop_end(acl::string* out, size_t max /* = 0 */) |
| 548 | { |
| 549 | if (m_pBuf == NULL) { |
| 550 | logger_error("call push_pop first"); |
| 551 | return -1; |
| 552 | } |
| 553 | |
| 554 | update_finish(m_pBuf); |
| 555 | |
| 556 | if (out == NULL) { |
| 557 | m_pBuf->clear(); |
| 558 | return 0; |
| 559 | } |
| 560 | |
| 561 | size_t n = m_pBuf->length(); |
| 562 | if (n == 0) { |
| 563 | return 0; |
| 564 | } |
| 565 | if (max > 0 && n > max) { |
| 566 | n = max; |
| 567 | } |
| 568 | out->append(m_pBuf->c_str(), m_pBuf->length()); |
| 569 | m_pBuf->clear(); |
| 570 | return (int) n; |
| 571 | } |
| 572 | |
| 573 | void charset_conv::clear(void) |
| 574 | { |