1
0
mirror of https://github.com/wfjm/w11.git synced 2026-02-09 01:51:12 +00:00

use auto; use emplace,make_pair

This commit is contained in:
wfjm
2018-11-16 18:26:00 +01:00
parent e1abc27983
commit 4e1f91b0a1
24 changed files with 110 additions and 141 deletions

View File

@@ -1,4 +1,4 @@
// $Id: ReventLoop.cpp 1049 2018-09-22 13:56:52Z mueller $
// $Id: ReventLoop.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.2.2 use emplace_back
// 2017-04-07 868 1.2.1 Dump(): add detail arg
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), add UnStop,StopPending
// 2013-04-27 511 1.1.3 BUGFIX: logic in DoCall() fixed (loop range)
@@ -90,7 +91,7 @@ void ReventLoop::AddPollHandler(const pollhdl_t& pollhdl,
}
}
fPollDsc.push_back(PollDsc(pollhdl,fd,events));
fPollDsc.emplace_back(PollDsc(pollhdl,fd,events));
fUpdatePoll = true;
if (fspLog && fTraceLevel >= 1) {

View File

@@ -1,6 +1,6 @@
// $Id: RlinkAddrMap.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RlinkAddrMap.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.0.4 use auto; use emplace,make_pair
// 2017-04-07 868 1.0.3 Dump(): add detail arg
// 2013-02-03 481 1.0.2 use Rexception
// 2011-11-28 434 1.0.1 Print(): use proper cast for lp64 compatibility
@@ -76,8 +77,8 @@ bool RlinkAddrMap::Insert(const std::string& name, uint16_t addr)
if (fNameMap.find(name) != fNameMap.end()) return false;
if (fAddrMap.find(addr) != fAddrMap.end()) return false;
fNameMap.insert(nmap_val_t(name, addr));
fAddrMap.insert(amap_val_t(addr, name));
fNameMap.emplace(make_pair(name, addr));
fAddrMap.emplace(make_pair(addr, name));
fMaxLength = max(fMaxLength, name.length());
return true;
@@ -88,7 +89,7 @@ bool RlinkAddrMap::Insert(const std::string& name, uint16_t addr)
bool RlinkAddrMap::Erase(const std::string& name)
{
nmap_cit_t it = fNameMap.find(name);
auto it = fNameMap.find(name);
if (it == fNameMap.end()) return false;
fMaxLength = 0; // force recalculate
@@ -107,7 +108,7 @@ bool RlinkAddrMap::Erase(const std::string& name)
bool RlinkAddrMap::Erase(uint16_t addr)
{
amap_cit_t it = fAddrMap.find(addr);
auto it = fAddrMap.find(addr);
if (it == fAddrMap.end()) return false;
fMaxLength = 0; // force recalculate
@@ -126,7 +127,7 @@ bool RlinkAddrMap::Erase(uint16_t addr)
bool RlinkAddrMap::Find(const std::string& name, uint16_t& addr) const
{
nmap_cit_t it = fNameMap.find(name);
auto it = fNameMap.find(name);
if (it == fNameMap.end()) return false;
addr = it->second;
@@ -139,7 +140,7 @@ bool RlinkAddrMap::Find(const std::string& name, uint16_t& addr) const
bool RlinkAddrMap::Find(uint16_t addr, std::string& name) const
{
amap_cit_t it = fAddrMap.find(addr);
auto it = fAddrMap.find(addr);
if (it == fAddrMap.end()) return false;
name = it->second;
@@ -153,7 +154,7 @@ bool RlinkAddrMap::Find(uint16_t addr, std::string& name) const
size_t RlinkAddrMap::MaxNameLength() const
{
if (fMaxLength == 0) {
for (amap_cit_t it=fAddrMap.begin(); it!=fAddrMap.end(); it++) {
for (auto it=fAddrMap.begin(); it!=fAddrMap.end(); it++) {
fMaxLength = max(fMaxLength, (it->second).length());
}
}
@@ -168,7 +169,7 @@ void RlinkAddrMap::Print(std::ostream& os, int ind) const
size_t maxlen = max(((size_t) 6), MaxNameLength());
RosFill bl(ind);
for (amap_cit_t it=fAddrMap.begin(); it!=fAddrMap.end(); it++) {
for (auto it=fAddrMap.begin(); it!=fAddrMap.end(); it++) {
os << bl << RosPrintf((it->second).c_str(), "-s",maxlen)
<< " : " << RosPrintf(it->first, "$x0", 6)
<< " " << RosPrintf(it->first, "o0", 6) << endl;

View File

@@ -1,4 +1,4 @@
// $Id: RlinkAddrMap.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RlinkAddrMap.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -36,13 +36,7 @@ namespace Retro {
class RlinkAddrMap {
public:
typedef std::map<std::string, uint16_t> nmap_t;
typedef nmap_t::iterator nmap_it_t;
typedef nmap_t::const_iterator nmap_cit_t;
typedef nmap_t::value_type nmap_val_t;
typedef std::map<uint16_t, std::string> amap_t;
typedef amap_t::iterator amap_it_t;
typedef amap_t::const_iterator amap_cit_t;
typedef amap_t::value_type amap_val_t;
RlinkAddrMap();
~RlinkAddrMap();

View File

@@ -1,4 +1,4 @@
// $Id: RlinkPortCuff.cpp 1060 2018-10-27 11:32:39Z mueller $
// $Id: RlinkPortCuff.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2012-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.7 use auto
// 2018-10-27 1059 1.1.6 coverity fixup (uncaught exception in dtor)
// 2017-04-15 875 1.1.5 Open(): set default scheme
// 2017-03-04 858 1.1.4 use clock_gettime instead of gettimeofday
@@ -235,7 +236,7 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg)
// 2. libusb callbacks
const libusb_pollfd** plist = libusb_get_pollfds(fpUsbContext);
for (const libusb_pollfd** p = plist; *p !=0; p++) {
for (auto p = plist; *p !=0; p++) {
PollfdAdd((*p)->fd, (*p)->events);
}
::free(plist);

View File

@@ -1,4 +1,4 @@
// $Id: RtclRlinkConnect.cpp 1048 2018-09-22 07:41:46Z mueller $
// $Id: RtclRlinkConnect.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.6.2 use auto
// 2018-09-16 1047 1.6.1 coverity fixup (uninitialized scalar)
// 2017-04-29 888 1.6 drop M_rawio; add M_rawread,M_rawrblk,M_rawwblk
// 2017-04-22 883 1.5.2 M_amap: -testname opt addr check; add hasrbmon get
@@ -538,8 +539,8 @@ int RtclRlinkConnect::M_amap(RtclArgs& args)
} else { // amap
RtclOPtr plist(Tcl_NewListObj(0, nullptr));
const RlinkAddrMap::amap_t amap = addrmap.Amap();
for (RlinkAddrMap::amap_cit_t it=amap.begin(); it!=amap.end(); it++) {
const auto amap = addrmap.Amap();
for (auto it=amap.begin(); it!=amap.end(); it++) {
Tcl_Obj* tpair[2];
tpair[0] = Tcl_NewIntObj(it->first);
tpair[1] = Tcl_NewStringObj((it->second).c_str(),(it->second).length());

View File

@@ -1,6 +1,6 @@
// $Id: RtclRlinkServer.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclRlinkServer.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.2 use auto
// 2017-04-02 865 1.1.1 M_dump: use GetArgsDump and Dump detail
// 2015-04-04 662 1.1 add M_get, M_set; remove 'server -trace'
// 2014-08-22 584 1.0.6 use nullptr
@@ -105,7 +106,7 @@ RtclRlinkServer::RtclRlinkServer(Tcl_Interp* interp, const char* name)
RtclRlinkServer::~RtclRlinkServer()
{
for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
for (auto it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
delete (*it);
}
}
@@ -196,7 +197,7 @@ int RtclRlinkServer::M_attn(RtclArgs& args)
uint16_t mask=0;
if (!args.GetArg("mask", mask)) return kERR;
if (!args.AllDone()) return kERR;
for (alist_it_t it = fAttnHdl.end(); it != fAttnHdl.begin(); ) {
for (auto it = fAttnHdl.end(); it != fAttnHdl.begin(); ) {
it--;
if ((*it)->Mask() == mask) {
fAttnHdl.erase(it);
@@ -212,7 +213,7 @@ int RtclRlinkServer::M_attn(RtclArgs& args)
if (!args.GetArg("mask", mask)) return kERR;
if (!args.AllDone()) return kERR;
RtclOPtr pres(Tcl_NewListObj(0,nullptr));
for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
for (auto it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
if ((*it)->Mask() & mask) {
RtclOPtr pele(Tcl_NewListObj(0,nullptr));
Tcl_ListObjAppendElement(nullptr, pele,
@@ -229,7 +230,7 @@ int RtclRlinkServer::M_attn(RtclArgs& args)
if (!args.GetArg("mask", mask)) return kERR;
if (!args.AllDone()) return kERR;
int nhdl = 0;
for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
for (auto it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
if ((*it)->Mask() & mask) {
nhdl += 1;
int rc = Tcl_EvalObjEx(interp, (*it)->Script(), TCL_EVAL_GLOBAL);
@@ -243,7 +244,7 @@ int RtclRlinkServer::M_attn(RtclArgs& args)
} else if (opt == "-list") { // attn -list
if (!args.AllDone()) return kERR;
vector<uint16_t> vres;
for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
for (auto it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
vres.push_back((*it)->Mask());
}
args.SetResult(Rtcl::NewListIntObj(vres));
@@ -253,7 +254,7 @@ int RtclRlinkServer::M_attn(RtclArgs& args)
if (!args.OptValid()) return kERR;
if (!args.AllDone()) return kERR;
uint16_t mask=0;
for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
for (auto it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) {
mask |= (*it)->Mask();
}
args.SetResult(mask);

View File

@@ -1,4 +1,4 @@
// $Id: RtclCmdBase.cpp 1048 2018-09-22 07:41:46Z mueller $
// $Id: RtclCmdBase.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.2 use auto
// 2017-04-02 865 1.1.1 add GetArgsDump()
// 2017-04-02 863 1.1 add DelMeth(),TstMeth(); add M_info() and '?'
// rename fMapMeth -> fMethMap
@@ -96,7 +97,7 @@ int RtclCmdBase::DispatchCmd(RtclArgs& args)
if (it_match==fMethMap.end() ||
name!=it_match->first.substr(0,name.length())) {
mmap_cit_t it_un = fMethMap.find("$unknown"); // unknown method registered ?
auto it_un = fMethMap.find("$unknown"); // unknown method registered ?
if (it_un!=fMethMap.end()) {
return (it_un->second)(args);
}
@@ -115,7 +116,7 @@ int RtclCmdBase::DispatchCmd(RtclArgs& args)
// check for ambiguous substring match
if (name != it_match->first) {
mmap_cit_t it1 = it_match;
auto it1 = it_match;
it1++;
if (it1!=fMethMap.end() && name==it1->first.substr(0,name.length())) {
Tcl_AppendResult(interp, "-E: ambiguous option '",

View File

@@ -1,4 +1,4 @@
// $Id: RtclCmdBase.hpp 1052 2018-09-30 08:10:52Z mueller $
// $Id: RtclCmdBase.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -47,7 +47,6 @@ namespace Retro {
typedef std::map<std::string, methfo_t> mmap_t;
typedef mmap_t::iterator mmap_it_t;
typedef mmap_t::const_iterator mmap_cit_t;
typedef mmap_t::value_type mmap_val_t;
RtclCmdBase();
virtual ~RtclCmdBase();

View File

@@ -1,6 +1,6 @@
// $Id: RtclContext.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclContext.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.0.5 use auto; use emplace,make_pair
// 2017-02-04 866 1.0.4 rename fMapContext -> fContextMap
// 2013-02-03 481 1.0.3 use Rexception
// 2013-01-12 474 1.0.2 add FindProxy() method
@@ -42,9 +43,6 @@ using namespace std;
// all method definitions in namespace Retro
namespace Retro {
typedef std::pair<RtclContext::cset_it_t, bool> cset_ins_t;
typedef std::pair<RtclContext::pset_it_t, bool> pset_ins_t;
RtclContext::xmap_t RtclContext::fContextMap;
//------------------------------------------+-----------------------------------
@@ -67,7 +65,7 @@ RtclContext::~RtclContext()
void RtclContext::RegisterClass(RtclClassBase* pobj)
{
cset_ins_t ret = fSetClass.insert(pobj);
auto ret = fSetClass.insert(pobj);
if (ret.second == false) // or use !(ret.second)
throw Rexception("RtclContext::RegisterClass()",
"Bad args: duplicate pointer");
@@ -88,7 +86,7 @@ void RtclContext::UnRegisterClass(RtclClassBase* pobj)
void RtclContext::RegisterProxy(RtclProxyBase* pobj)
{
pset_ins_t ret = fSetProxy.insert(pobj);
auto ret = fSetProxy.insert(pobj);
if (ret.second == false) // or use !(ret.second)
throw Rexception("RtclContext::RegisterProxy()",
"Bad args: duplicate pointer");
@@ -109,7 +107,7 @@ void RtclContext::UnRegisterProxy(RtclProxyBase* pobj)
bool RtclContext::CheckProxy(RtclProxyBase* pobj)
{
pset_it_t it = fSetProxy.find(pobj);
auto it = fSetProxy.find(pobj);
return it != fSetProxy.end();
}
@@ -118,7 +116,7 @@ bool RtclContext::CheckProxy(RtclProxyBase* pobj)
bool RtclContext::CheckProxy(RtclProxyBase* pobj, const string& type)
{
pset_it_t it = fSetProxy.find(pobj);
auto it = fSetProxy.find(pobj);
if (it == fSetProxy.end()) return false;
return (*it)->Type() == type;
}
@@ -130,7 +128,7 @@ void RtclContext::ListProxy(std::vector<RtclProxyBase*>& list,
const std::string& type)
{
list.clear();
for (pset_it_t it = fSetProxy.begin(); it != fSetProxy.end(); it++) {
for (auto it = fSetProxy.begin(); it != fSetProxy.end(); it++) {
if (type.length() == 0 || (*it)->Type()==type) {
list.push_back(*it);
}
@@ -144,7 +142,7 @@ void RtclContext::ListProxy(std::vector<RtclProxyBase*>& list,
RtclProxyBase* RtclContext::FindProxy(const std::string& type,
const std::string& name)
{
for (pset_it_t it = fSetProxy.begin(); it != fSetProxy.end(); it++) {
for (auto it = fSetProxy.begin(); it != fSetProxy.end(); it++) {
if (type.length() == 0 || (*it)->Type()==type) {
const char* cmdname = Tcl_GetCommandName(fInterp, (*it)->Token());
if (name == cmdname) return *it;
@@ -159,12 +157,12 @@ RtclProxyBase* RtclContext::FindProxy(const std::string& type,
RtclContext& RtclContext::Find(Tcl_Interp* interp)
{
RtclContext* pcntx = 0;
xmap_it_t it = fContextMap.find(interp);
auto it = fContextMap.find(interp);
if (it != fContextMap.end()) {
pcntx = it->second;
} else {
pcntx = new RtclContext(interp);
fContextMap.insert(xmap_val_t(interp, pcntx));
fContextMap.emplace(make_pair(interp, pcntx));
Tcl_CreateExitHandler((Tcl_ExitProc*) ThunkTclExitProc, (ClientData) pcntx);
}

View File

@@ -1,4 +1,4 @@
// $Id: RtclContext.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclContext.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -45,12 +45,8 @@ namespace Retro {
class RtclContext : private boost::noncopyable {
public:
typedef std::set<RtclClassBase*> cset_t;
typedef cset_t::iterator cset_it_t;
typedef std::set<RtclProxyBase*> pset_t;
typedef pset_t::iterator pset_it_t;
typedef std::map<Tcl_Interp*, RtclContext*> xmap_t;
typedef xmap_t::iterator xmap_it_t;
typedef xmap_t::value_type xmap_val_t;
explicit RtclContext(Tcl_Interp* interp);
virtual ~RtclContext();

View File

@@ -1,6 +1,6 @@
// $Id: RtclGetList.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclGetList.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.1 use auto; use emplace,make_pair
// 2015-01-08 631 1.1 add Clear(), add '?' (key list) and '*' (kv list)
// 2014-08-22 584 1.0.1 use nullptr
// 2013-02-12 487 1.0 Initial version
@@ -53,7 +54,7 @@ RtclGetList::RtclGetList()
RtclGetList::~RtclGetList()
{
for (map_cit_t it=fMap.begin(); it != fMap.end(); it++) {
for (auto it=fMap.begin(); it != fMap.end(); it++) {
delete (it->second);
}
}
@@ -63,8 +64,7 @@ RtclGetList::~RtclGetList()
void RtclGetList::Add(const std::string& name, RtclGetBase* pget)
{
typedef std::pair<Retro::RtclGetList::map_it_t, bool> map_ins_t;
map_ins_t ret = fMap.insert(map_val_t(name, pget));
auto ret = fMap.emplace(make_pair(name, pget));
if (ret.second == false)
throw Rexception("RtclGetList::Add:",
string("Bad args: duplicate name: '") + name + "'");
@@ -110,14 +110,14 @@ int RtclGetList::M_get(RtclArgs& args)
return TCL_OK;
}
map_cit_t it = fMap.lower_bound(pname);
auto it = fMap.lower_bound(pname);
// complain if not found
if (it == fMap.end() || pname != it->first.substr(0,pname.length())) {
Tcl_AppendResult(interp, "-E: unknown property '", pname.c_str(),
"': must be ", nullptr);
const char* delim = "";
for (map_cit_t it1=fMap.begin(); it1!=fMap.end(); it1++) {
for (auto it1=fMap.begin(); it1!=fMap.end(); it1++) {
Tcl_AppendResult(interp, delim, it1->first.c_str(), nullptr);
delim = ",";
}
@@ -125,7 +125,7 @@ int RtclGetList::M_get(RtclArgs& args)
}
// check for ambiguous substring match
map_cit_t it1 = it;
auto it1 = it;
it1++;
if (it1!=fMap.end() && pname==it1->first.substr(0,pname.length())) {
Tcl_AppendResult(interp, "-E: ambiguous property name '", pname.c_str(),

View File

@@ -1,4 +1,4 @@
// $Id: RtclGetList.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclGetList.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -55,9 +55,6 @@ namespace Retro {
protected:
typedef std::map<std::string, RtclGetBase*> map_t;
typedef map_t::iterator map_it_t;
typedef map_t::const_iterator map_cit_t;
typedef map_t::value_type map_val_t;
map_t fMap;
};

View File

@@ -1,6 +1,6 @@
// $Id: RtclNameSet.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclNameSet.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.2 use auto
// 2014-08-22 584 1.1.1 use nullptr
// 2013-05-19 521 1.1 add CheckMatch()
// 2013-02-03 481 1.0.1 use Rexception
@@ -41,8 +42,6 @@ using namespace std;
// all method definitions in namespace Retro
namespace Retro {
typedef std::pair<RtclNameSet::nset_it_t, bool> nset_ins_t;
//------------------------------------------+-----------------------------------
//! Default constructor
@@ -61,7 +60,7 @@ RtclNameSet::RtclNameSet(const std::string& nset)
size_t iend = nset.find_first_of('|', ibeg);
if (iend-ibeg > 0) {
string name(nset, ibeg, iend-ibeg);
nset_ins_t ret = fSet.insert(name);
auto ret = fSet.insert(name);
if (ret.second == false) // or use !(ret.second)
throw Rexception("RtclNameSet::<ctor>", "Bad args: " +
string("duplicate name '") + name +
@@ -97,7 +96,7 @@ int RtclNameSet::CheckMatch(Tcl_Interp* interp, std::string& rval,
const std::string& tval, bool misserr) const
{
rval.clear();
nset_cit_t it = fSet.lower_bound(tval);
auto it = fSet.lower_bound(tval);
// no leading substring match
if (it==fSet.end() || tval!=it->substr(0,tval.length())) {
@@ -105,7 +104,7 @@ int RtclNameSet::CheckMatch(Tcl_Interp* interp, std::string& rval,
Tcl_AppendResult(interp, "-E: bad option '", tval.c_str(),
"': must be ", nullptr);
const char* delim = "";
for (nset_cit_t it1=fSet.begin(); it1!=fSet.end(); it1++) {
for (auto it1=fSet.begin(); it1!=fSet.end(); it1++) {
Tcl_AppendResult(interp, delim, it1->c_str(), nullptr);
delim = ",";
}
@@ -115,7 +114,7 @@ int RtclNameSet::CheckMatch(Tcl_Interp* interp, std::string& rval,
// check for ambiguous substring match
if (tval != *it) {
nset_cit_t it1 = it;
auto it1 = it;
it1++;
if (it1!=fSet.end() && tval==it1->substr(0,tval.length())) {
Tcl_AppendResult(interp, "-E: ambiguous option '", tval.c_str(),

View File

@@ -1,6 +1,6 @@
// $Id: RtclSetList.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclSetList.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.1 use auto; use emplace,make_pair
// 2015-01-08 631 1.1 add Clear(), add '?' (key list)
// 2014-08-22 584 1.0.1 use nullptr
// 2013-02-12 487 1.0 Initial version
@@ -53,7 +54,7 @@ RtclSetList::RtclSetList()
RtclSetList::~RtclSetList()
{
for (map_cit_t it=fMap.begin(); it != fMap.end(); it++) {
for (auto it=fMap.begin(); it != fMap.end(); it++) {
delete (it->second);
}
}
@@ -63,8 +64,7 @@ RtclSetList::~RtclSetList()
void RtclSetList::Add(const std::string& name, RtclSetBase* pset)
{
typedef std::pair<Retro::RtclSetList::map_it_t, bool> map_ins_t;
map_ins_t ret = fMap.insert(map_val_t(name, pset));
auto ret = fMap.emplace(make_pair(name, pset));
if (ret.second == false)
throw Rexception("RtclSetList::Add:",
string("Bad args: duplicate name: '") + name + "'");
@@ -100,14 +100,14 @@ int RtclSetList::M_set(RtclArgs& args)
return TCL_OK;
}
map_cit_t it = fMap.lower_bound(pname);
auto it = fMap.lower_bound(pname);
// complain if not found
if (it == fMap.end() || pname != it->first.substr(0,pname.length())) {
Tcl_AppendResult(interp, "-E: unknown property '", pname.c_str(),
"': must be ", nullptr);
const char* delim = "";
for (map_cit_t it1=fMap.begin(); it1!=fMap.end(); it1++) {
for (auto it1=fMap.begin(); it1!=fMap.end(); it1++) {
Tcl_AppendResult(interp, delim, it1->first.c_str(), nullptr);
delim = ",";
}
@@ -115,7 +115,7 @@ int RtclSetList::M_set(RtclArgs& args)
}
// check for ambiguous substring match
map_cit_t it1 = it;
auto it1 = it;
it1++;
if (it1!=fMap.end() && pname==it1->first.substr(0,pname.length())) {
Tcl_AppendResult(interp, "-E: ambiguous property name '", pname.c_str(),

View File

@@ -1,4 +1,4 @@
// $Id: RtclSetList.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RtclSetList.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -55,9 +55,6 @@ namespace Retro {
protected:
typedef std::map<std::string, RtclSetBase*> map_t;
typedef map_t::iterator map_it_t;
typedef map_t::const_iterator map_cit_t;
typedef map_t::value_type map_val_t;
map_t fMap;
};

View File

@@ -1,6 +1,6 @@
// $Id: RlogFileCatalog.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RlogFileCatalog.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.0.1 use auto; use make_pair,emplace
// 2013-02-22 491 1.0 Initial version
// ---------------------------------------------------------------------------
@@ -50,13 +51,13 @@ RlogFileCatalog& RlogFileCatalog::Obj()
const boost::shared_ptr<RlogFile>&
RlogFileCatalog::FindOrCreate(const std::string& name)
{
map_cit_t it = fMap.find(name);
auto it = fMap.find(name);
if (it != fMap.end()) return it->second;
boost::shared_ptr<RlogFile> sptr(new RlogFile());
it = fMap.insert(fMap.begin(), map_val_t(name, sptr));
auto pitb = fMap.emplace(make_pair(name, sptr));
return it->second;
return pitb.first->second;
}
//------------------------------------------+-----------------------------------

View File

@@ -1,4 +1,4 @@
// $Id: RlogFileCatalog.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RlogFileCatalog.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2011-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -47,9 +47,6 @@ namespace Retro {
protected:
typedef std::map<std::string, boost::shared_ptr<RlogFile>> map_t;
typedef map_t::iterator map_it_t;
typedef map_t::const_iterator map_cit_t;
typedef map_t::value_type map_val_t;
map_t fMap; //!< name->rlogfile map
};

View File

@@ -1,6 +1,6 @@
// $Id: RparseUrl.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RparseUrl.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-11-09 1066 1.1.1 use auto; use emplace,make_pair
// 2017-04-15 875 1.1 add Set() with default scheme handling
// 2015-06-04 686 1.0.2 Set(): add check that optlist is enclosed by '|'
// 2013-02-23 492 1.0.1 add static FindScheme(); allow no or empty scheme
@@ -163,7 +164,7 @@ void RparseUrl::Clear()
bool RparseUrl::FindOpt(const std::string& name) const
{
omap_cit_t it = fOptMap.find(name);
auto it = fOptMap.find(name);
if (it == fOptMap.end()) return false;
return true;
}
@@ -173,7 +174,7 @@ bool RparseUrl::FindOpt(const std::string& name) const
bool RparseUrl::FindOpt(const std::string& name, std::string& value) const
{
omap_cit_t it = fOptMap.find(name);
auto it = fOptMap.find(name);
if (it == fOptMap.end()) return false;
value = it->second;
@@ -193,7 +194,7 @@ void RparseUrl::Dump(std::ostream& os, int ind, const char* text) const
os << bl << " fScheme: " << fScheme << endl;
os << bl << " fPath: " << fPath << endl;
os << bl << " fOptMap: " << endl;
for (omap_cit_t it=fOptMap.begin(); it!=fOptMap.end(); it++) {
for (auto it=fOptMap.begin(); it!=fOptMap.end(); it++) {
os << bl << " " << RosPrintf((it->first).c_str(), "-s",8)
<< " : " << it->second << endl;
}
@@ -236,7 +237,7 @@ bool RparseUrl::AddOpt(const std::string& key, const std::string& val,
return false;
}
fOptMap.insert(omap_val_t(key, hasval ? val : "1"));
fOptMap.emplace(make_pair(key, hasval ? val : "1"));
return true;
}

View File

@@ -1,4 +1,4 @@
// $Id: RparseUrl.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RparseUrl.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -36,9 +36,6 @@ namespace Retro {
class RparseUrl {
public:
typedef std::map<std::string, std::string> omap_t;
typedef omap_t::iterator omap_it_t;
typedef omap_t::const_iterator omap_cit_t;
typedef omap_t::value_type omap_val_t;
RparseUrl();
virtual ~RparseUrl();

View File

@@ -1,4 +1,4 @@
// $Id: Rw11Cpu.cpp 1050 2018-09-23 15:46:42Z mueller $
// $Id: Rw11Cpu.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,7 +13,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2019-09-23 1050 1.2.14 add HasPcnt()
// 2018-11-09 1066 1.2.15 use auto; use emplace,make_pair
// 2018-09-23 1050 1.2.14 add HasPcnt()
// 2018-09-22 1048 1.2.13 coverity fixup (drop unreachable code)
// 2017-04-07 868 1.2.12 Dump(): add detail arg
// 2017-02-26 857 1.2.11 add kCPAH_M_UBM22
@@ -233,7 +234,7 @@ void Rw11Cpu::AddCntl(const boost::shared_ptr<Rw11Cntl>& spcntl)
throw Rexception("Rw11Cpu::AddCntl",
"Bad state: duplicate controller name");;
fCntlMap.insert(cmap_val_t(name, spcntl));
fCntlMap.emplace(make_pair(name, spcntl));
spcntl->SetCpu(this);
return;
}
@@ -252,7 +253,7 @@ bool Rw11Cpu::TestCntl(const std::string& name) const
void Rw11Cpu::ListCntl(std::vector<std::string>& list) const
{
list.clear();
for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
for (auto it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
list.push_back((it->second)->Name());
}
return;
@@ -263,7 +264,7 @@ void Rw11Cpu::ListCntl(std::vector<std::string>& list) const
Rw11Cntl& Rw11Cpu::Cntl(const std::string& name) const
{
cmap_cit_t it=fCntlMap.find(name);
auto it=fCntlMap.find(name);
if (it == fCntlMap.end())
throw Rexception("Rw11Cpu::Cntl()",
"Bad args: controller name '" + name + "' unknown");
@@ -275,7 +276,7 @@ Rw11Cntl& Rw11Cpu::Cntl(const std::string& name) const
void Rw11Cpu::Start()
{
for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
for (auto it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
Rw11Cntl& cntl(*(it->second));
cntl.Probe();
if (cntl.ProbeStatus().Found() && cntl.Enable()) {
@@ -551,9 +552,6 @@ bool Rw11Cpu::LoadAbs(const std::string& fname, RerrMsg& emsg, bool trace)
};
typedef std::map<uint16_t, uint16_t> obmap_t;
//typedef obmap_t::iterator obmap_it_t;
typedef obmap_t::const_iterator obmap_cit_t;
typedef obmap_t::value_type obmap_val_t;
obmap_t oddbyte; // odd byte cache
@@ -637,7 +635,7 @@ bool Rw11Cpu::LoadAbs(const std::string& fname, RerrMsg& emsg, bool trace)
addr = ldaddr;
word = 0;
if ((addr & 0x01) == 1 && bytcnt > 6) {
obmap_cit_t it = oddbyte.find(addr);
auto it = oddbyte.find(addr);
if (it != oddbyte.end()) {
word = it->second;
} else {
@@ -683,7 +681,7 @@ bool Rw11Cpu::LoadAbs(const std::string& fname, RerrMsg& emsg, bool trace)
} else {
if ((addr & 0x01) == 1) { // high byte not yet seen
data.push_back(word); // zero fill high byte
oddbyte.insert(obmap_val_t(addr,word)); // store even byte for later
oddbyte.emplace(make_pair(addr,word)); // store even byte for later
}
//cout << "+++2 " << RosPrintBvi(ldaddr,8)
@@ -884,7 +882,7 @@ void Rw11Cpu::Dump(std::ostream& os, int ind, const char* text,
os << bl << " fCpuAct: " << fCpuAct << endl;
os << bl << " fCpuStat: " << RosPrintf(fCpuStat,"$x0",4) << endl;
os << bl << " fCntlMap: " << endl;
for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
for (auto it=fCntlMap.begin(); it!=fCntlMap.end(); it++) {
os << bl << " " << RosPrintf((it->first).c_str(), "-s",8)
<< " : " << it->second << endl;
}

View File

@@ -1,4 +1,4 @@
// $Id: Rw11Cpu.hpp 1050 2018-09-23 15:46:42Z mueller $
// $Id: Rw11Cpu.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -67,10 +67,6 @@ namespace Retro {
class Rw11Cpu : public Rbits, private boost::noncopyable {
public:
typedef std::map<std::string, boost::shared_ptr<Rw11Cntl>> cmap_t;
typedef cmap_t::iterator cmap_it_t;
typedef cmap_t::const_iterator cmap_cit_t;
typedef cmap_t::value_type cmap_val_t;
explicit Rw11Cpu(const std::string& type);
virtual ~Rw11Cpu();

View File

@@ -1,4 +1,4 @@
// $Id: Rw11VirtDiskOver.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rw11VirtDiskOver.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2017- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -39,9 +39,6 @@ namespace Retro {
public:
typedef std::map<uint32_t,Rw11VirtDiskBuffer> bmap_t;
typedef bmap_t::iterator bmap_it_t;
typedef bmap_t::const_iterator bmap_cit_t;
typedef bmap_t::value_type bmap_val_t;
explicit Rw11VirtDiskOver(Rw11Unit* punit);
~Rw11VirtDiskOver();

View File

@@ -1,4 +1,4 @@
// $Id: Rw11VirtDiskRam.hpp 1063 2018-10-29 18:37:42Z mueller $
// $Id: Rw11VirtDiskRam.hpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2018- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -38,9 +38,6 @@ namespace Retro {
public:
typedef std::map<uint32_t,Rw11VirtDiskBuffer> bmap_t;
typedef bmap_t::iterator bmap_it_t;
typedef bmap_t::const_iterator bmap_cit_t;
typedef bmap_t::value_type bmap_val_t;
explicit Rw11VirtDiskRam(Rw11Unit* punit);
~Rw11VirtDiskRam();

View File

@@ -1,4 +1,4 @@
// $Id: RtclRw11Cpu.cpp 1050 2018-09-23 15:46:42Z mueller $
// $Id: RtclRw11Cpu.cpp 1066 2018-11-10 11:21:53Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,7 +13,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2019-09-23 1050 1.2.18 add HasPcnt()
// 2018-11-09 1066 1.2.19 use auto; use emplace_back
// 2018-09-23 1050 1.2.18 add HasPcnt()
// 2018-09-21 1048 1.2.18 coverity fixup (uninitialized scalar)
// 2017-04-22 883 1.2.17 M_(imap|rmap): -testname optional addr check
// 2017-04-15 876 1.2.16 add ControllerCommands()
@@ -223,8 +224,8 @@ int RtclRw11Cpu::M_imap(RtclArgs& args)
} else { // imap
RtclOPtr plist(Tcl_NewListObj(0, nullptr));
const RlinkAddrMap::amap_t amap = addrmap.Amap();
for (RlinkAddrMap::amap_cit_t it=amap.begin(); it!=amap.end(); it++) {
const auto amap = addrmap.Amap();
for (auto it=amap.begin(); it!=amap.end(); it++) {
Tcl_Obj* tpair[2];
tpair[0] = Tcl_NewIntObj(it->first);
tpair[1] = Tcl_NewStringObj((it->second).c_str(),(it->second).length());
@@ -328,8 +329,8 @@ int RtclRw11Cpu::M_rmap(RtclArgs& args)
} else { // rmap
RtclOPtr plist(Tcl_NewListObj(0, nullptr));
const RlinkAddrMap::amap_t amap = lmap.Amap();
for (RlinkAddrMap::amap_cit_t it=amap.begin(); it!=amap.end(); it++) {
const auto amap = lmap.Amap();
for (auto it=amap.begin(); it!=amap.end(); it++) {
Tcl_Obj* tpair[2];
tpair[0] = Tcl_NewIntObj(it->first);
tpair[1] = Tcl_NewStringObj((it->second).c_str(),(it->second).length());
@@ -1069,8 +1070,6 @@ int RtclRw11Cpu::M_ldasm(RtclArgs& args)
bool lstbodyseen = false;
typedef map<uint16_t, uint16_t> cmap_t;
typedef cmap_t::iterator cmap_it_t;
//typedef cmap_t::value_type cmap_val_t;
cmap_t cmap;
uint16_t dot = 0;
@@ -1163,7 +1162,7 @@ int RtclRw11Cpu::M_ldasm(RtclArgs& args)
dot = 0;
RerrMsg emsg;
for (cmap_it_t it=cmap.begin(); it!=cmap.end(); it++) {
for (auto it=cmap.begin(); it!=cmap.end(); it++) {
//cout << "+++2 mem[" << RosPrintf(it->first, "o0", 6)
// << "]=" << RosPrintf(it->second, "o0", 6) << endl;
if (dot != it->first || block.size() >= Connect().BlockSizeMax()) {
@@ -1576,7 +1575,7 @@ bool RtclRw11Cpu::GetVarName(RtclArgs& args, const char* argname,
size_t nind,
std::vector<std::string>& varname)
{
while (varname.size() < nind+1) varname.push_back(string());
while (varname.size() < nind+1) varname.emplace_back(string());
string name;
if (!args.GetArg(argname, name)) return false;
if (name.length()) { // if variable defined