Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SBMLNamespaces_addPackageNamespace{,s} functions to C API #235

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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