+ allow to suppress verbose mode of XMLReader

This commit is contained in:
wmayer 2015-01-13 21:57:18 +01:00
parent 395d5249d4
commit 7c789a1bf7
3 changed files with 19 additions and 9 deletions

View File

@ -134,11 +134,15 @@ void PropertyLink::Restore(Base::XMLReader &reader)
App::Document* document = parent->getDocument();
DocumentObject* object = document ? document->getObject(name.c_str()) : 0;
if (!object) {
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
if (reader.isVerbose()) {
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
}
}
else if (parent == object) {
Base::Console().Warning("Object '%s' links to itself, nullify it\n",name.c_str());
if (reader.isVerbose()) {
Base::Console().Warning("Object '%s' links to itself, nullify it\n",name.c_str());
}
object = 0;
}
@ -319,9 +323,12 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader)
if (name != ""){
App::Document* document = static_cast<DocumentObject*>(getContainer())->getDocument();
pcObject = document ? document->getObject(name.c_str()) : 0;
if (!pcObject)
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
if (!pcObject) {
if (reader.isVerbose()) {
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
}
}
setValue(pcObject,values);
}
else {
@ -471,7 +478,7 @@ void PropertyLinkList::Restore(Base::XMLReader &reader)
DocumentObject* child = document ? document->getObject(name.c_str()) : 0;
if (child)
values.push_back(child);
else
else if (reader.isVerbose())
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
}
@ -663,7 +670,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader)
DocumentObject* child = document ? document->getObject(name.c_str()) : 0;
if (child)
values.push_back(child);
else
else if (reader.isVerbose())
Base::Console().Warning("Lost link to '%s' while loading, maybe "
"an object was not loaded correctly\n",name.c_str());
std::string subName = reader.getAttribute("sub");

View File

@ -60,7 +60,7 @@ using namespace std;
// ---------------------------------------------------------------------------
Base::XMLReader::XMLReader(const char* FileName, std::istream& str)
: DocumentSchema(0), ProgramVersion(""), FileVersion(0), Level(0), _File(FileName)
: DocumentSchema(0), ProgramVersion(""), FileVersion(0), Level(0), _File(FileName), _verbose(true)
{
#ifdef _MSC_VER
str.imbue(std::locale::empty());

View File

@ -120,6 +120,8 @@ public:
~XMLReader();
bool isValid() const { return _valid; }
bool isVerbose() const { return _verbose; }
void setVerbose(bool on) { _verbose = on; }
/** @name Parser handling */
//@{
@ -224,6 +226,7 @@ protected:
XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader* parser;
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token;
bool _valid;
bool _verbose;
struct FileEntry {
std::string FileName;