[go: nahoru, domu]

blob: 60e2a26747c665a1f3190b4c7e0fb3c2eec557ed [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2013 The Chromium Authors
tfarina@chromium.orgb59660662013-12-03 14:31:212// 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.org0318f922014-04-22 00:09:237namespace url {
tfarina@chromium.orgb59660662013-12-03 14:31:218
Peter Kastingcfdf32c2022-08-17 20:21:029StdStringCanonOutput::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.orgb59660662013-12-03 14:31:2113}
14
15StdStringCanonOutput::~StdStringCanonOutput() {
16 // Nothing to do, we don't own the string.
17}
18
19void StdStringCanonOutput::Complete() {
20 str_->resize(cur_len_);
21 buffer_len_ = cur_len_;
22}
23
Peter Kastingcfdf32c2022-08-17 20:21:0224void StdStringCanonOutput::Resize(size_t sz) {
tfarina@chromium.orgb59660662013-12-03 14:31:2125 str_->resize(sz);
Peter Kastingcfdf32c2022-08-17 20:21:0226 buffer_ = str_->empty() ? nullptr : &(*str_)[0];
tfarina@chromium.orgb59660662013-12-03 14:31:2127 buffer_len_ = sz;
28}
29
vitalybuka@chromium.org0318f922014-04-22 00:09:2330} // namespace url