From be7b8379e1fac7194dc6beee7b136ff64c153b5e Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 31 May 2018 16:45:40 +0200 Subject: [PATCH] small prettification --- src/common/syngroups.cpp | 29 +++++++++++++++-------------- src/common/syngroups.h | 7 +++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/common/syngroups.cpp b/src/common/syngroups.cpp index efbc42e9..b89d22f7 100644 --- a/src/common/syngroups.cpp +++ b/src/common/syngroups.cpp @@ -68,11 +68,11 @@ SynGroups::SynGroups() bool SynGroups::setfile(const string& fn) { - LOGDEB("SynGroups::setfile(" << (fn) << ")\n" ); + LOGDEB("SynGroups::setfile(" << fn << ")\n"); if (!m) { m = new Internal; if (!m) { - LOGERR("SynGroups:setfile:: new Internal failed: no mem ?\n" ); + LOGERR("SynGroups:setfile:: new Internal failed: no mem ?\n"); return false; } } @@ -86,7 +86,7 @@ bool SynGroups::setfile(const string& fn) ifstream input; input.open(fn.c_str(), ios::in); if (!input.is_open()) { - LOGERR("SynGroups:setfile:: could not open " << (fn) << " errno " << (errno) << "\n" ); + LOGSYSERR("SynGroups:setfile", "open", fn); return false; } @@ -101,7 +101,7 @@ bool SynGroups::setfile(const string& fn) getline(input, cline); if (!input.good()) { if (input.bad()) { - LOGERR("Syngroup::setfile(" << (fn) << "):Parse: input.bad()\n" ); + LOGERR("Syngroup::setfile(" << fn << "):Parse: input.bad()\n"); return false; } // Must be eof ? But maybe we have a partial line which @@ -142,23 +142,25 @@ bool SynGroups::setfile(const string& fn) vector words; if (!stringToStrings(line, words)) { - LOGERR("SynGroups:setfile: " << (fn) << ": bad line " << (lnum) << ": " << (line) << "\n" ); + LOGERR("SynGroups:setfile: " << fn << ": bad line " << lnum << + ": " << line << "\n"); continue; } if (words.empty()) continue; if (words.size() == 1) { - LOGERR("Syngroup::setfile(" << (fn) << "):single term group at line " << (lnum) << " ??\n" ); + LOGERR("Syngroup::setfile(" << fn << "):single term group at line " + << lnum << " ??\n"); continue; } m->groups.push_back(words); - for (vector::const_iterator it = words.begin(); - it != words.end(); it++) { - m->terms[*it] = m->groups.size()-1; + for (const auto& word : words) { + m->terms[word] = m->groups.size()-1; } - LOGDEB1("SynGroups::setfile: group: [" << (stringsToString(m->groups.back())) << "]\n" ); + LOGDEB1("SynGroups::setfile: group: [" << + stringsToString(m->groups.back()) << "]\n"); } m->ok = true; return true; @@ -170,16 +172,15 @@ vector SynGroups::getgroup(const string& term) if (!ok()) return ret; - std::unordered_map::const_iterator it1 = - m->terms.find(term); + const auto it1 = m->terms.find(term); if (it1 == m->terms.end()) { - LOGDEB1("SynGroups::getgroup: [" << (term) << "] not found in direct map\n" ); + LOGDEB1("SynGroups::getgroup: [" << term<<"] not found in direct map\n"); return ret; } unsigned int idx = it1->second; if (idx >= m->groups.size()) { - LOGERR("SynGroups::getgroup: line index higher than line count !\n" ); + LOGERR("SynGroups::getgroup: line index higher than line count !\n"); return ret; } return m->groups[idx]; diff --git a/src/common/syngroups.h b/src/common/syngroups.h index 62a71523..c490b09f 100644 --- a/src/common/syngroups.h +++ b/src/common/syngroups.h @@ -28,14 +28,17 @@ class SynGroups { public: SynGroups(); ~SynGroups(); + SynGroups(const SynGroups&) = delete; + SynGroups& operator=(const SynGroups&) = delete; + SynGroups(const SynGroups&&) = delete; + SynGroups& operator=(const SynGroups&&) = delete; + bool setfile(const std::string& fname); std::vector getgroup(const std::string& term); bool ok(); private: class Internal; Internal *m; - SynGroups(const SynGroups&); - SynGroups& operator=(const SynGroups&); }; #endif /* _SYNGROUPS_H_INCLUDED_ */