16e6646c03788f198a9878763680c05342d7622f3Chris Craik/* 26e6646c03788f198a9878763680c05342d7622f3Chris Craik * Copyright (C) 2015 The Android Open Source Project 36e6646c03788f198a9878763680c05342d7622f3Chris Craik * 46e6646c03788f198a9878763680c05342d7622f3Chris Craik * Licensed under the Apache License, Version 2.0 (the "License"); 56e6646c03788f198a9878763680c05342d7622f3Chris Craik * you may not use this file except in compliance with the License. 66e6646c03788f198a9878763680c05342d7622f3Chris Craik * You may obtain a copy of the License at 76e6646c03788f198a9878763680c05342d7622f3Chris Craik * 86e6646c03788f198a9878763680c05342d7622f3Chris Craik * http://www.apache.org/licenses/LICENSE-2.0 96e6646c03788f198a9878763680c05342d7622f3Chris Craik * 106e6646c03788f198a9878763680c05342d7622f3Chris Craik * Unless required by applicable law or agreed to in writing, software 116e6646c03788f198a9878763680c05342d7622f3Chris Craik * distributed under the License is distributed on an "AS IS" BASIS, 126e6646c03788f198a9878763680c05342d7622f3Chris Craik * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136e6646c03788f198a9878763680c05342d7622f3Chris Craik * See the License for the specific language governing permissions and 146e6646c03788f198a9878763680c05342d7622f3Chris Craik * limitations under the License. 156e6646c03788f198a9878763680c05342d7622f3Chris Craik */ 166e6646c03788f198a9878763680c05342d7622f3Chris Craik 17096895550b9d5430d7a001d491566decf4f9791bJohn Reck#include "StringUtils.h" 186e6646c03788f198a9878763680c05342d7622f3Chris Craik 196e6646c03788f198a9878763680c05342d7622f3Chris Craiknamespace android { 206e6646c03788f198a9878763680c05342d7622f3Chris Craiknamespace uirenderer { 216e6646c03788f198a9878763680c05342d7622f3Chris Craik 22704bed0da7cc75d0c517d425445de70ceb58060bJohn Reckunordered_string_set StringUtils::split(const char* spacedList) { 23704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck unordered_string_set set; 246e6646c03788f198a9878763680c05342d7622f3Chris Craik const char* current = spacedList; 256e6646c03788f198a9878763680c05342d7622f3Chris Craik const char* head = current; 266e6646c03788f198a9878763680c05342d7622f3Chris Craik do { 276e6646c03788f198a9878763680c05342d7622f3Chris Craik head = strchr(current, ' '); 286e6646c03788f198a9878763680c05342d7622f3Chris Craik std::string s(current, head ? head - current : strlen(current)); 296e6646c03788f198a9878763680c05342d7622f3Chris Craik if (s.length()) { 30704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck set.insert(std::move(s)); 316e6646c03788f198a9878763680c05342d7622f3Chris Craik } 326e6646c03788f198a9878763680c05342d7622f3Chris Craik current = head + 1; 336e6646c03788f198a9878763680c05342d7622f3Chris Craik } while (head); 34704bed0da7cc75d0c517d425445de70ceb58060bJohn Reck return set; 356e6646c03788f198a9878763680c05342d7622f3Chris Craik} 366e6646c03788f198a9878763680c05342d7622f3Chris Craik 376e6646c03788f198a9878763680c05342d7622f3Chris Craik}; // namespace uirenderer 386e6646c03788f198a9878763680c05342d7622f3Chris Craik}; // namespace android 39