17af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// Copyright 2013 The Chromium Authors. All rights reserved. 27af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// Use of this source code is governed by a BSD-style license that can be 37af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// found in the LICENSE file. 4ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// 5ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// The original source code is from: 6ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// http://src.chromium.org/viewvc/chrome/trunk/src/base/strings/string_split.h?revision=236210 7ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// 8ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// Modifications from original: 9ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// 1) Supports only std::string type. 10ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com// 2) Does not trim whitespace. 117af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com 12ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com#ifndef I18N_ADDRESSINPUT_UTIL_STRING_SPLIT_H_ 13ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com#define I18N_ADDRESSINPUT_UTIL_STRING_SPLIT_H_ 147af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com 157af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com#include <string> 167af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com#include <vector> 177af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com 18ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.comnamespace i18n { 19ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.comnamespace addressinput { 207af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com 217af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// Splits |str| into a vector of strings delimited by |c|, placing the results 227af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// in |r|. If several instances of |c| are contiguous, or if |str| begins with 237af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// or ends with |c|, then an empty string is inserted. 247af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// 257af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which 267af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// the trailing byte of a multi-byte character can be in the ASCII range. 277af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. 287af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com// Note: |c| must be in the ASCII range. 29ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.comvoid SplitString(const std::string& str, char c, std::vector<std::string>* r); 307af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com 31ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com} // namespace addressinput 32ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com} // namespace i18n 337af2afbf8abd201b5cad73ca1275e1b03d91efcaroubert@google.com 34ff46a74157ff7b73490fd1fb909d6151fcafa353roubert@google.com#endif // I18N_ADDRESSINPUT_UTIL_STRING_SPLIT_H_ 35