Commit b5966066 authored by tfarina@chromium.org's avatar tfarina@chromium.org

Deinline the implementation of StdStringCanonOutput.

This should move the implementation of StdStringCanonOutput from the
header to the source file, that should please the chromium-style clang
plugin.

BUG=287029
TEST=url_unittests
R=thakis@chromium.org,abarth@chromium.org
TBR=abarth

Review URL: https://codereview.chromium.org/84673002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238392 0039d316-1c4b-4281-b951-d872f2087c98
parent cfb8c555
......@@ -42,6 +42,7 @@
'url_canon_pathurl.cc',
'url_canon_query.cc',
'url_canon_relative.cc',
'url_canon_stdstring.cc',
'url_canon_stdstring.h',
'url_canon_stdurl.cc',
'url_file.h',
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "url/url_canon_stdstring.h"
namespace url_canon {
StdStringCanonOutput::StdStringCanonOutput(std::string* str)
: CanonOutput(), str_(str) {
cur_len_ = static_cast<int>(str_->size()); // Append to existing data.
str_->resize(str_->capacity());
buffer_ = str_->empty() ? NULL : &(*str_)[0];
buffer_len_ = static_cast<int>(str_->size());
}
StdStringCanonOutput::~StdStringCanonOutput() {
// Nothing to do, we don't own the string.
}
void StdStringCanonOutput::Complete() {
str_->resize(cur_len_);
buffer_len_ = cur_len_;
}
void StdStringCanonOutput::Resize(int sz) {
str_->resize(sz);
buffer_ = str_->empty() ? NULL : &(*str_)[0];
buffer_len_ = sz;
}
} // namespace url_canon
......@@ -13,6 +13,7 @@
#include "base/compiler_specific.h"
#include "url/url_canon.h"
#include "url/url_export.h"
namespace url_canon {
......@@ -32,31 +33,15 @@ namespace url_canon {
//
// Therefore, the user should call Complete() before using the string that
// this class wrote into.
class StdStringCanonOutput : public CanonOutput {
class URL_EXPORT StdStringCanonOutput : public CanonOutput {
public:
StdStringCanonOutput(std::string* str)
: CanonOutput(),
str_(str) {
cur_len_ = static_cast<int>(str_->size()); // Append to existing data.
str_->resize(str_->capacity());
buffer_ = str_->empty() ? NULL : &(*str_)[0];
buffer_len_ = static_cast<int>(str_->size());
}
virtual ~StdStringCanonOutput() {
// Nothing to do, we don't own the string.
}
StdStringCanonOutput(std::string* str);
virtual ~StdStringCanonOutput();
// Must be called after writing has completed but before the string is used.
void Complete() {
str_->resize(cur_len_);
buffer_len_ = cur_len_;
}
void Complete();
virtual void Resize(int sz) OVERRIDE {
str_->resize(sz);
buffer_ = str_->empty() ? NULL : &(*str_)[0];
buffer_len_ = sz;
}
virtual void Resize(int sz) OVERRIDE;
protected:
std::string* str_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment