Skip to content

Commit

Permalink
Merge pull request #235 from giordano/mg/addpackagenamespace
Browse files Browse the repository at this point in the history
Add `SBMLNamespaces_addPackageNamespace{,s}` functions to C API
  • Loading branch information
fbergmann committed Jul 15, 2022
2 parents 6a512ff + e719502 commit 8344b88
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/sbml/SBMLNamespaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,30 @@ SBMLNamespaces_getSupportedNamespaces(int *length)
SBMLNamespaces::freeSBMLNamespaces(const_cast<List*>(supported));
return result;
}

LIBSBML_EXTERN
int
SBMLNamespaces_addPackageNamespace(SBMLNamespaces_t *sbmlns,
const char *pkgName,
unsigned int pkgVersion,
const char *prefix)
{
if (sbmlns != NULL)
return sbmlns->addPackageNamespace(pkgName, pkgVersion, prefix);
else
return LIBSBML_INVALID_OBJECT;
}

LIBSBML_EXTERN
int
SBMLNamespaces_addPackageNamespaces(SBMLNamespaces_t *sbmlns,
const XMLNamespaces_t * xmlns)
{
if (sbmlns != NULL)
return sbmlns->addPackageNamespaces(xmlns);
else
return LIBSBML_INVALID_OBJECT;
}
/** @endcond */

LIBSBML_CPP_NAMESPACE_END
Expand Down
50 changes: 50 additions & 0 deletions src/sbml/SBMLNamespaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,56 @@ LIBSBML_EXTERN
SBMLNamespaces_t **
SBMLNamespaces_getSupportedNamespaces(int *length);

/**
* Add an XML namespace (a pair of URI and prefix) of a package extension
* to the set of namespaces within this SBMLNamespaces object.
*
* The SBML Level and SBML Version of this object is used.
*
* @param sbmlns the SBMLNamespaces_t structure to add to.
* @param pkgName the string of package name (e.g. "layout", "multi").
* @param pkgVersion the package version.
* @param prefix the prefix of the package namespace to be added.
* The package's name will be used if the given string is empty (default).
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
*
* @note An XML namespace of a non-registered package extension can't be
* added by this function (@sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
* will be returned).
*
* @see addNamespace(@if java String, String@endif)
*/
LIBSBML_EXTERN
int
SBMLNamespaces_addPackageNamespace(SBMLNamespaces_t *sbmlns,
const char *pkgName,
unsigned int pkgVersion,
const char *prefix);

/**
* Add the XML namespaces of package extensions in the given XMLNamespace
* object to the set of namespaces within this SBMLNamespaces object
* (Non-package XML namespaces are not added by this function).
*
* @param sbmlns the SBMLNamespaces_t structure to add to.
* @param xmlns the XML namespaces to be added.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
*
* @note XML namespaces of a non-registered package extensions are not
* added (just ignored) by this function. @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t} will be returned if the given
* xmlns is @c NULL.
*/
LIBSBML_EXTERN
int
SBMLNamespaces_addPackageNamespaces(SBMLNamespaces_t *sbmlns,
const XMLNamespaces_t * xmlns);

END_C_DECLS
LIBSBML_CPP_NAMESPACE_END

Expand Down

0 comments on commit 8344b88

Please sign in to comment.