1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2025-10-16 23:47:46 +02:00

fix: Remove deprecated (C++11) std::{binary,unary}_function

This commit is contained in:
Sirius Bakke 2023-07-22 20:06:18 +02:00
parent a940362776
commit 0421a0cf45
9 changed files with 180 additions and 145 deletions

View File

@ -66,7 +66,11 @@ ANTLR_C_USING(strcasecmp)
/** Functor for the literals map
*/
class ANTLR_API CharScannerLiteralsLess : public ANTLR_USE_NAMESPACE(std)binary_function<ANTLR_USE_NAMESPACE(std)string,ANTLR_USE_NAMESPACE(std)string,bool> {
class ANTLR_API CharScannerLiteralsLess
#if __cplusplus < 201103L
: public ANTLR_USE_NAMESPACE(std)binary_function<ANTLR_USE_NAMESPACE(std)string,ANTLR_USE_NAMESPACE(std)string,bool>
#endif
{
private:
const CharScanner* scanner;
public:

View File

@ -1,4 +1,4 @@
/*
/*
Firewall Builder
@ -17,7 +17,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -55,7 +55,7 @@ namespace fwcompiler {
protected:
std::string comment_symbol;
/**
* dynamic interfaces can not be used in policy rules in IOS ACLs
*/
@ -78,13 +78,13 @@ namespace fwcompiler {
*************************************************************************
*/
/**
* verifies combination of interface and direction and
* fills interface and direction. After this predicate it
* is guaranteed that both interface and direction have
* some value. In certain situations interface ID may be
* set to "nil" though (e.g. global policy rules).
* set to "nil" though (e.g. global policy rules).
*/
DECLARE_POLICY_RULE_PROCESSOR( InterfaceAndDirection_v6 );
@ -117,7 +117,7 @@ namespace fwcompiler {
*************************************************************************
*
* end of module PolicyCompiler_iosacl_v6_acls.cpp
*
*
*************************************************************************
*/
@ -196,7 +196,7 @@ namespace fwcompiler {
*/
DECLARE_POLICY_RULE_PROCESSOR(splitTCPServiceWithFlags);
friend class PolicyCompiler_iosacl::splitTCPServiceWithFlags;
/**
* this processor prints single policy rule, assuming all
* groups have been expanded, so source, destination and
@ -212,7 +212,7 @@ namespace fwcompiler {
int aclLineCounter;
std::string _printPortRangeOp(int rs, int re);
std::string getTcpFlagName(const libfwbuilder::TCPService::TCPFlag f);
std::string _printSrcService(libfwbuilder::Service *srv);
std::string _printDstService(libfwbuilder::Service *srv);
@ -244,7 +244,10 @@ namespace fwcompiler {
PrintCompleteACLs(const std::string &n) : PrintRule(n) {}
virtual bool processNext();
struct printRulesForACL : public std::unary_function<libfwbuilder::Rule*, void>
struct printRulesForACL
#if __cplusplus < 201103L
: public std::unary_function<libfwbuilder::Rule*, void>
#endif
{
ciscoACL *acl;
std::stringstream *output;
@ -286,7 +289,7 @@ namespace fwcompiler {
virtual void epilog();
virtual std::string printClearCommands();
static std::string getAccessGroupCommandForAddressFamily(bool ipv6);
};

View File

@ -1,4 +1,4 @@
/*
/*
Firewall Builder
@ -17,7 +17,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -55,7 +55,7 @@ namespace fwcompiler {
protected:
std::string comment_symbol;
/**
* dynamic interfaces can not be used in policy rules in NXOS ACLs
*/
@ -78,13 +78,13 @@ namespace fwcompiler {
*************************************************************************
*/
/**
* verifies combination of interface and direction and
* fills interface and direction. After this predicate it
* is guaranteed that both interface and direction have
* some value. In certain situations interface ID may be
* set to "nil" though (e.g. global policy rules).
* set to "nil" though (e.g. global policy rules).
*/
DECLARE_POLICY_RULE_PROCESSOR( InterfaceAndDirection_v6 );
@ -117,7 +117,7 @@ namespace fwcompiler {
*************************************************************************
*
* end of module PolicyCompiler_nxosacl_v6_acls.cpp
*
*
*************************************************************************
*/
@ -196,7 +196,7 @@ namespace fwcompiler {
*/
DECLARE_POLICY_RULE_PROCESSOR(splitTCPServiceWithFlags);
friend class PolicyCompiler_nxosacl::splitTCPServiceWithFlags;
/**
* this processor prints single policy rule, assuming all
* groups have been expanded, so source, destination and
@ -212,7 +212,7 @@ namespace fwcompiler {
int aclLineCounter;
std::string _printPortRangeOp(int rs, int re);
std::string getTcpFlagName(const libfwbuilder::TCPService::TCPFlag f);
std::string _printSrcService(libfwbuilder::Service *srv);
std::string _printDstService(libfwbuilder::Service *srv);
@ -244,7 +244,10 @@ namespace fwcompiler {
PrintCompleteACLs(const std::string &n) : PrintRule(n) {}
virtual bool processNext();
struct printRulesForACL : public std::unary_function<libfwbuilder::Rule*, void>
struct printRulesForACL
#if __cplusplus < 201103L
: public std::unary_function<libfwbuilder::Rule*, void>
#endif
{
ciscoACL *acl;
std::stringstream *output;
@ -286,7 +289,7 @@ namespace fwcompiler {
virtual void epilog();
virtual std::string printClearCommands();
static std::string getAccessGroupCommandForAddressFamily(bool ipv6);
};

View File

@ -68,7 +68,10 @@ using namespace libfwbuilder;
using namespace std;
// a functor to join list<string> into a string with separator sep
class join : public std::unary_function<std::string, void>
class join
#if __cplusplus < 201103L
: public std::unary_function<std::string, void>
#endif
{
std::string *result;
std::string separator;
@ -325,7 +328,7 @@ void Importer::addInterfaceAddress(const std::string &label,
void Importer::setInterfaceComment(const std::string &descr)
{
// current_interface can be nullptr if parser encountered command
// that looked like interface description but in reality was
// that looked like interface description but in reality was
// description of something else. For example this happens when
// it finds command "description" under "controller" in Cisco router
// configuration.
@ -489,7 +492,7 @@ void Importer::newUnidirRuleSet(const string &ruleset_name,
/*
* Grammar must ensure the call to setDefaultAction() happens
* after the call to newUnidirRuleSet()
*
*
*/
void Importer::setDefaultAction(const std::string &iptables_action_name)
{
@ -603,7 +606,7 @@ void Importer::setSrcSelf()
void Importer::setDstSelf()
{
dst_a = "self";
}
}
FWObject* Importer::makeAddressObj(const std::string addr, const std::string netm)
{
@ -612,7 +615,7 @@ FWObject* Importer::makeAddressObj(const std::string addr, const std::string net
return getFirewallObject();
}
if ( (addr=="" && netm=="") ||
if ( (addr=="" && netm=="") ||
(addr==InetAddr::getAny().toString() &&
netm==InetAddr::getAny().toString()))
return nullptr; // this is 'any'
@ -620,7 +623,7 @@ FWObject* Importer::makeAddressObj(const std::string addr, const std::string net
ObjectSignature sig(error_tracker);
sig.type_name = Address::TYPENAME;
sig.setAddress(addr.c_str());
if (netm=="")
if (netm=="")
sig.setNetmask(InetAddr::getAllOnes().toString().c_str(),
address_maker->getInvertedNetmasks());
else
@ -987,7 +990,7 @@ void Importer::rearrangeVlanInterfaces()
{
Interface *intf = Interface::cast(*it);
FWOptions *ifopt = intf->getOptionsObject();
if (int_prop->looksLikeVlanInterface(intf->getName().c_str()) &&
ifopt->getStr("type")=="8021q")
{

View File

@ -1,4 +1,4 @@
/*
/*
Firewall Builder
@ -17,7 +17,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -55,7 +55,7 @@ namespace fwcompiler {
protected:
std::string comment_symbol;
/**
* dynamic interfaces can not be used in policy rules in JUNOS ACLs
*/
@ -81,13 +81,13 @@ namespace fwcompiler {
*************************************************************************
*/
/**
* verifies combination of interface and direction and
* fills interface and direction. After this predicate it
* is guaranteed that both interface and direction have
* some value. In certain situations interface ID may be
* set to "nil" though (e.g. global policy rules).
* set to "nil" though (e.g. global policy rules).
*/
DECLARE_POLICY_RULE_PROCESSOR( InterfaceAndDirection_v6 );
@ -120,7 +120,7 @@ namespace fwcompiler {
*************************************************************************
*
* end of module PolicyCompiler_iosacl_v6_acls.cpp
*
*
*************************************************************************
*/
@ -205,7 +205,7 @@ namespace fwcompiler {
*/
DECLARE_POLICY_RULE_PROCESSOR(checkIPv4FragmentService);
friend class PolicyCompiler_junosacl::checkIPv4FragmentService;
/**
* this processor prints single policy rule, assuming all
* groups have been expanded, so source, destination and
@ -223,7 +223,7 @@ namespace fwcompiler {
std::map<std::string,std::string> reject_icmp_reason;
std::string _printPortRangeOp(int rs, int re);
std::string getTcpFlagName(const libfwbuilder::TCPService::TCPFlag f);
std::string _printSrcService(libfwbuilder::Service *srv);
std::string _printDstService(libfwbuilder::Service *srv);
@ -267,7 +267,10 @@ namespace fwcompiler {
PrintCompleteACLs(const std::string &n) : PrintRule(n) {}
virtual bool processNext();
struct printRulesForACL : public std::unary_function<libfwbuilder::Rule*, void>
struct printRulesForACL
#if __cplusplus < 201103L
: public std::unary_function<libfwbuilder::Rule*, void>
#endif
{
ciscoACL *acl;
std::stringstream *output;
@ -310,7 +313,7 @@ namespace fwcompiler {
virtual void epilog();
virtual std::string printClearCommands();
static std::string getAccessGroupCommandForAddressFamily(bool ipv6);
};

View File

@ -1,4 +1,4 @@
/*
/*
Firewall Builder
@ -18,7 +18,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -125,7 +125,7 @@ void FWObject::fromXML(xmlNodePtr root)
if (cur && !xmlIsBlankNode(cur))
{
FWObject *o = dbr->createFromXML(cur);
if (o!=nullptr)
if (o!=nullptr)
{
/* Add w/o validation. Trust XML to do that */
add(o, false);
@ -164,7 +164,7 @@ xmlNodePtr FWObject::toXML(xmlNodePtr parent, bool process_children)
if (id!=-1)
{
xmlNewProp(
me,
me,
XMLTools::ToXmlCast("id"),
XMLTools::StrToXmlCast(s_id));
}
@ -174,7 +174,7 @@ xmlNodePtr FWObject::toXML(xmlNodePtr parent, bool process_children)
XMLTools::StrToXmlCast(setToString(keywords)));
}
for(map<string, string>::const_iterator i=data.begin(); i!=data.end(); ++i)
for(map<string, string>::const_iterator i=data.begin(); i!=data.end(); ++i)
{
const string &name = (*i).first;
const string &value = (*i).second;
@ -187,7 +187,7 @@ xmlNodePtr FWObject::toXML(xmlNodePtr parent, bool process_children)
if (process_children)
{
for(list<FWObject*>::const_iterator j=begin(); j!=end(); ++j)
for(list<FWObject*>::const_iterator j=begin(); j!=end(); ++j)
(*j)->toXML(me);
}
@ -239,7 +239,7 @@ FWObject::FWObject(const FWObject &c) : list<FWObject*>(c)
storeCreationTime();
}
FWObject::~FWObject()
FWObject::~FWObject()
{
busy = true; // ignore read-only
if (size() > 0) destroyChildren();
@ -315,7 +315,7 @@ FWObject* FWObject::findObjectByName(const string &type,
if (getTypeName()==type && getName()==name) return this;
list<FWObject*>::iterator j;
for(j=begin(); j!=end(); ++j)
for(j=begin(); j!=end(); ++j)
{
FWObject *o=*j;
@ -332,7 +332,7 @@ FWObject* FWObject::findObjectByAttribute(const std::string &attr,
if (getStr(attr)==val) return this;
list<FWObject*>::iterator j;
for(j=begin(); j!=end(); ++j)
for(j=begin(); j!=end(); ++j)
{
FWObject *o=*j;
@ -352,7 +352,7 @@ bool FWObject::cmp(const FWObject *obj, bool recursive)
if (data.size() != obj->data.size())
return false;
for(map<string, string>::const_iterator i=data.begin(); i!=data.end(); ++i)
for(map<string, string>::const_iterator i=data.begin(); i!=data.end(); ++i)
{
const string &name = (*i).first;
const string &value = (*i).second;
@ -411,7 +411,7 @@ FWObject& FWObject::duplicate(const FWObject *x, bool preserve_id)
destroyChildren(); // does it erase index entries?
for(list<FWObject*>::const_iterator m=x->begin(); m!=x->end(); ++m)
for(list<FWObject*>::const_iterator m=x->begin(); m!=x->end(); ++m)
{
FWObject *o = *m;
addCopyOf( o, preserve_id);
@ -493,11 +493,14 @@ FWObject& FWObject::shallowDuplicate(const FWObject *x, bool preserve_id)
return *this;
}
class InheritsFWOptions: public std::unary_function<FWObject*, bool>
class InheritsFWOptions
#if __cplusplus < 201103L
: public std::unary_function<FWObject*, bool>
#endif
{
public:
InheritsFWOptions() {}
bool operator()(const FWObject *o) const
bool operator()(const FWObject *o) const
{
return FWOptions::constcast(o)!=nullptr;
}
@ -518,12 +521,12 @@ FWObject& FWObject::duplicateForUndo(const FWObject *obj)
return *this;
}
const string &FWObject::getName() const
{
const string &FWObject::getName() const
{
return name;
}
void FWObject::setName(const string &n)
void FWObject::setName(const string &n)
{
if (name != n)
{
@ -593,7 +596,7 @@ string FWObject::getPath(bool relative, bool detailed) const
}
const string& FWObject::getComment() const
{
{
return comment;
}
@ -607,7 +610,7 @@ void FWObject::setComment(const string &c)
}
int FWObject::getId() const
{
{
return id;
}
@ -624,9 +627,9 @@ void FWObject::setId(int c)
}
}
bool FWObject::exists(const string &name) const
bool FWObject::exists(const string &name) const
{
return data.count(name)!=0;
return data.count(name)!=0;
}
const string &FWObject::getStr(const string &name) const
@ -642,7 +645,7 @@ void FWObject::remStr(const string &name)
{
checkReadOnly();
map<string, string>::iterator m=data.find(name);
if(m != data.end())
if(m != data.end())
{
data.erase(m);
setDirty(true);
@ -706,7 +709,7 @@ void FWObject::setBool(const string &name, const string &val)
{
if(!name.empty())
setBool(name,
(val=="1" || cxx_strcasecmp(val.c_str(),"true")==0));
(val=="1" || cxx_strcasecmp(val.c_str(),"true")==0));
}
void FWObject::Show()
@ -847,7 +850,7 @@ void FWObject::add(FWObject *obj, bool validate)
assert(old_parent != this);
}
if (!validate || validateChild(obj))
if (!validate || validateChild(obj))
{
push_back(obj);
_adopt(obj);
@ -879,7 +882,7 @@ void FWObject::addRef(FWObject *obj)
{
checkReadOnly();
if (validateChild(obj))
if (validateChild(obj))
{
FWReference *oref = obj->createRef();
obj->ref();
@ -933,9 +936,9 @@ void FWObject::swapObjects(FWObject *o1, FWObject *o2)
{
checkReadOnly();
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
if(*m==o1)
if(*m==o1)
{
*m=o2;
} else if(*m==o2)
@ -988,14 +991,14 @@ void FWObject::removeRef(FWObject *obj)
if (!obj) return;
int obj_id = obj->getId();
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
FWObject *o = *m;
FWReference *oref = FWReference::cast(o);
if (oref && oref->getPointerId()==obj_id)
{
// do not delete object even if this reference was the last one (?)
obj->unref();
obj->unref();
FWObject::remove(o, false); // do not remove
delete o;
@ -1007,7 +1010,7 @@ void FWObject::removeRef(FWObject *obj)
bool FWObject::hasRef(FWObject *obj)
{
int obj_id = obj->getId();
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
FWObject *o = *m;
FWReference *oref = FWReference::cast(o);
@ -1024,7 +1027,7 @@ void FWObject::_removeAllRef(FWObject *rm)
for (FWObject::iterator i=begin(); i!=end(); i++)
(*i)->_removeAllRef(rm);
removeRef(rm);
}
@ -1036,13 +1039,13 @@ void FWObject::removeAllReferences(FWObject *rm)
void FWObject::findAllReferences(const FWObject *obj, std::set<FWReference*> &res)
{
int obj_id = obj->getId();
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
FWObject *o=*m;
FWReference *oref = FWReference::cast(o);
if(oref)
{
if(oref->getPointerId()==obj_id)
if(oref->getPointerId()==obj_id)
res.insert(oref);
} else
{
@ -1059,7 +1062,7 @@ set<FWReference*> FWObject::findAllReferences(const FWObject *obj)
}
bool FWObject::validateChild(FWObject*)
{
{
return true;
}
@ -1124,7 +1127,7 @@ void FWObject::sortChildrenByName(bool follow_references)
bool FWObject::verifyTree()
{
bool res = false;
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
FWObject *o = *m;
FWObject *o_parent = o->getParent();
@ -1173,7 +1176,7 @@ bool FWObject::verifyTree()
void FWObject::fixTree()
{
getRoot()->addToIndex(this);
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
FWObject *o = *m;
if (o->getRoot() != getRoot()) o->setRoot(getRoot());
@ -1217,7 +1220,7 @@ void FWObject::clearChildren(bool recursive)
int referenced_children = 0;
int total_children = 0;
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{
FWObject *o = *m;
@ -1225,7 +1228,7 @@ void FWObject::clearChildren(bool recursive)
if (recursive) o->clearChildren(recursive);
o->unref();
if(o->ref_counter==0)
if(o->ref_counter==0)
{
if (dbr) dbr->removeFromIndex( o->getId() );
delete o;
@ -1236,7 +1239,7 @@ void FWObject::clearChildren(bool recursive)
setDirty(true);
#ifdef FWB_DEBUG
cerr << "Deleted " << total_children - referenced_children
cerr << "Deleted " << total_children - referenced_children
<< " child objects; still referenced " << referenced_children
<< " child objects" << endl;
#endif
@ -1281,9 +1284,9 @@ bool FWObject::hasChild(FWObject *obj)
FWObject* FWObject::getById (int id, bool recursive)
{
if(id==getId()) return this;
list<FWObject*>::iterator j;
for(j=begin(); j!=end(); ++j)
for(j=begin(); j!=end(); ++j)
{
FWObject *o=*j;
int oid = o->getId();
@ -1303,13 +1306,13 @@ FWObject* FWObject::getFirstByType(const string &type_name) const
list<FWObject*> FWObject::getByType(const string &type_name) const
{
list<FWObject*> res;
for(const_iterator i=begin(); i!=end(); ++i)
for(const_iterator i=begin(); i!=end(); ++i)
{
i=find_if( i, end(), FWObjectTypeNameEQPredicate(type_name));
if (i==end()) break;
res.push_back(*i);
}
return res;
}
return res;
}
list<FWObject*> FWObject::getByTypeDeep(const string &type_name) const
@ -1427,23 +1430,23 @@ void FWObjectTypedChildIterator::init(
}
bool FWObjectTypedChildIterator::operator==(
const FWObject::const_iterator& __x) const
{
return real_iterator == __x;
const FWObject::const_iterator& __x) const
{
return real_iterator == __x;
}
bool FWObjectTypedChildIterator::operator!=(
const FWObject::const_iterator& __x) const
{
return real_iterator != __x;
const FWObject::const_iterator& __x) const
{
return real_iterator != __x;
}
FWObject *FWObjectTypedChildIterator::operator*() const
{
FWObject *FWObjectTypedChildIterator::operator*() const
{
return *real_iterator;
}
FWObjectTypedChildIterator& FWObjectTypedChildIterator::operator++()
FWObjectTypedChildIterator& FWObjectTypedChildIterator::operator++()
{
if(real_iterator==_end)
return *this;
@ -1455,11 +1458,11 @@ FWObjectTypedChildIterator& FWObjectTypedChildIterator::operator++()
}
/*
* if iterator points to the first element in the list, then operator--()
* if iterator points to the first element in the list, then operator--()
* should move it and make it point to end()
*/
FWObjectTypedChildIterator& FWObjectTypedChildIterator::operator--()
{
FWObjectTypedChildIterator& FWObjectTypedChildIterator::operator--()
{
if(real_iterator==_end)
return *this;
do
@ -1476,7 +1479,7 @@ FWObject::tree_iterator FWObject::tree_iterator::operator++(int )
++*this;
return __tmp;
}
//#define TI_DEBUG 1
/* this is a prefix operator */
@ -1596,7 +1599,7 @@ void FWObject::replaceReferenceInternal(int old_id, int new_id, int &counter)
for (FWObject::iterator j1=begin(); j1!=end(); ++j1)
(*j1)->replaceReferenceInternal(old_id, new_id, counter);
} else
{
{
if (ref->getPointerId()==old_id)
{
ref->setPointerId(new_id);

View File

@ -1,4 +1,4 @@
/*
/*
Firewall Builder
@ -18,7 +18,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -108,7 +108,7 @@ private:
* create the object. The 'parent' pointer, on the other hand, is
* stored once the object is added to the tree.
*
* dbroot is assigned by method FWObjectDatabase::create
* dbroot is assigned by method FWObjectDatabase::create
*/
FWObjectDatabase *dbroot;
int id;
@ -128,7 +128,7 @@ protected:
std::string xml_name;
bool busy;
bool dirty;
std::map<std::string, std::string> data;
std::map<std::string, void*> private_data;
@ -173,7 +173,7 @@ protected:
// special constructor used to create FWObjectDatabase objects
FWObject(bool new_id);
public:
DECLARE_FWOBJECT_SUBTYPE(FWObject);
@ -198,8 +198,8 @@ public:
bool operator==(const tree_iterator& i) const;
bool operator!=(const tree_iterator& i) const;
};
tree_iterator tree_begin();
tree_iterator tree_end();
@ -214,7 +214,7 @@ public:
* need to add as children.
*/
virtual void init(FWObjectDatabase *root);
int getId() const;
void setId(int i);
bool haveId() { return (id != -1); }
@ -226,7 +226,7 @@ public:
* checking if this object is read-only itself.
*/
bool getRO() const { return ro; }
virtual void fromXML(xmlNodePtr xml_parent_node);
virtual xmlNodePtr toXML(xmlNodePtr xml_parent_node);
xmlNodePtr toXML(xmlNodePtr xml_parent_node, bool process_children);
@ -236,7 +236,7 @@ public:
* represented by the class derived from FWObject if we want to. For
* example, used in all "Any" objects so we did not have to create extra
* classes
*
*
*/
void setXMLName (const std::string &);
@ -259,7 +259,7 @@ public:
*/
virtual FWObject& duplicate(const FWObject *obj,
bool preserve_id = true);
/**
* This method works just like duplicate, except it does not destroy
* or change children of 'this'.
@ -283,13 +283,13 @@ public:
* ones are issued.
*/
virtual FWObject* addCopyOf(const FWObject *obj, bool preserve_id = true);
/**
* compares objects. Ignores ID and always looks at
* attributes. Returns true if objects are equal.
*/
virtual bool cmp(const FWObject *obj, bool recursive=false);
void Show();
void Hide();
@ -312,7 +312,7 @@ public:
const std::string &getName() const;
void setName(const std::string& n);
const std::string &getComment() const;
void setComment(const std::string& c);
@ -323,7 +323,7 @@ public:
void* getPrivateData(const std::string &key) const;
std::map<std::string, void*> &getAllPrivateData();
/**
* convenience method: returns the name of the library this object belongs to.
* In fwbuilder2 library is an element directly under FWObjectDatabase; all
@ -372,7 +372,7 @@ public:
* to o1 with o2 and vice versa.
*/
virtual void swapObjects(FWObject *o1,FWObject *o2);
/**
* Finds first instance of 'obj' in children of this
* object and removes if. If 'obj' reference counter
@ -390,7 +390,7 @@ public:
* Adds reference object pointing to 'obj' as a child of 'this'
*/
virtual void addRef(FWObject *obj);
/**
* Removes reference to given object among
* children of 'this'.
@ -437,7 +437,7 @@ public:
void clearChildren(bool recursive=true);
void sortChildrenByName(bool follow_references=false);
/**
* Walks the tree, looking for objects that are referenced by two parents
* or those with this->parent == nullptr. Prints report to stderr and
@ -454,7 +454,7 @@ public:
* point to the old object tree and need to be fixed.
*/
void fixTree();
int getChildrenCount() const;
virtual void dump(bool recursive,bool brief,int offset=0) const;
@ -467,7 +467,7 @@ public:
bool isChildOf(FWObject *obj);
bool hasChild(FWObject *obj);
/**
* Returns object with given ID. If recursive is 'false'
* search is restricted to direct children of given object
@ -537,7 +537,7 @@ public:
*/
void findDependencies(std::list<FWObject*> &deps);
virtual void setDirty(bool f);
virtual bool isDirty();
@ -581,7 +581,7 @@ class FWObjectTypedChildIterator
public:
FWObjectTypedChildIterator();
FWObjectTypedChildIterator(const FWObjectTypedChildIterator &o);
FWObjectTypedChildIterator(const FWObjectTypedChildIterator &o);
FWObjectTypedChildIterator(const FWObject *o, const std::string &_type_name);
FWObjectTypedChildIterator& operator=(const FWObjectTypedChildIterator&) = default;
@ -590,12 +590,12 @@ class FWObjectTypedChildIterator
FWObject *operator*() const;
FWObjectTypedChildIterator& operator++();
FWObjectTypedChildIterator& operator--();
const FWObject::const_iterator &begin() { return _begin; }
const FWObject::const_iterator & end() { return _end ; }
protected:
std::string type_name;
FWObject::const_iterator real_iterator;
FWObject::const_iterator _begin;
@ -603,35 +603,43 @@ class FWObjectTypedChildIterator
void init(const FWObject *o, const std::string &_type_name);
};
/**
* Predicate class testing object pointers for name eqivalence.
* name is obtained by calling getName() method.
* This class could be used in STL Algoriths find_if, and others.
*/
class FWObjectNameEQPredicate: public std::unary_function<FWObject*, bool>
class FWObjectNameEQPredicate
#if __cplusplus < 201103L
: public std::unary_function<FWObject*, bool>
#endif
{
std::string n;
public:
FWObjectNameEQPredicate(const std::string &name):n(name) {}
bool operator()(const FWObject *o) const
bool operator()(const FWObject *o) const
{
return o->getName()==n;
}
};
struct FWObjectNameCmpPredicate :
public std::binary_function<FWObject*, FWObject*, bool>
struct FWObjectNameCmpPredicate
#if __cplusplus < 201103L
: public std::binary_function<FWObject*, FWObject*, bool>
#endif
{
bool follow_references;
FWObjectNameCmpPredicate(bool follow_refs=false);
bool operator()(FWObject *a,FWObject *b);
};
class findFWObjectIDPredicate : public std::unary_function<FWObject*, bool>
class findFWObjectIDPredicate
#if __cplusplus < 201103L
: public std::unary_function<FWObject*, bool>
#endif
{
int _id;
public:
@ -645,15 +653,18 @@ class findFWObjectIDPredicate : public std::unary_function<FWObject*, bool>
* name is obtained by calling getTypeName() method.
* This class could be used in STL Algoriths find_if, and others.
*/
class FWObjectTypeNameEQPredicate: public std::unary_function<FWObject*, bool>
class FWObjectTypeNameEQPredicate
#if __cplusplus < 201103L
: public std::unary_function<FWObject*, bool>
#endif
{
std::string n;
public:
FWObjectTypeNameEQPredicate(const std::string &name):n(name) {}
bool operator()(const FWObject *o) const
bool operator()(const FWObject *o) const
{
return o->getTypeName()==n;
}

View File

@ -307,7 +307,7 @@ instDialog::~instDialog()
// ========================================================================
/*
/*
* main loop: use lists compile_fw_list and install_fw_list to iterate
* all firewalls and do everything.
*/
@ -637,9 +637,11 @@ int instDialog::findFilesToInspect(QStringList &files)
}
return files.size();
}
struct CaseInsensitiveComparison :
public std::binary_function<libfwbuilder::FWObject*, libfwbuilder::FWObject*, bool>
struct CaseInsensitiveComparison
#if __cplusplus < 201103L
: public std::binary_function<libfwbuilder::FWObject*, libfwbuilder::FWObject*, bool>
#endif
{
bool operator()(libfwbuilder::FWObject *a,libfwbuilder::FWObject *b)
{
@ -651,7 +653,7 @@ void instDialog::findFirewalls()
{
firewalls.clear();
clusters.clear();
if (project)
{
project->m_panel->om->findAllFirewalls(firewalls);

View File

@ -1,4 +1,4 @@
/*
/*
Firewall Builder
@ -15,7 +15,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -80,7 +80,10 @@ void TableFactory::detach()
// dbroot->remove(persistent_tables, false);
}
struct joinIDs : public unary_function<string, void>
struct joinIDs
#if __cplusplus < 201103L
: public unary_function<string, void>
#endif
{
string out, sep;
joinIDs(const string& _sep) { sep=_sep; };
@ -106,8 +109,8 @@ void TableFactory::registerTable(const string& tblname, const string& tblid,
FWObject* tbl)
{
// two different table objects should have different names
//
if (tables.count(tblid)!=0 &&
//
if (tables.count(tblid)!=0 &&
tblnames.count(tblname)!=0 &&
tables[tblid]->getName()!=tbl->getName()
)
@ -321,7 +324,7 @@ string TableFactory::PrintTables()
if (path.empty()) {
compiler->abort("Error: Firewall's data directory not set for address table: " + atrt->getName());
}
output << " file \"" << path << "\"";
}