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

Side by Side Diff: tools/gn/eclipse_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/command_format.cc ('k') | tools/gn/exec_process.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/eclipse_writer.h" 5 #include "tools/gn/eclipse_writer.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <memory>
8 9
9 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "tools/gn/builder.h" 11 #include "tools/gn/builder.h"
12 #include "tools/gn/config_values_extractors.h" 12 #include "tools/gn/config_values_extractors.h"
13 #include "tools/gn/filesystem_utils.h" 13 #include "tools/gn/filesystem_utils.h"
14 #include "tools/gn/loader.h" 14 #include "tools/gn/loader.h"
15 #include "tools/gn/xml_element_writer.h" 15 #include "tools/gn/xml_element_writer.h"
16 16
17 namespace { 17 namespace {
18 18
19 // Escapes |unescaped| for use in XML element content. 19 // Escapes |unescaped| for use in XML element content.
20 std::string EscapeForXML(const std::string& unescaped) { 20 std::string EscapeForXML(const std::string& unescaped) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 void EclipseWriter::WriteCDTSettings() { 122 void EclipseWriter::WriteCDTSettings() {
123 out_ << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; 123 out_ << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
124 XmlElementWriter cdt_properties_element(out_, "cdtprojectproperties", 124 XmlElementWriter cdt_properties_element(out_, "cdtprojectproperties",
125 XmlAttributes()); 125 XmlAttributes());
126 126
127 { 127 {
128 const char* kIncludesSectionName = 128 const char* kIncludesSectionName =
129 "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"; 129 "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths";
130 scoped_ptr<XmlElementWriter> section_element = 130 std::unique_ptr<XmlElementWriter> section_element =
131 cdt_properties_element.SubElement( 131 cdt_properties_element.SubElement(
132 "section", XmlAttributes("name", kIncludesSectionName)); 132 "section", XmlAttributes("name", kIncludesSectionName));
133 133
134 section_element->SubElement( 134 section_element->SubElement(
135 "language", XmlAttributes("name", "holder for library settings")); 135 "language", XmlAttributes("name", "holder for library settings"));
136 136
137 for (const std::string& language : languages_) { 137 for (const std::string& language : languages_) {
138 scoped_ptr<XmlElementWriter> language_element = 138 std::unique_ptr<XmlElementWriter> language_element =
139 section_element->SubElement("language", 139 section_element->SubElement("language",
140 XmlAttributes("name", language)); 140 XmlAttributes("name", language));
141 for (const std::string& include_dir : include_dirs_) { 141 for (const std::string& include_dir : include_dirs_) {
142 language_element 142 language_element
143 ->SubElement("includepath", 143 ->SubElement("includepath",
144 XmlAttributes("workspace_path", "false")) 144 XmlAttributes("workspace_path", "false"))
145 ->Text(EscapeForXML(include_dir)); 145 ->Text(EscapeForXML(include_dir));
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 { 150 {
151 const char* kMacrosSectionName = 151 const char* kMacrosSectionName =
152 "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; 152 "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros";
153 scoped_ptr<XmlElementWriter> section_element = 153 std::unique_ptr<XmlElementWriter> section_element =
154 cdt_properties_element.SubElement( 154 cdt_properties_element.SubElement(
155 "section", XmlAttributes("name", kMacrosSectionName)); 155 "section", XmlAttributes("name", kMacrosSectionName));
156 156
157 section_element->SubElement( 157 section_element->SubElement(
158 "language", XmlAttributes("name", "holder for library settings")); 158 "language", XmlAttributes("name", "holder for library settings"));
159 159
160 for (const std::string& language : languages_) { 160 for (const std::string& language : languages_) {
161 scoped_ptr<XmlElementWriter> language_element = 161 std::unique_ptr<XmlElementWriter> language_element =
162 section_element->SubElement("language", 162 section_element->SubElement("language",
163 XmlAttributes("name", language)); 163 XmlAttributes("name", language));
164 for (const auto& key_val : defines_) { 164 for (const auto& key_val : defines_) {
165 scoped_ptr<XmlElementWriter> macro_element = 165 std::unique_ptr<XmlElementWriter> macro_element =
166 language_element->SubElement("macro"); 166 language_element->SubElement("macro");
167 macro_element->SubElement("name")->Text(EscapeForXML(key_val.first)); 167 macro_element->SubElement("name")->Text(EscapeForXML(key_val.first));
168 macro_element->SubElement("value")->Text(EscapeForXML(key_val.second)); 168 macro_element->SubElement("value")->Text(EscapeForXML(key_val.second));
169 } 169 }
170 } 170 }
171 } 171 }
172 } 172 }
OLDNEW
« no previous file with comments | « tools/gn/command_format.cc ('k') | tools/gn/exec_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698