Changeset View
Changeset View
Standalone View
Standalone View
source/ps/tests/test_CLogger.h
/* Copyright (C) 2009 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | public: | ||||
void ParseOutput() | void ParseOutput() | ||||
{ | { | ||||
const std::string header_end = "</h2>\n"; | const std::string header_end = "</h2>\n"; | ||||
std::string s = mainlog->str(); | std::string s = mainlog->str(); | ||||
size_t start = s.find(header_end); | size_t start = s.find(header_end); | ||||
TS_ASSERT_DIFFERS(start, s.npos); | TS_ASSERT_DIFFERS(start, s.npos); | ||||
s = s.substr(start + header_end.length()); | s.erase(0, start + header_end.length()); | ||||
vladislavbelov: Also why iterators? | |||||
size_t n = 0, m; | size_t n = 0, m; | ||||
while (s.npos != (m = s.find('\n', n))) | while (s.npos != (m = s.find('\n', n))) | ||||
{ | { | ||||
size_t gt = s.find('>', n); | size_t gt = s.find('>', n); | ||||
lines.push_back(s.substr(gt+1, m-gt-5)); // strip the <p> and </p> | lines.push_back(s.substr(gt+1, m-gt-5)); // strip the <p> and </p> | ||||
n = m+1; | n = m+1; | ||||
} | } | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator
Also why iterators?