Loading...
Searching...
No Matches
stringUtils.cpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#include "stringUtils.hpp"
26
27using namespace std;
28
29namespace bitpit {
30
31namespace utils {
32
33namespace string {
34
51bool getAfterKeyword(const std::string &line, const std::string &key, char del, std::string &result)
52{
53 result.clear();
54
55 std::size_t pos = line.find(key);
56 if (pos == std::string::npos) {
57 return false;
58 }
59
60 std::string::const_iterator it = line.begin();
61 advance(it, pos);
62 advance(it, key.size());
63
64 while ((*it) != del) {
65 ++it;
66 }
67 std::size_t c1= it- line.begin() + 1;
68
69 ++it;
70
71 while ((*it) != del) {
72 ++it;
73 }
74 std::size_t c2 = it - line.begin() - 1;
75
76 pos= c2 - c1 + 1;
77
78 result = line.substr(c1, pos);
79 trim(result);
80
81 return true;
82}
83
84}
85
86}
87
88}
std::string & trim(std::string &s)
bool getAfterKeyword(const std::string &line, const std::string &key, char del, std::string &result)
--- layout: doxygen_footer ---