blob: c81a0a98b54ec3c851f2b5f1c6ceb1f5fc7863bc [file] [log] [blame]
[email protected]b59660662013-12-03 14:31:211// 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]0318f922014-04-22 00:09:237namespace url {
[email protected]b59660662013-12-03 14:31:218
9StdStringCanonOutput::StdStringCanonOutput(std::string* str)
10 : CanonOutput(), str_(str) {
11 cur_len_ = static_cast<int>(str_->size()); // Append to existing data.
[email protected]b59660662013-12-03 14:31:2112 buffer_ = str_->empty() ? NULL : &(*str_)[0];
13 buffer_len_ = static_cast<int>(str_->size());
14}
15
16StdStringCanonOutput::~StdStringCanonOutput() {
17 // Nothing to do, we don't own the string.
18}
19
20void StdStringCanonOutput::Complete() {
21 str_->resize(cur_len_);
22 buffer_len_ = cur_len_;
23}
24
25void StdStringCanonOutput::Resize(int sz) {
26 str_->resize(sz);
27 buffer_ = str_->empty() ? NULL : &(*str_)[0];
28 buffer_len_ = sz;
29}
30
[email protected]0318f922014-04-22 00:09:2331} // namespace url