summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--url/url.gyp1
-rw-r--r--url/url_canon_stdstring.cc32
-rw-r--r--url/url_canon_stdstring.h27
3 files changed, 39 insertions, 21 deletions
diff --git a/url/url.gyp b/url/url.gyp
index 2c81443..9dc949a 100644
--- a/url/url.gyp
+++ b/url/url.gyp
@@ -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',
diff --git a/url/url_canon_stdstring.cc b/url/url_canon_stdstring.cc
new file mode 100644
index 0000000..ad81a2f
--- /dev/null
+++ b/url/url_canon_stdstring.cc
@@ -0,0 +1,32 @@
+// 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
diff --git a/url/url_canon_stdstring.h b/url/url_canon_stdstring.h
index 9b4a6c2..0915672 100644
--- a/url/url_canon_stdstring.h
+++ b/url/url_canon_stdstring.h
@@ -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_;