1 // Copyright 2013 The Chromium Authors 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 7 namespace url { 8 StdStringCanonOutput(std::string * str)9StdStringCanonOutput::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(); 13 } 14 ~StdStringCanonOutput()15StdStringCanonOutput::~StdStringCanonOutput() { 16 // Nothing to do, we don't own the string. 17 } 18 Complete()19void StdStringCanonOutput::Complete() { 20 str_->resize(cur_len_); 21 buffer_len_ = cur_len_; 22 } 23 Resize(size_t sz)24void StdStringCanonOutput::Resize(size_t sz) { 25 str_->resize(sz); 26 buffer_ = str_->empty() ? nullptr : &(*str_)[0]; 27 buffer_len_ = sz; 28 } 29 30 } // namespace url 31