Changeset 11158 in ntrip for trunk/BNC/src/bncutils.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (4 days ago)
- File:
-
- 1 edited
-
trunk/BNC/src/bncutils.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bncutils.cpp
r11096 r11158 43 43 #include <math.h> 44 44 45 #include <QReg Exp>45 #include <QRegularExpression> 46 46 #include <QStringList> 47 47 #include <QDateTime> … … 156 156 } 157 157 158 // 158 // Replace each ${NAME} by the environment variable NAME (empty if not set); 159 // BNC's own file name placeholders are kept 159 160 //////////////////////////////////////////////////////////////////////////// 160 161 void expandEnvVar(QString& str) { 161 162 162 QRegExp rx("(\\$\\{.+\\})"); 163 164 if (rx.indexIn(str) != -1) { 165 QStringListIterator it(rx.capturedTexts()); 166 if (it.hasNext()) { 167 QString rxStr = it.next(); 168 QString envVar = rxStr.mid(2,rxStr.length()-3); 169 str.replace(rxStr, qgetenv(envVar.toLatin1())); 170 } 171 } 163 static const QStringList placeholders = QStringList() << "GPSWD" << "V3OBS" << "V3PROD"; 164 165 QString result; 166 int last = 0; 167 QRegularExpressionMatchIterator it = QRegularExpression("\\$\\{([^}]+)\\}").globalMatch(str); 168 while (it.hasNext()) { 169 QRegularExpressionMatch match = it.next(); 170 QString name = match.captured(1); 171 result += str.mid(last, match.capturedStart() - last); 172 result += placeholders.contains(name) ? match.captured(0) 173 : QString::fromUtf8(qgetenv(name.toLatin1())); 174 last = match.capturedEnd(); 175 } 176 str = result + str.mid(last); 172 177 } 173 178
Note:
See TracChangeset
for help on using the changeset viewer.
