Line data Source code
1 : /**************************************************************************** 2 : * Copyright (C) 2017-2024 Savoir-faire Linux Inc. * 3 : * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> * 4 : * Author : Alexandre Lision <alexandre.lision@savoirfairelinux.com> * 5 : * * 6 : * This library is free software; you can redistribute it and/or * 7 : * modify it under the terms of the GNU Lesser General Public * 8 : * License as published by the Free Software Foundation; either * 9 : * version 2.1 of the License, or (at your option) any later version. * 10 : * * 11 : * This library is distributed in the hope that it will be useful, * 12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 14 : * Lesser General Public License for more details. * 15 : * * 16 : * You should have received a copy of the GNU General Public License * 17 : * along with this program. If not, see <http://www.gnu.org/licenses/>. * 18 : ***************************************************************************/ 19 : 20 : #include "vcard.h" 21 : #include "string_utils.h" 22 : 23 : namespace vCard { 24 : 25 : namespace utils { 26 : 27 : std::map<std::string, std::string> 28 72 : toMap(std::string_view content) 29 : { 30 72 : std::map<std::string, std::string> vCard; 31 : 32 72 : std::string_view line; 33 148 : while (jami::getline(content, line)) { 34 76 : if (line.size()) { 35 76 : const auto dblptPos = line.find(':'); 36 76 : if (dblptPos == std::string::npos) 37 14 : continue; 38 62 : vCard.emplace(line.substr(0, dblptPos), line.substr(dblptPos + 1)); 39 : } 40 : } 41 144 : return vCard; 42 0 : } 43 : } // namespace utils 44 : 45 : } // namespace vCard