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

Unified Diff: base/ini_parser.cc

Issue 453703002: Move ini_parser from base to chrome/common (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base:: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/ini_parser.h ('k') | base/ini_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/ini_parser.cc
diff --git a/base/ini_parser.cc b/base/ini_parser.cc
deleted file mode 100644
index 7a2bd1c911bd8028cc4f83636d2df2d9b6dd0285..0000000000000000000000000000000000000000
--- a/base/ini_parser.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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 "base/ini_parser.h"
-
-#include "base/logging.h"
-#include "base/strings/string_tokenizer.h"
-
-namespace base {
-
-INIParser::INIParser() : used_(false) {}
-
-INIParser::~INIParser() {}
-
-void INIParser::Parse(const std::string& content) {
- DCHECK(!used_);
- used_ = true;
- base::StringTokenizer tokenizer(content, "\r\n");
-
- std::string current_section;
- while (tokenizer.GetNext()) {
- std::string line = tokenizer.token();
- if (line.empty()) {
- // Skips the empty line.
- continue;
- }
- if (line[0] == '#' || line[0] == ';') {
- // This line is a comment.
- continue;
- }
- if (line[0] == '[') {
- // It is a section header.
- current_section = line.substr(1);
- size_t end = current_section.rfind(']');
- if (end != std::string::npos)
- current_section.erase(end);
- } else {
- std::string key, value;
- size_t equal = line.find('=');
- if (equal != std::string::npos) {
- key = line.substr(0, equal);
- value = line.substr(equal + 1);
- HandleTriplet(current_section, key, value);
- }
- }
- }
-}
-
-DictionaryValueINIParser::DictionaryValueINIParser() {}
-
-DictionaryValueINIParser::~DictionaryValueINIParser() {}
-
-void DictionaryValueINIParser::HandleTriplet(const std::string& section,
- const std::string& key,
- const std::string& value) {
-
- // Checks whether the section and key contain a '.' character.
- // Those sections and keys break DictionaryValue's path format when not
- // using the *WithoutPathExpansion methods.
- if (section.find('.') == std::string::npos &&
- key.find('.') == std::string::npos)
- root_.SetString(section + "." + key, value);
-}
-
-} // namespace base
« no previous file with comments | « base/ini_parser.h ('k') | base/ini_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698