File indexing completed on 2024-04-28 05:50:44
0001 /* 0002 This source file is part of Konsole, a terminal emulator. 0003 0004 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 // Own 0010 #include "ProfileCommandParser.h" 0011 0012 // Konsole 0013 0014 // Qt 0015 #include <QRegularExpression> 0016 0017 using namespace Konsole; 0018 0019 Profile::PropertyMap ProfileCommandParser::parse(const QString &input) 0020 { 0021 Profile::PropertyMap changes; 0022 0023 // regular expression to parse profile change requests. 0024 // 0025 // format: property=value;property=value ... 0026 // 0027 // where 'property' is a word consisting only of characters from A-Z 0028 // where 'value' is any sequence of characters other than a semi-colon 0029 // 0030 static const QRegularExpression regExp(QStringLiteral("([a-zA-Z]+)=([^;]+)")); 0031 0032 QRegularExpressionMatchIterator iterator(regExp.globalMatch(input)); 0033 while (iterator.hasNext()) { 0034 QRegularExpressionMatch match(iterator.next()); 0035 Profile::Property property = Profile::lookupByName(match.captured(1)); 0036 changes.insert_or_assign(property, match.captured(2)); 0037 } 0038 0039 return changes; 0040 }