File indexing completed on 2025-01-05 04:55:53

0001 /*
0002     utils/stringutils.cpp
0003 
0004     This file is part of libkleopatra
0005     SPDX-FileCopyrightText: 2021 g10 Code GmbH
0006     SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include <config-libkleo.h>
0012 
0013 #include "stringutils.h"
0014 
0015 std::vector<std::string> Kleo::split(const std::string &s, char c)
0016 {
0017     std::vector<std::string> result;
0018 
0019     auto start = 0;
0020     auto end = s.find(c, start);
0021     while (end != s.npos) {
0022         result.push_back(s.substr(start, end - start));
0023         start = end + 1;
0024         end = s.find(c, start);
0025     }
0026     result.push_back(s.substr(start));
0027 
0028     return result;
0029 }