Base: Add isNullOrEmpty string helper
This adds isNullOrEmpty string helper that cheks if string is... well null or empty. It is done to improve readability of the code and better express intent.
This commit is contained in:
@@ -2368,12 +2368,12 @@ private:
|
||||
std::string subname(sub);
|
||||
if (!subname.empty() && subname[subname.size()-1]!='.')
|
||||
subname += '.';
|
||||
if (mapped && mapped[0]) {
|
||||
if (!Base::Tools::isNullOrEmpty(mapped)) {
|
||||
if (!Data::isMappedElement(mapped))
|
||||
subname += Data::ELEMENT_MAP_PREFIX;
|
||||
subname += mapped;
|
||||
}
|
||||
if (element && element[0]) {
|
||||
if (!Base::Tools::isNullOrEmpty(element)) {
|
||||
if (!subname.empty() && subname[subname.size()-1]!='.')
|
||||
subname += '.';
|
||||
subname += element;
|
||||
|
||||
@@ -2555,7 +2555,7 @@ PyObject* TopoShapePy::getChildShapes(PyObject* args)
|
||||
return Py::new_reference_to(
|
||||
getElements(*getTopoShapePtr(),
|
||||
TopoShape::shapeType(type),
|
||||
avoid && avoid[0] ? TopoShape::shapeType(avoid) : TopAbs_SHAPE));
|
||||
!Base::Tools::isNullOrEmpty(avoid) ? TopoShape::shapeType(avoid) : TopAbs_SHAPE));
|
||||
}
|
||||
PY_CATCH_OCC;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
@@ -60,7 +61,7 @@ public:
|
||||
~FaceSelectionGate() override = default;
|
||||
bool allow(App::Document*, App::DocumentObject*, const char*sSubName) override
|
||||
{
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return false;
|
||||
std::string element(sSubName);
|
||||
return element.substr(0,4) == "Face";
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include <App/Link.h>
|
||||
#include <App/Part.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
@@ -51,7 +53,8 @@
|
||||
#include "DlgExtrusion.h"
|
||||
|
||||
|
||||
FC_LOG_LEVEL_INIT("Part",true,true)
|
||||
|
||||
FC_LOG_LEVEL_INIT("Part", true, true)
|
||||
|
||||
using namespace PartGui;
|
||||
|
||||
@@ -69,7 +72,7 @@ public:
|
||||
{
|
||||
this->canSelect = false;
|
||||
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return false;
|
||||
std::string element(sSubName);
|
||||
if (element.substr(0,4) != "Edge")
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
@@ -186,7 +187,7 @@ namespace PartGui {
|
||||
{
|
||||
if (pObj != this->object)
|
||||
return false;
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return false;
|
||||
std::string element(sSubName);
|
||||
if (allowEdge)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/Link.h>
|
||||
#include <App/Part.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
{
|
||||
this->canSelect = false;
|
||||
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return false;
|
||||
std::string element(sSubName);
|
||||
if (element.substr(0,4) != "Edge")
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Dialogs/DlgMaterialPropertiesImp.h>
|
||||
@@ -79,7 +80,7 @@ namespace PartGui {
|
||||
{
|
||||
if (pObj != this->object)
|
||||
return false;
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return false;
|
||||
std::string element(sSubName);
|
||||
return element.substr(0, 4) == "Face";
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
@@ -69,7 +70,7 @@ namespace PartGui {
|
||||
{
|
||||
if (!obj || !obj->isDerivedFrom<Part::Feature>())
|
||||
return false;
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return (mode == ALL);
|
||||
std::string element(sSubName);
|
||||
switch (mode) {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/Link.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
}
|
||||
bool allow(App::Document* /*pDoc*/, App::DocumentObject*pObj, const char*sSubName) override
|
||||
{
|
||||
if (!sSubName || sSubName[0] == '\0') {
|
||||
if (Base::Tools::isNullOrEmpty(sSubName)) {
|
||||
// If selecting again the same edge the passed sub-element is empty. If the whole
|
||||
// shape is an edge or wire we can use it completely.
|
||||
Part::TopoShape topoShape = Part::Feature::getTopoShape(pObj);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
{
|
||||
if (pObj != this->object)
|
||||
return false;
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (Base::Tools::isNullOrEmpty(sSubName))
|
||||
return false;
|
||||
std::string element(sSubName);
|
||||
return element.substr(0,4) == "Face";
|
||||
|
||||
Reference in New Issue
Block a user