// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include #include #include #include namespace CommonAPI { std::vector& split(const std::string& s, char delim, std::vector& elems) { std::istringstream ss(s); std::string item; while (std::getline(ss, item, delim)) { elems.push_back(item); } return elems; } std::vector split(const std::string& s, char delim) { std::vector elems; return split(s, delim, elems); } void trim(std::string& toTrim) { toTrim.erase( toTrim.begin(), std::find_if( toTrim.begin(), toTrim.end(), std::not1(std::ptr_fun(isspace)) ) ); toTrim.erase( std::find_if( toTrim.rbegin(), toTrim.rend(), std::not1(std::ptr_fun(isspace))).base(), toTrim.end() ); } }//namespace CommonAPI