diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Swift/Controllers/StatusCache.cpp | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swift/Controllers/StatusCache.cpp')
-rw-r--r-- | Swift/Controllers/StatusCache.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/Swift/Controllers/StatusCache.cpp b/Swift/Controllers/StatusCache.cpp index d00d7f6..ce4391d 100644 --- a/Swift/Controllers/StatusCache.cpp +++ b/Swift/Controllers/StatusCache.cpp @@ -24,9 +24,9 @@ namespace Swift { static const size_t MAX_ENTRIES = 200; StatusCache::StatusCache(ApplicationPathProvider* paths) { - paths_ = paths; - path_ = paths_->getDataDir() / "StatusCache"; - loadRecents(); + paths_ = paths; + path_ = paths_->getDataDir() / "StatusCache"; + loadRecents(); } StatusCache::~StatusCache() { @@ -34,71 +34,71 @@ StatusCache::~StatusCache() { } std::vector<StatusCache::PreviousStatus> StatusCache::getMatches(const std::string& substring, size_t maxCount) const { - std::vector<PreviousStatus> matches; - foreach (const PreviousStatus& status, previousStatuses_) { - if (substring.empty() || (boost::algorithm::ifind_first(status.first, substring) && substring != status.first)) { - matches.push_back(status); - if (matches.size() == maxCount) { - break; - } - } - } - return matches; + std::vector<PreviousStatus> matches; + foreach (const PreviousStatus& status, previousStatuses_) { + if (substring.empty() || (boost::algorithm::ifind_first(status.first, substring) && substring != status.first)) { + matches.push_back(status); + if (matches.size() == maxCount) { + break; + } + } + } + return matches; } void StatusCache::addRecent(const std::string& text, StatusShow::Type type) { - if (text.empty()) { - return; - } - previousStatuses_.remove_if(lambda::bind(&PreviousStatus::first, lambda::_1) == text && lambda::bind(&PreviousStatus::second, lambda::_1) == type); - previousStatuses_.push_front(PreviousStatus(text, type)); - for (size_t i = previousStatuses_.size(); i > MAX_ENTRIES; i--) { - previousStatuses_.pop_back(); - } - saveRecents(); + if (text.empty()) { + return; + } + previousStatuses_.remove_if(lambda::bind(&PreviousStatus::first, lambda::_1) == text && lambda::bind(&PreviousStatus::second, lambda::_1) == type); + previousStatuses_.push_front(PreviousStatus(text, type)); + for (size_t i = previousStatuses_.size(); i > MAX_ENTRIES; i--) { + previousStatuses_.pop_back(); + } + saveRecents(); } void StatusCache::loadRecents() { - try { - if (boost::filesystem::exists(path_)) { - ByteArray data; - readByteArrayFromFile(data, path_); - std::string stringData = byteArrayToString(data); - std::vector<std::string> lines; - boost::split(lines, stringData, boost::is_any_of("\n")); - foreach (const std::string& line, lines) { - std::vector<std::string> bits; - boost::split(bits, line, boost::is_any_of("\t")); - if (bits.size() < 2) { - continue; - } - StatusShow::Type type; - type = static_cast<StatusShow::Type>(boost::lexical_cast<size_t>(bits[0])); - previousStatuses_.push_back(PreviousStatus(boost::trim_copy(bits[1]), type)); - } - } - } - catch (const boost::filesystem::filesystem_error& e) { - std::cerr << "ERROR: " << e.what() << std::endl; - } + try { + if (boost::filesystem::exists(path_)) { + ByteArray data; + readByteArrayFromFile(data, path_); + std::string stringData = byteArrayToString(data); + std::vector<std::string> lines; + boost::split(lines, stringData, boost::is_any_of("\n")); + foreach (const std::string& line, lines) { + std::vector<std::string> bits; + boost::split(bits, line, boost::is_any_of("\t")); + if (bits.size() < 2) { + continue; + } + StatusShow::Type type; + type = static_cast<StatusShow::Type>(boost::lexical_cast<size_t>(bits[0])); + previousStatuses_.push_back(PreviousStatus(boost::trim_copy(bits[1]), type)); + } + } + } + catch (const boost::filesystem::filesystem_error& e) { + std::cerr << "ERROR: " << e.what() << std::endl; + } } void StatusCache::saveRecents() { - try { - if (!boost::filesystem::exists(path_.parent_path())) { - boost::filesystem::create_directories(path_.parent_path()); - } - boost::filesystem::ofstream file(path_); - foreach (const PreviousStatus& recent, previousStatuses_) { - std::string message = recent.first; - boost::replace_all(message, "\t", " "); - file << recent.second << "\t" << message << std::endl; - } - file.close(); - } - catch (const boost::filesystem::filesystem_error& e) { - std::cerr << "ERROR: " << e.what() << std::endl; - } + try { + if (!boost::filesystem::exists(path_.parent_path())) { + boost::filesystem::create_directories(path_.parent_path()); + } + boost::filesystem::ofstream file(path_); + foreach (const PreviousStatus& recent, previousStatuses_) { + std::string message = recent.first; + boost::replace_all(message, "\t", " "); + file << recent.second << "\t" << message << std::endl; + } + file.close(); + } + catch (const boost::filesystem::filesystem_error& e) { + std::cerr << "ERROR: " << e.what() << std::endl; + } } } |