url_canon_stdstring.cc 788 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "url/url_canon_stdstring.h"
  5. namespace url {
  6. StdStringCanonOutput::StdStringCanonOutput(std::string* str) : str_(str) {
  7. cur_len_ = str_->size(); // Append to existing data.
  8. buffer_ = str_->empty() ? nullptr : &(*str_)[0];
  9. buffer_len_ = str_->size();
  10. }
  11. StdStringCanonOutput::~StdStringCanonOutput() {
  12. // Nothing to do, we don't own the string.
  13. }
  14. void StdStringCanonOutput::Complete() {
  15. str_->resize(cur_len_);
  16. buffer_len_ = cur_len_;
  17. }
  18. void StdStringCanonOutput::Resize(size_t sz) {
  19. str_->resize(sz);
  20. buffer_ = str_->empty() ? nullptr : &(*str_)[0];
  21. buffer_len_ = sz;
  22. }
  23. } // namespace url