Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
tfarina@chromium.org | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "url/url_canon_stdstring.h" |
| 6 | |
vitalybuka@chromium.org | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 7 | namespace url { |
tfarina@chromium.org | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 8 | |
Peter Kasting | cfdf32c | 2022-08-17 20:21:02 | [diff] [blame] | 9 | StdStringCanonOutput::StdStringCanonOutput(std::string* str) : str_(str) { |
| 10 | cur_len_ = str_->size(); // Append to existing data. |
| 11 | buffer_ = str_->empty() ? nullptr : &(*str_)[0]; |
| 12 | buffer_len_ = str_->size(); |
tfarina@chromium.org | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | StdStringCanonOutput::~StdStringCanonOutput() { |
| 16 | // Nothing to do, we don't own the string. |
| 17 | } |
| 18 | |
| 19 | void StdStringCanonOutput::Complete() { |
| 20 | str_->resize(cur_len_); |
| 21 | buffer_len_ = cur_len_; |
| 22 | } |
| 23 | |
Peter Kasting | cfdf32c | 2022-08-17 20:21:02 | [diff] [blame] | 24 | void StdStringCanonOutput::Resize(size_t sz) { |
tfarina@chromium.org | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 25 | str_->resize(sz); |
Peter Kasting | cfdf32c | 2022-08-17 20:21:02 | [diff] [blame] | 26 | buffer_ = str_->empty() ? nullptr : &(*str_)[0]; |
tfarina@chromium.org | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 27 | buffer_len_ = sz; |
| 28 | } |
| 29 | |
vitalybuka@chromium.org | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 30 | } // namespace url |