url_canon_stdstring.cc 834 B

12345678910111213141516171819202122232425262728293031
  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)
  7. : CanonOutput(), str_(str) {
  8. cur_len_ = static_cast<int>(str_->size()); // Append to existing data.
  9. buffer_ = str_->empty() ? NULL : &(*str_)[0];
  10. buffer_len_ = static_cast<int>(str_->size());
  11. }
  12. StdStringCanonOutput::~StdStringCanonOutput() {
  13. // Nothing to do, we don't own the string.
  14. }
  15. void StdStringCanonOutput::Complete() {
  16. str_->resize(cur_len_);
  17. buffer_len_ = cur_len_;
  18. }
  19. void StdStringCanonOutput::Resize(int sz) {
  20. str_->resize(sz);
  21. buffer_ = str_->empty() ? NULL : &(*str_)[0];
  22. buffer_len_ = sz;
  23. }
  24. } // namespace url