[email protected] | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 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 | |
| 5 | #include "url/url_canon_stdstring.h" |
| 6 | |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 7 | namespace url { |
[email protected] | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 8 | |
| 9 | StdStringCanonOutput::StdStringCanonOutput(std::string* str) |
| 10 | : CanonOutput(), str_(str) { |
| 11 | cur_len_ = static_cast<int>(str_->size()); // Append to existing data. |
[email protected] | b5966066 | 2013-12-03 14:31:21 | [diff] [blame] | 12 | buffer_ = str_->empty() ? NULL : &(*str_)[0]; |
| 13 | buffer_len_ = static_cast<int>(str_->size()); |
| 14 | } |
| 15 | |
| 16 | StdStringCanonOutput::~StdStringCanonOutput() { |
| 17 | // Nothing to do, we don't own the string. |
| 18 | } |
| 19 | |
| 20 | void StdStringCanonOutput::Complete() { |
| 21 | str_->resize(cur_len_); |
| 22 | buffer_len_ = cur_len_; |
| 23 | } |
| 24 | |
| 25 | void StdStringCanonOutput::Resize(int sz) { |
| 26 | str_->resize(sz); |
| 27 | buffer_ = str_->empty() ? NULL : &(*str_)[0]; |
| 28 | buffer_len_ = sz; |
| 29 | } |
| 30 | |
[email protected] | 0318f92 | 2014-04-22 00:09:23 | [diff] [blame] | 31 | } // namespace url |