From 311c175f3184103950c72bc5c775174597430b83 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Jul 2017 01:31:22 +0300 Subject: Replace std::vector into macro STD_VECTOR. In most case it equal to std::vector except debug modes. Now it can be also mse::mstd::vector, but sadly this class not support all required features. --- src/fs/virtfs/fs.cpp | 38 +++++++++++++++++++------------------- src/fs/virtfs/fs.h | 2 +- src/fs/virtfs/fszip.cpp | 42 +++++++++++++++++++++--------------------- src/fs/virtfs/zipentry.h | 4 ++-- src/fs/virtfs/zipreader.cpp | 4 ++-- 5 files changed, 45 insertions(+), 45 deletions(-) (limited to 'src/fs') diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp index 9fe755560..2ec75ac05 100644 --- a/src/fs/virtfs/fs.cpp +++ b/src/fs/virtfs/fs.cpp @@ -51,7 +51,7 @@ namespace VirtFs { namespace { - std::vector mEntries; + STD_VECTOR mEntries; } // namespace void init(const std::string &restrict name) @@ -85,7 +85,7 @@ namespace VirtFs return FsDir::getUserDir(); } - std::vector &getEntries() + STD_VECTOR &getEntries() { return mEntries; } @@ -93,7 +93,7 @@ namespace VirtFs FsEntry *searchByRootInternal(const std::string &restrict root, const std::string &restrict subDir) { - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { const FsEntry *const entry = *it; if (entry->root == root && @@ -108,7 +108,7 @@ namespace VirtFs FsEntry *searchByTypeInternal(const std::string &restrict root, const FsEntryTypeT type) { - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { const FsEntry *const entry = *it; if (entry->root == root && @@ -134,7 +134,7 @@ namespace VirtFs if (findLast(rootDir, std::string(dirSeparator)) == false) rootDir += dirSeparator; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; if (entry->funcs->exists(entry, name, rootDir) == true) @@ -159,7 +159,7 @@ namespace VirtFs rootDir += dirSeparator; StringVect &names = list->names; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; entry->funcs->enumerate(entry, rootDir, names); @@ -183,7 +183,7 @@ namespace VirtFs if (findLast(rootDir, std::string(dirSeparator)) == false) rootDir += dirSeparator; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; entry->funcs->getFiles(entry, rootDir, list); @@ -205,7 +205,7 @@ namespace VirtFs if (findLast(rootDir, std::string(dirSeparator)) == false) rootDir += dirSeparator; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; entry->funcs->getFilesWithDir(entry, rootDir, list); @@ -228,7 +228,7 @@ namespace VirtFs if (findLast(rootDir, std::string(dirSeparator)) == false) rootDir += dirSeparator; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; entry->funcs->getDirs(entry, rootDir, list); @@ -248,7 +248,7 @@ namespace VirtFs if (findLast(dirName, std::string(dirSeparator)) == false) dirName += dirSeparator; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; bool isDirFlag(false); @@ -279,7 +279,7 @@ namespace VirtFs filename.c_str()); return nullptr; } - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; File *const file = entry->funcs->openRead(entry, filename); @@ -298,7 +298,7 @@ namespace VirtFs filename.c_str()); return nullptr; } - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; File *const file = entry->funcs->openWrite(entry, filename); @@ -317,7 +317,7 @@ namespace VirtFs filename.c_str()); return nullptr; } - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; File *const file = entry->funcs->openAppend(entry, filename); @@ -487,7 +487,7 @@ namespace VirtFs { subDir += dirSeparator; } - FOR_EACH (std::vector::iterator, it, mEntries) + FOR_EACH (STD_VECTOR::iterator, it, mEntries) { FsEntry *const entry = *it; if (entry->root == oldDir && @@ -679,7 +679,7 @@ namespace VirtFs reportAlways("Called unmount without zip archive"); return false; } - FOR_EACH (std::vector::iterator, it, mEntries) + FOR_EACH (STD_VECTOR::iterator, it, mEntries) { FsEntry *const entry = *it; if (entry->root == oldDir && @@ -719,7 +719,7 @@ namespace VirtFs { subDir += dirSeparator; } - FOR_EACH (std::vector::iterator, it, mEntries) + FOR_EACH (STD_VECTOR::iterator, it, mEntries) { FsEntry *const entry = *it; if (entry->root == oldDir && @@ -756,7 +756,7 @@ namespace VirtFs if (findLast(rootDir, std::string(dirSeparator)) == false) rootDir += dirSeparator; - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; std::string realDir; @@ -785,7 +785,7 @@ namespace VirtFs { FsDir::deinit(); FsZip::deinit(); - FOR_EACH (std::vector::iterator, it, mEntries) + FOR_EACH (STD_VECTOR::iterator, it, mEntries) { FsEntry *const entry = *it; if (entry->type == FsEntryType::Dir) @@ -865,7 +865,7 @@ namespace VirtFs filename.c_str()); return nullptr; } - FOR_EACH (std::vector::const_iterator, it, mEntries) + FOR_EACH (STD_VECTOR::const_iterator, it, mEntries) { FsEntry *const entry = *it; const char *const buf = entry->funcs->loadFile(entry, diff --git a/src/fs/virtfs/fs.h b/src/fs/virtfs/fs.h index ca67117ea..326a88d90 100644 --- a/src/fs/virtfs/fs.h +++ b/src/fs/virtfs/fs.h @@ -98,7 +98,7 @@ namespace VirtFs const Append append); bool unmountDirInternal(std::string oldDir, std::string subDir); - std::vector &getEntries(); + STD_VECTOR &getEntries(); FsEntry *searchByRootInternal(const std::string &restrict root, const std::string &restrict subDir); FsEntry *searchByTypeInternal(const std::string &restrict root, diff --git a/src/fs/virtfs/fszip.cpp b/src/fs/virtfs/fszip.cpp index 830909778..148df66fc 100644 --- a/src/fs/virtfs/fszip.cpp +++ b/src/fs/virtfs/fszip.cpp @@ -102,7 +102,7 @@ namespace FsZip filename = pathJoin(subDir, filename); dirName = pathJoin(subDir, dirName); } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -112,7 +112,7 @@ namespace FsZip return true; } } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mDirs) { @@ -136,14 +136,14 @@ namespace FsZip filename = pathJoin(subDir, filename); dirName = pathJoin(subDir, dirName); } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { if ((*it2)->fileName == filename) return true; } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mDirs) { @@ -163,7 +163,7 @@ namespace FsZip dirName = pathJoin(subDir, dirName); if (dirName == dirSeparator) { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -188,7 +188,7 @@ namespace FsZip } else { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -226,7 +226,7 @@ namespace FsZip dirName = pathJoin(subDir, dirName); if (dirName == dirSeparator) { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -250,7 +250,7 @@ namespace FsZip std::string dirName2 = pathJoin(dirName, fileName); if (findLast(dirName2, std::string(dirSeparator)) == false) dirName2 += dirSeparator; - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it, zipEntry->mDirs) { @@ -267,7 +267,7 @@ namespace FsZip } else { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -296,7 +296,7 @@ namespace FsZip { dirName2 += dirSeparator; } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it, zipEntry->mDirs) { @@ -327,7 +327,7 @@ namespace FsZip dirNameFull = dirName; if (dirNameFull == dirSeparator) { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -351,7 +351,7 @@ namespace FsZip std::string dirName2 = pathJoin(dirNameFull, fileName); if (findLast(dirName2, std::string(dirSeparator)) == false) dirName2 += dirSeparator; - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it, zipEntry->mDirs) { @@ -368,7 +368,7 @@ namespace FsZip } else { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -397,7 +397,7 @@ namespace FsZip { dirName2 += dirSeparator; } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it, zipEntry->mDirs) { @@ -425,7 +425,7 @@ namespace FsZip dirName = pathJoin(subDir, dirName); if (dirName == dirSeparator) { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -449,7 +449,7 @@ namespace FsZip std::string dirName2 = pathJoin(dirName, fileName); if (findLast(dirName2, std::string(dirSeparator)) == false) dirName2 += dirSeparator; - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it, zipEntry->mDirs) { @@ -466,7 +466,7 @@ namespace FsZip } else { - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -495,7 +495,7 @@ namespace FsZip { dirName2 += dirSeparator; } - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it, zipEntry->mDirs) { @@ -521,7 +521,7 @@ namespace FsZip std::string subDir = zipEntry->subDir; if (!subDir.empty()) dirName = pathJoin(subDir, dirName); - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mDirs) { @@ -546,7 +546,7 @@ namespace FsZip std::string subDir = zipEntry->subDir; if (!subDir.empty()) filename = pathJoin(subDir, filename); - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { @@ -679,7 +679,7 @@ namespace FsZip const std::string subDir = zipEntry->subDir; if (!subDir.empty()) filename = pathJoin(subDir, filename); - FOR_EACH (std::vector::const_iterator, + FOR_EACH (STD_VECTOR::const_iterator, it2, zipEntry->mHeaders) { diff --git a/src/fs/virtfs/zipentry.h b/src/fs/virtfs/zipentry.h index ddb742b4f..3d8a21ced 100644 --- a/src/fs/virtfs/zipentry.h +++ b/src/fs/virtfs/zipentry.h @@ -42,8 +42,8 @@ struct ZipEntry final : public FsEntry ~ZipEntry(); - std::vector mHeaders; - std::vector mDirs; + STD_VECTOR mHeaders; + STD_VECTOR mDirs; }; } // namespace VirtFs diff --git a/src/fs/virtfs/zipreader.cpp b/src/fs/virtfs/zipreader.cpp index 3302fd7c0..017686e6b 100644 --- a/src/fs/virtfs/zipreader.cpp +++ b/src/fs/virtfs/zipreader.cpp @@ -82,8 +82,8 @@ namespace ZipReader return false; } const std::string archiveName = entry->root; - std::vector &restrict headers = entry->mHeaders; - std::vector &restrict dirs = entry->mDirs; + STD_VECTOR &restrict headers = entry->mHeaders; + STD_VECTOR &restrict dirs = entry->mDirs; FILE *restrict const arcFile = fopen(archiveName.c_str(), "rb"); if (arcFile == nullptr) -- cgit v1.2.3-70-g09d2