Skip to content

Commit

Permalink
Fixed Custom Registration error
Browse files Browse the repository at this point in the history
  • Loading branch information
netfabb committed Jul 19, 2024
1 parent 21aa856 commit 1c3e445
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Include/Common/Platform/NMR_XmlWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace NMR {
virtual void WriteText(_In_ const nfChar * pszContent, _In_ const nfUint32 cbLength) = 0;

virtual bool GetNamespacePrefix(const std::string &sNameSpaceURI, std::string &sNameSpacePrefix) = 0;
virtual void RegisterCustomNameSpace(const std::string &sNameSpace, const std::string &sNameSpacePrefix) = 0;
virtual void RegisterCustomNameSpace(const std::string &sNameSpace, const std::string &sNameSpacePrefix, bool bFailIfExisting) = 0;
virtual nfUint32 GetNamespaceCount() = 0;
virtual std::string GetNamespacePrefix(nfUint32 nIndex) = 0;
virtual std::string GetNamespace(nfUint32 nIndex) = 0;
Expand Down
2 changes: 1 addition & 1 deletion Include/Common/Platform/NMR_XmlWriter_Native.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace NMR {
virtual void WriteRawLine(_In_ const nfChar * pszRawData, _In_ nfUint32 cbCount);

virtual bool GetNamespacePrefix(const std::string &sNameSpaceURI, std::string &sNameSpacePrefix);
virtual void RegisterCustomNameSpace(const std::string &sNameSpace, const std::string &sNameSpacePrefix);
virtual void RegisterCustomNameSpace(const std::string &sNameSpace, const std::string &sNameSpacePrefix, bool bFailIfExisting);
virtual nfUint32 GetNamespaceCount();
virtual std::string GetNamespacePrefix(nfUint32 nIndex);
virtual std::string GetNamespace(nfUint32 nIndex);
Expand Down
2 changes: 1 addition & 1 deletion Include/Model/Writer/NMR_ModelWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace NMR {
void assignBinaryStream(const std::string& InstanceUUID, const std::string& sBinaryStreamUUID);
CChunkedBinaryStreamWriter* findBinaryStream(const std::string& InstanceUUID, std::string& Path);

virtual void registerCustomNameSpace(const std::string & sPrefix, const std::string & sNameSpace);
virtual void registerCustomNameSpace(const std::string & sPrefix, const std::string & sNameSpace, bool bFailIfExisting);

};

Expand Down
2 changes: 1 addition & 1 deletion Include/Model/Writer/NMR_ModelWriter_3MF.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace NMR {

void addAdditionalAttachment(_In_ std::string sPath, _In_ PImportStream pStream, _In_ std::string sRelationShipType);

void registerCustomNameSpace(const std::string& sPrefix, const std::string& sNameSpace) override;
void registerCustomNameSpace(const std::string& sPrefix, const std::string& sNameSpace, bool bFailIfExisting) override;
std::map<std::string, std::string> getCustomNamespaceMap();

};
Expand Down
2 changes: 1 addition & 1 deletion Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace NMR {
void registerStreamWriter(const std::string& sInstanceUUID, const std::string& sPath, CChunkedBinaryStreamWriter* pBinaryStreamWriter);
void setWriteBinaryExtension(bool bWriteBinaryExtension);

void registerCustomNamespace (const std::string & sPrefix, const std::string & sNamespace);
void registerCustomNamespace (const std::string & sPrefix, const std::string & sNamespace, bool bFailIfExisting);

};

Expand Down
2 changes: 1 addition & 1 deletion Source/API/lib3mf_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,5 @@ void CWriter::RegisterCustomNamespace(const std::string& sPrefix, const std::str
if (!NMR::fnStringIsValidAlphanumericNameString (sPrefix))
throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDNAMESPACEPREFIX);

m_pWriter->registerCustomNameSpace(sPrefix, sNameSpace);
m_pWriter->registerCustomNameSpace(sPrefix, sNameSpace, false);
}
8 changes: 6 additions & 2 deletions Source/Common/Platform/NMR_XmlWriter_Native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,17 @@ namespace NMR {
}
}

void CXmlWriter_Native::RegisterCustomNameSpace(const std::string &sNameSpace, const std::string &sNameSpacePrefix)
void CXmlWriter_Native::RegisterCustomNameSpace(const std::string &sNameSpace, const std::string &sNameSpacePrefix, bool bFailIfExisting)
{
std::string sDummy;
if (GetNamespacePrefix(sNameSpace, sDummy))
{
throw CNMRException(NMR_ERROR_XMLNAMESPACEALREADYREGISTERED);
if (bFailIfExisting)
throw CNMRException(NMR_ERROR_XMLNAMESPACEALREADYREGISTERED);

return;
}

for (auto it = m_sNameSpaces.begin(); it != m_sNameSpaces.end(); ++it)
if (it->second == sNameSpacePrefix)
throw CNMRException(NMR_ERROR_XMLPREFIXALREADYREGISTERED);
Expand Down
2 changes: 1 addition & 1 deletion Source/Model/Writer/NMR_ModelWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace NMR {
m_bAllowBinaryStreams = true;
}

void CModelWriter::registerCustomNameSpace(const std::string& sPrefix, const std::string& sNameSpace)
void CModelWriter::registerCustomNameSpace(const std::string& sPrefix, const std::string& sNameSpace, bool bFailIfExisting)
{
throw CNMRException(NMR_ERROR_WRITERDOESNOTSUPPORTNAMESPACES);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Model/Writer/NMR_ModelWriter_3MF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace NMR {
for (auto iIter : m_CustomNameSpaces) {
std::string sPrefix = iIter.first;
std::string sNameSpace = iIter.second;
ModelNode.registerCustomNamespace(sPrefix, sNameSpace);
ModelNode.registerCustomNamespace(sPrefix, sNameSpace, false);
}

for (auto iAssignmentIter : m_BinaryWriterAssignmentMap) {
Expand All @@ -132,7 +132,7 @@ namespace NMR {
m_AdditionalAttachments.insert(std::make_pair(sPath, std::make_pair(pStream, sRelationShipType)));
}

void CModelWriter_3MF::registerCustomNameSpace(const std::string& sPrefix, const std::string& sNameSpace)
void CModelWriter_3MF::registerCustomNameSpace(const std::string& sPrefix, const std::string& sNameSpace, bool bFailIfExisting)
{
if (sPrefix.empty ())
throw CNMRException(NMR_ERROR_INVALIDPARAM);
Expand Down
6 changes: 3 additions & 3 deletions Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace NMR {
std::string prefix = "customXMLNS" + std::to_string(m_pXMLWriter->GetNamespaceCount());
std::string sDummy;
if (!m_pXMLWriter->GetNamespacePrefix(md->getNameSpace(), sDummy)) {
m_pXMLWriter->RegisterCustomNameSpace(md->getNameSpace(), prefix);
m_pXMLWriter->RegisterCustomNameSpace(md->getNameSpace(), prefix, false);
}
}
}
Expand Down Expand Up @@ -924,9 +924,9 @@ namespace NMR {
m_bWriteBinaryExtension = bWriteBinaryExtension;
}

void CModelWriterNode100_Model::registerCustomNamespace(const std::string& sPrefix, const std::string& sNamespace)
void CModelWriterNode100_Model::registerCustomNamespace(const std::string& sPrefix, const std::string& sNamespace, bool bFailIfExisting)
{
m_pXMLWriter->RegisterCustomNameSpace(sNamespace, sPrefix);
m_pXMLWriter->RegisterCustomNameSpace(sNamespace, sPrefix, bFailIfExisting);
}

void CModelWriterNode100_Model::writeCustomToolpathXMLNode(PCustomXMLNode pXMLNode, const std::string& sPrefix)
Expand Down

0 comments on commit 1c3e445

Please sign in to comment.