Skip to content

Commit

Permalink
+ allow to suppress verbose mode of XMLReader
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 13, 2015
1 parent 395d524 commit 7c789a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
23 changes: 15 additions & 8 deletions src/App/PropertyLinks.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/Base/Reader.cpp
Expand Up @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions src/Base/Reader.h
Expand Up @@ -120,6 +120,8 @@ class BaseExport XMLReader : public XERCES_CPP_NAMESPACE_QUALIFIER DefaultHandle
~XMLReader();

bool isValid() const { return _valid; }
bool isVerbose() const { return _verbose; }
void setVerbose(bool on) { _verbose = on; }

/** @name Parser handling */
//@{
Expand Down Expand Up @@ -224,6 +226,7 @@ class BaseExport XMLReader : public XERCES_CPP_NAMESPACE_QUALIFIER DefaultHandle
XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader* parser;
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token;
bool _valid;
bool _verbose;

struct FileEntry {
std::string FileName;
Expand Down

0 comments on commit 7c789a1

Please sign in to comment.