mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
[Common/Data/File/Input/Net/Serialize/System/UI] Using for based loop C++17 and replaced on structured binding map C++17
This commit is contained in:
parent
a6dbb4dfdb
commit
45429bcd85
12 changed files with 54 additions and 72 deletions
|
@ -191,9 +191,9 @@ void Section::Clear() {
|
|||
|
||||
bool Section::GetKeys(std::vector<std::string> &keys) const {
|
||||
keys.clear();
|
||||
for (auto liter = lines_.begin(); liter != lines_.end(); ++liter) {
|
||||
if (!liter->Key().empty())
|
||||
keys.emplace_back(liter->Key());
|
||||
for (auto &line : lines_) {
|
||||
if (!line.Key().empty())
|
||||
keys.emplace_back(line.Key());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -303,11 +303,10 @@ void Section::Set(std::string_view key, bool newValue, bool defaultValue)
|
|||
void Section::Set(std::string_view key, const std::vector<std::string>& newValues)
|
||||
{
|
||||
std::string temp;
|
||||
// Join the strings with ,
|
||||
std::vector<std::string>::const_iterator it;
|
||||
for (it = newValues.begin(); it != newValues.end(); ++it)
|
||||
// Join the strings with ,
|
||||
for (const auto &value : newValues)
|
||||
{
|
||||
temp += (*it) + ",";
|
||||
temp += value + ",";
|
||||
}
|
||||
// remove last ,
|
||||
if (temp.length())
|
||||
|
@ -668,25 +667,3 @@ bool IniFile::Get(const char* sectionName, const char* key, bool* value, bool de
|
|||
return section->Get(key, value, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Unit test. TODO: Move to the real unit test framework.
|
||||
/*
|
||||
int main()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load("my.ini");
|
||||
ini.Set("Hej", "A", "amaskdfl");
|
||||
ini.Set("Mossa", "A", "amaskdfl");
|
||||
ini.Set("Aissa", "A", "amaskdfl");
|
||||
//ini.Read("my.ini");
|
||||
std::string x;
|
||||
ini.Get("Hej", "B", &x, "boo");
|
||||
ini.DeleteKey("Mossa", "A");
|
||||
ini.DeleteSection("Mossa");
|
||||
ini.SortSections();
|
||||
ini.Save("my.ini");
|
||||
//UpdateVars(ini);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -103,11 +103,11 @@ const char *I18NCategory::T_cstr(const char *key, const char *def) {
|
|||
}
|
||||
|
||||
void I18NCategory::SetMap(const std::map<std::string, std::string> &m) {
|
||||
for (auto iter = m.begin(); iter != m.end(); ++iter) {
|
||||
if (map_.find(iter->first) == map_.end()) {
|
||||
std::string text = ReplaceAll(iter->second, "\\n", "\n");
|
||||
_dbg_assert_(iter->first.find('\n') == std::string::npos);
|
||||
map_[iter->first] = I18NEntry(text);
|
||||
for (const auto &[key, value] : m) {
|
||||
if (map_.find(key) == map_.end()) {
|
||||
std::string text = ReplaceAll(value, "\\n", "\n");
|
||||
_dbg_assert_(key.find('\n') == std::string::npos);
|
||||
map_[key] = I18NEntry(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,13 +110,13 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vector<File::File
|
|||
// INFO_LOG(Log::System, "Zip: Listing '%s'", orig_path);
|
||||
|
||||
listing->reserve(directories.size() + files.size());
|
||||
for (auto diter = directories.begin(); diter != directories.end(); ++diter) {
|
||||
for (const auto &dir : directories) {
|
||||
File::FileInfo info;
|
||||
info.name = *diter;
|
||||
info.name = dir;
|
||||
|
||||
// Remove the "inzip" part of the fullname.
|
||||
std::string relativePath = std::string(path).substr(inZipPath_.size());
|
||||
info.fullName = Path(relativePath + *diter);
|
||||
info.fullName = Path(relativePath + dir);
|
||||
info.exists = true;
|
||||
info.isWritable = false;
|
||||
info.isDirectory = true;
|
||||
|
@ -124,12 +124,12 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vector<File::File
|
|||
listing->push_back(info);
|
||||
}
|
||||
|
||||
for (auto fiter = files.begin(); fiter != files.end(); ++fiter) {
|
||||
for (const auto &fiter : files) {
|
||||
std::string fpath = path;
|
||||
File::FileInfo info;
|
||||
info.name = *fiter;
|
||||
info.name = fiter;
|
||||
std::string relativePath = std::string(path).substr(inZipPath_.size());
|
||||
info.fullName = Path(relativePath + *fiter);
|
||||
info.fullName = Path(relativePath + fiter);
|
||||
info.exists = true;
|
||||
info.isWritable = false;
|
||||
info.isDirectory = false;
|
||||
|
|
|
@ -42,8 +42,8 @@ std::vector<InputMapping> tabRightKeys;
|
|||
static std::unordered_map<InputDeviceID, int> uiFlipAnalogY;
|
||||
|
||||
static void AppendKeys(std::vector<InputMapping> &keys, const std::vector<InputMapping> &newKeys) {
|
||||
for (auto iter = newKeys.begin(); iter != newKeys.end(); ++iter) {
|
||||
keys.push_back(*iter);
|
||||
for (auto key : newKeys) {
|
||||
keys.push_back(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -359,8 +359,8 @@ void Server::Handle404(const ServerRequest &request) {
|
|||
|
||||
void Server::HandleListing(const ServerRequest &request) {
|
||||
request.WriteHttpResponseHeader("1.0", 200, -1, "text/plain");
|
||||
for (auto iter = handlers_.begin(); iter != handlers_.end(); ++iter) {
|
||||
request.Out()->Printf("%s\n", iter->first.c_str());
|
||||
for (auto &handler : handlers_) {
|
||||
request.Out()->Printf("%s\n", handler.first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@ void DoList(PointerWrap &p, std::list<T> &x, T &default_val) {
|
|||
Do(p, list_size);
|
||||
x.resize(list_size, default_val);
|
||||
|
||||
typename std::list<T>::iterator itr, end;
|
||||
for (itr = x.begin(), end = x.end(); itr != end; ++itr)
|
||||
Do(p, *itr);
|
||||
for (T elem : x)
|
||||
Do(p, elem);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -62,8 +62,8 @@ void DoMap(PointerWrap &p, M &x, typename M::mapped_type &default_val) {
|
|||
template<class K, class T>
|
||||
void Do(PointerWrap &p, std::map<K, T *> &x) {
|
||||
if (p.mode == PointerWrap::MODE_READ) {
|
||||
for (auto it = x.begin(), end = x.end(); it != end; ++it) {
|
||||
delete it->second;
|
||||
for (auto &iter : x) {
|
||||
delete iter.second;
|
||||
}
|
||||
}
|
||||
T *dv = nullptr;
|
||||
|
@ -79,8 +79,8 @@ void Do(PointerWrap &p, std::map<K, T> &x) {
|
|||
template<class K, class T>
|
||||
void Do(PointerWrap &p, std::unordered_map<K, T *> &x) {
|
||||
if (p.mode == PointerWrap::MODE_READ) {
|
||||
for (auto it = x.begin(), end = x.end(); it != end; ++it) {
|
||||
delete it->second;
|
||||
for (auto &iter : x) {
|
||||
delete iter.second;
|
||||
}
|
||||
}
|
||||
T *dv = nullptr;
|
||||
|
@ -132,8 +132,8 @@ void DoMultimap(PointerWrap &p, M &x, typename M::mapped_type &default_val) {
|
|||
template<class K, class T>
|
||||
void Do(PointerWrap &p, std::multimap<K, T *> &x) {
|
||||
if (p.mode == PointerWrap::MODE_READ) {
|
||||
for (auto it = x.begin(), end = x.end(); it != end; ++it) {
|
||||
delete it->second;
|
||||
for (auto &iter : x) {
|
||||
delete iter.second;
|
||||
}
|
||||
}
|
||||
T *dv = nullptr;
|
||||
|
@ -149,8 +149,8 @@ void Do(PointerWrap &p, std::multimap<K, T> &x) {
|
|||
template<class K, class T>
|
||||
void Do(PointerWrap &p, std::unordered_multimap<K, T *> &x) {
|
||||
if (p.mode == PointerWrap::MODE_READ) {
|
||||
for (auto it = x.begin(), end = x.end(); it != end; ++it) {
|
||||
delete it->second;
|
||||
for (auto &iter : x) {
|
||||
delete iter.second;
|
||||
}
|
||||
}
|
||||
T *dv = nullptr;
|
||||
|
|
|
@ -54,8 +54,14 @@ void DoSet(PointerWrap &p, std::set<T> &x) {
|
|||
template <class T>
|
||||
void Do(PointerWrap &p, std::set<T *> &x) {
|
||||
if (p.mode == PointerWrap::MODE_READ) {
|
||||
<<<<<<< HEAD
|
||||
for (auto it = x.begin(), end = x.end(); it != end; ++it) {
|
||||
delete *it;
|
||||
=======
|
||||
for (T* s : x) {
|
||||
if (s != nullptr)
|
||||
delete s;
|
||||
>>>>>>> 37ce2a4de1 ([Common/Data/File/Input/Net/Serialize/System/UI] Using for based loop C++17 and replaced on structured binding map C++17)
|
||||
}
|
||||
}
|
||||
DoSet(p, x);
|
||||
|
|
|
@ -353,21 +353,21 @@ static void ProcessHeldKeys(ViewGroup *root) {
|
|||
double now = time_now_d();
|
||||
|
||||
restart:
|
||||
for (std::set<HeldKey>::iterator iter = heldKeys.begin(); iter != heldKeys.end(); ++iter) {
|
||||
if (iter->triggerTime < now) {
|
||||
for (const auto &hk : heldKeys) {
|
||||
if (hk.triggerTime < now) {
|
||||
KeyInput key;
|
||||
key.keyCode = iter->key;
|
||||
key.deviceId = iter->deviceId;
|
||||
key.keyCode = hk.key;
|
||||
key.deviceId = hk.deviceId;
|
||||
key.flags = KEY_DOWN;
|
||||
KeyEvent(key, root);
|
||||
|
||||
focusMoves.push_back(key.keyCode);
|
||||
|
||||
// Cannot modify the current item when looping over a set, so let's do this instead.
|
||||
HeldKey hk = *iter;
|
||||
heldKeys.erase(hk);
|
||||
hk.triggerTime = now + repeatInterval;
|
||||
heldKeys.insert(hk);
|
||||
HeldKey k = hk;
|
||||
heldKeys.erase(k);
|
||||
k.triggerTime = now + repeatInterval;
|
||||
heldKeys.insert(k);
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,8 +163,8 @@ void ScreenManager::resized() {
|
|||
std::lock_guard<std::recursive_mutex> guard(inputLock_);
|
||||
// Have to notify the whole stack, otherwise there will be problems when going back
|
||||
// to non-top screens.
|
||||
for (auto iter = stack_.begin(); iter != stack_.end(); ++iter) {
|
||||
iter->screen->resized();
|
||||
for (auto &layer : stack_) {
|
||||
layer.screen->resized();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,8 +338,8 @@ void ScreenManager::pop() {
|
|||
|
||||
void ScreenManager::RecreateAllViews() {
|
||||
std::lock_guard<std::recursive_mutex> guard(inputLock_);
|
||||
for (auto it = stack_.begin(); it != stack_.end(); ++it) {
|
||||
it->screen->RecreateViews();
|
||||
for (auto &layer : stack_) {
|
||||
layer.screen->RecreateViews();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ void Event::Trigger(EventParams &e) {
|
|||
|
||||
// Call this from UI thread
|
||||
EventReturn Event::Dispatch(EventParams &e) {
|
||||
for (auto iter = handlers_.begin(); iter != handlers_.end(); ++iter) {
|
||||
if ((iter->func)(e) == UI::EVENT_DONE) {
|
||||
for (auto &handler : handlers_) {
|
||||
if ((handler.func)(e) == UI::EVENT_DONE) {
|
||||
// Event is handled, stop looping immediately. This event might even have gotten deleted.
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
|
|
@ -438,9 +438,9 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei
|
|||
}
|
||||
|
||||
// Then go right ahead and see if any of the children contain any better candidates.
|
||||
for (auto iter = views_.begin(); iter != views_.end(); ++iter) {
|
||||
if ((*iter)->IsViewGroup()) {
|
||||
ViewGroup *vg = static_cast<ViewGroup *>(*iter);
|
||||
for (auto *v : views_) {
|
||||
if (v->IsViewGroup()) {
|
||||
ViewGroup *vg = static_cast<ViewGroup *>(v);
|
||||
if (vg)
|
||||
result = vg->FindNeighbor(view, direction, result);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue