Skip to content

Commit 8344b88

Browse files
authored
Merge pull request #235 from giordano/mg/addpackagenamespace
Add `SBMLNamespaces_addPackageNamespace{,s}` functions to C API
2 parents 6a512ff + e719502 commit 8344b88

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

src/sbml/SBMLNamespaces.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,30 @@ SBMLNamespaces_getSupportedNamespaces(int *length)
889889
SBMLNamespaces::freeSBMLNamespaces(const_cast<List*>(supported));
890890
return result;
891891
}
892+
893+
LIBSBML_EXTERN
894+
int
895+
SBMLNamespaces_addPackageNamespace(SBMLNamespaces_t *sbmlns,
896+
const char *pkgName,
897+
unsigned int pkgVersion,
898+
const char *prefix)
899+
{
900+
if (sbmlns != NULL)
901+
return sbmlns->addPackageNamespace(pkgName, pkgVersion, prefix);
902+
else
903+
return LIBSBML_INVALID_OBJECT;
904+
}
905+
906+
LIBSBML_EXTERN
907+
int
908+
SBMLNamespaces_addPackageNamespaces(SBMLNamespaces_t *sbmlns,
909+
const XMLNamespaces_t * xmlns)
910+
{
911+
if (sbmlns != NULL)
912+
return sbmlns->addPackageNamespaces(xmlns);
913+
else
914+
return LIBSBML_INVALID_OBJECT;
915+
}
892916
/** @endcond */
893917

894918
LIBSBML_CPP_NAMESPACE_END

src/sbml/SBMLNamespaces.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,56 @@ LIBSBML_EXTERN
778778
SBMLNamespaces_t **
779779
SBMLNamespaces_getSupportedNamespaces(int *length);
780780

781+
/**
782+
* Add an XML namespace (a pair of URI and prefix) of a package extension
783+
* to the set of namespaces within this SBMLNamespaces object.
784+
*
785+
* The SBML Level and SBML Version of this object is used.
786+
*
787+
* @param sbmlns the SBMLNamespaces_t structure to add to.
788+
* @param pkgName the string of package name (e.g. "layout", "multi").
789+
* @param pkgVersion the package version.
790+
* @param prefix the prefix of the package namespace to be added.
791+
* The package's name will be used if the given string is empty (default).
792+
*
793+
* @copydetails doc_returns_success_code
794+
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
795+
* @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
796+
*
797+
* @note An XML namespace of a non-registered package extension can't be
798+
* added by this function (@sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
799+
* will be returned).
800+
*
801+
* @see addNamespace(@if java String, String@endif)
802+
*/
803+
LIBSBML_EXTERN
804+
int
805+
SBMLNamespaces_addPackageNamespace(SBMLNamespaces_t *sbmlns,
806+
const char *pkgName,
807+
unsigned int pkgVersion,
808+
const char *prefix);
809+
810+
/**
811+
* Add the XML namespaces of package extensions in the given XMLNamespace
812+
* object to the set of namespaces within this SBMLNamespaces object
813+
* (Non-package XML namespaces are not added by this function).
814+
*
815+
* @param sbmlns the SBMLNamespaces_t structure to add to.
816+
* @param xmlns the XML namespaces to be added.
817+
*
818+
* @copydetails doc_returns_success_code
819+
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
820+
* @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
821+
*
822+
* @note XML namespaces of a non-registered package extensions are not
823+
* added (just ignored) by this function. @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t} will be returned if the given
824+
* xmlns is @c NULL.
825+
*/
826+
LIBSBML_EXTERN
827+
int
828+
SBMLNamespaces_addPackageNamespaces(SBMLNamespaces_t *sbmlns,
829+
const XMLNamespaces_t * xmlns);
830+
781831
END_C_DECLS
782832
LIBSBML_CPP_NAMESPACE_END
783833

0 commit comments

Comments
 (0)