Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: tools/gn/xml_element_writer.cc

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/xml_element_writer.h ('k') | tools/imagediff/image_diff.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/xml_element_writer.h" 5 #include "tools/gn/xml_element_writer.h"
6 6
7 #include "base/memory/ptr_util.h"
8
7 XmlAttributes::XmlAttributes() {} 9 XmlAttributes::XmlAttributes() {}
8 10
9 XmlAttributes::XmlAttributes(const base::StringPiece& attr_key, 11 XmlAttributes::XmlAttributes(const base::StringPiece& attr_key,
10 const base::StringPiece& attr_value) { 12 const base::StringPiece& attr_value) {
11 add(attr_key, attr_value); 13 add(attr_key, attr_value);
12 } 14 }
13 15
14 XmlAttributes& XmlAttributes::add(const base::StringPiece& attr_key, 16 XmlAttributes& XmlAttributes::add(const base::StringPiece& attr_key,
15 const base::StringPiece& attr_value) { 17 const base::StringPiece& attr_value) {
16 push_back(std::make_pair(attr_key, attr_value)); 18 push_back(std::make_pair(attr_key, attr_value));
(...skipping 29 matching lines...) Expand all
46 out_ << std::string(indent_, ' '); 48 out_ << std::string(indent_, ' ');
47 out_ << "</" << tag_ << '>' << std::endl; 49 out_ << "</" << tag_ << '>' << std::endl;
48 } 50 }
49 } 51 }
50 52
51 void XmlElementWriter::Text(const base::StringPiece& content) { 53 void XmlElementWriter::Text(const base::StringPiece& content) {
52 StartContent(false); 54 StartContent(false);
53 out_ << content; 55 out_ << content;
54 } 56 }
55 57
56 scoped_ptr<XmlElementWriter> XmlElementWriter::SubElement( 58 std::unique_ptr<XmlElementWriter> XmlElementWriter::SubElement(
57 const std::string& tag) { 59 const std::string& tag) {
58 return SubElement(tag, XmlAttributes()); 60 return SubElement(tag, XmlAttributes());
59 } 61 }
60 62
61 scoped_ptr<XmlElementWriter> XmlElementWriter::SubElement( 63 std::unique_ptr<XmlElementWriter> XmlElementWriter::SubElement(
62 const std::string& tag, 64 const std::string& tag,
63 const XmlAttributes& attributes) { 65 const XmlAttributes& attributes) {
64 StartContent(true); 66 StartContent(true);
65 return make_scoped_ptr( 67 return base::WrapUnique(
66 new XmlElementWriter(out_, tag, attributes, indent_ + 2)); 68 new XmlElementWriter(out_, tag, attributes, indent_ + 2));
67 } 69 }
68 70
69 std::ostream& XmlElementWriter::StartContent(bool start_new_line) { 71 std::ostream& XmlElementWriter::StartContent(bool start_new_line) {
70 if (!opening_tag_finished_) { 72 if (!opening_tag_finished_) {
71 out_ << '>'; 73 out_ << '>';
72 opening_tag_finished_ = true; 74 opening_tag_finished_ = true;
73 75
74 if (start_new_line && one_line_) { 76 if (start_new_line && one_line_) {
75 out_ << std::endl; 77 out_ << std::endl;
76 one_line_ = false; 78 one_line_ = false;
77 } 79 }
78 } 80 }
79 81
80 return out_; 82 return out_;
81 } 83 }
OLDNEW
« no previous file with comments | « tools/gn/xml_element_writer.h ('k') | tools/imagediff/image_diff.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698