| 511 | } |
| 512 | |
| 513 | int charset_conv::push_pop(const char* in, size_t len, |
| 514 | acl::string* out, size_t max /* = 0 */) |
| 515 | { |
| 516 | if (m_pBuf == NULL) { |
| 517 | m_pBuf = NEW acl::string(1024); |
| 518 | } |
| 519 | |
| 520 | if (in && len > 0 && !update(in, len, m_pBuf)) { |
| 521 | return -1; |
| 522 | } |
| 523 | |
| 524 | len = m_pBuf->length(); |
| 525 | if (len == 0) { |
| 526 | return 0; |
| 527 | } |
| 528 | |
| 529 | size_t n; |
| 530 | if (max > 0) { |
| 531 | n = max > len ? len : max; |
| 532 | } else { |
| 533 | n = len; |
| 534 | } |
| 535 | |
| 536 | out->append(m_pBuf->c_str(), n); |
| 537 | |
| 538 | if (len > n) { |
| 539 | m_pBuf->memmove(m_pBuf->c_str() + n, len - n); |
| 540 | } else { |
| 541 | m_pBuf->clear(); |
| 542 | } |
| 543 | |
| 544 | return (int) n; |
| 545 | } |
| 546 | |
| 547 | int charset_conv::pop_end(acl::string* out, size_t max /* = 0 */) |
| 548 | { |