コード例 #1
0
def writeListOfSubElements(attrib, output, element):
    loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_add{1}({0}_t * {2}, '.format(
        element, strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(element)))
    output.write('{0}_t * {1});\n\n\n'.format(
        attrib['element'], strFunctions.objAbbrev(attrib['element'])))
    if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and
                                               attrib['abstract'] == False):
        output.write('LIBSEDML_EXTERN\n')
        output.write('{0}_t *\n'.format(attrib['element']))
        output.write('{0}_create{1}({0}_t * {2}'.format(
            element, strFunctions.cap(attrib['name']),
            strFunctions.objAbbrev(element)))
        output.write(');\n\n\n')
    elif attrib.has_key('concrete'):
        for elem in attrib['concrete']:
            output.write('LIBSEDML_EXTERN\n')
            output.write('{0}_t *\n'.format(elem['element']))
            output.write('{0}_create{1}({0}_t * {2}'.format(
                element, strFunctions.cap(elem['name']),
                strFunctions.objAbbrev(element)))
            output.write(');\n\n\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('SedListOf_t *\n')
    output.write('{0}_get{1}({0}_t * {2})'.format(
        element, loname, strFunctions.objAbbrev(element)))
    output.write(';\n\n\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(attrib['element']))
    output.write('{0}_get{1}({0}_t * {2}, '.format(
        element, strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(element)))
    output.write('unsigned int n);\n\n\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(attrib['element']))
    output.write('{0}_get{1}ById({0}_t * {2}, '.format(
        element, strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(element)))
    output.write('const char * sid);\n\n\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('unsigned int\n')
    output.write('{0}_getNum{1}s({0}_t * {2}'.format(
        element, strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(element)))
    output.write(');\n\n\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(attrib['element']))
    output.write('{0}_remove{1}({0}_t * {2}, '.format(
        element, strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(element)))
    output.write('unsigned int n);\n\n\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(attrib['element']))
    output.write('{0}_remove{1}ById({0}_t * {2}, '.format(
        element, strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(element)))
    output.write('const char * sid);\n\n\n')
コード例 #2
0
def writeGetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if att[3] == 'const char *':
    attTypeCode = 'char *'
  else:
    attTypeCode = att[3]
  num = att[4]
  if attrib['type'] != 'element' and attrib['type'] != 'lo_element':
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}_get{1}'.format(element, capAttName))
    output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('LIBSEDML_EXTERN\n')
      output.write('ASTNode_t*\n')
      output.write('{0}_getMath'.format(element))
      output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
    else:
      output.write('LIBSEDML_EXTERN\n')
      output.write('{0}_t*\n'.format(strFunctions.cap(attrib['element'])))
      output.write('{0}_get{1}'.format(element, capAttName))
      output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
      output.write('LIBSEDML_EXTERN\n')
      output.write('{0}_t*\n'.format(strFunctions.cap(attrib['element'])))
      output.write('{0}_create{1}'.format(element, capAttName))
      output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
コード例 #3
0
def writeUnsetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib["type"] == "element" or attrib["type"] == "lo_element" or attrib["type"] == "inline_lo_element":
        return
    output.write("/**\n")
    output.write(' * Unsets the value of the "{0}" attribute of the given \n'.format(attName))
    output.write(" * {0}_t structure.\n *\n".format(element))
    output.write(" * @param {0} the {1}_t structure.\n *\n".format(strFunctions.objAbbrev(element), element))
    output.write(" * @return integer value indicating success/failure of the\n")
    output.write(" * function.  @if clike The value is drawn from the\n")
    output.write(" * enumeration #OperationReturnValues_t. @endif@~ The possible values\n")
    output.write(" * returned by this function are:\n")
    output.write(" * @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink\n")
    output.write(" * @li @link OperationReturnValues_t#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink\n")
    output.write(" * @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink\n *\n")
    output.write(" * @member of {0}_t\n".format(element))
    output.write(" */\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("int\n")
    output.write("{0}_unset{1}".format(element, capAttName))
    output.write("({0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
コード例 #4
0
def writeIsSetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib['type'] != 'lo_element' and attrib['type'] != 'inline_lo_element':
        output.write('/**\n')
        output.write(
            ' * Predicate returning @c 1 if the given {0}_t structure\'s \"{1}\"\n'
            .format(element, attName))
        output.write(' * is set.\n *\n')
        output.write(' * @param {0} the {1}_t structure.\n *\n'.format(
            strFunctions.objAbbrev(element), element))
        output.write(
            ' * @return @c 1 if the \"{0}\" of this {1}_t structure is\n'.
            format(attName, element))
        output.write(' * set, @c 0 otherwise.\n *\n')
        output.write(' * @member of {0}_t\n'.format(element))
        output.write(' */\n')
        output.write('LIBSBML_EXTERN\n')
        output.write('int\n')
        output.write('{0}_isSet{1}'.format(element, capAttName))
        output.write('(const {0}_t * {1});\n\n\n'.format(
            element, strFunctions.objAbbrev(element)))
コード例 #5
0
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] != 'element' and attrib['type'] != 'lo_element':
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_set{1}'.format(element, capAttName))
    output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
    output.write(' {0} {1});\n\n\n'.format(attTypeCode, attName))
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('LIBSEDML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_setMath'.format(element))
      output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
      output.write(' ASTNode_t* {0});\n\n\n'.format(attName))
    else:
      output.write('LIBSEDML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
      output.write(' {0}_t* {1});\n\n\n'.format(attrib['element'], attName))
コード例 #6
0
ファイル: writeCHeader.py プロジェクト: 0u812/libSEDML
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'std::vector<double>':
    return
  elif attrib['type'] != 'element' and attrib['type'] != 'lo_element' and attrib['type'] != 'XMLNode*':
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_set{1}'.format(element, capAttName))
    output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
    output.write(' {0} {1});\n\n\n'.format(attTypeCode, attName))
  elif attrib['type'] == 'XMLNode*':
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_set{1}'.format(element, capAttName))
    output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
    output.write(' XMLNode_t* {0});\n\n\n'.format(attName))
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('LIBSEDML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_setMath'.format(element))
      output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
      output.write(' ASTNode_t* {0});\n\n\n'.format(attName))
    else:
      output.write('LIBSEDML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, strFunctions.objAbbrev(element)))
      output.write(' {0}_t* {1});\n\n\n'.format(attrib['element'], attName))
コード例 #7
0
def writeConstructors(element, package, output):
    indent = strFunctions.getIndent(element)
    output.write('/**\n')
    output.write(
        ' * Creates a new {0}_t structure using the given SBML @p level and\n'.
        format(element))
    output.write(' * @p version values.\n *\n')
    output.write(
        ' * @param level an unsigned int, the SBML level to assign to this\n')
    output.write(' * {0}_t structure.\n *\n'.format(element))
    output.write(
        ' * @param version an unsigned int, the SBML version to assign to this\n'
    )
    output.write(' * {0}_t structure.\n *\n'.format(element))
    output.write(
        ' * @returns the newly-created {0}_t structure, or a null pointer if\n'
        .format(element))
    output.write(' * an error occurred during construction.\n *\n')
    output.write(' * @copydetails doc_note_setting_lv\n *\n')
    output.write(' * @memberof {0}_t\n'.format(element))
    output.write(' */\n')
    output.write('LIBSBML_EXTERN\n')
    output.write('{0}_t *\n'.format(element))
    output.write('{0}_create'.format(element))
    output.write('(unsigned int level, unsigned int version,\n')
    output.write('{0}       unsigned int pkgVersion);\n\n\n'.format(indent))
    #  output.write('LIBSBML_EXTERN\n')
    #  output.write('{0}_t *\n'.format(element))
    #  output.write('{0}_createWithNS'.format(element))
    #  output.write('(SBMLNamespaces_t *sbmlns);\n\n\n')
    output.write('/**\n')
    output.write(' * Frees the given {0}_t structure.\n * \n'.format(element))
    output.write(' * @param {0} the {1}_t structure to be freed.\n *\n'.format(
        strFunctions.objAbbrev(element), element))
    output.write(' * @memberof {0}_t\n'.format(element))
    output.write(' */\n')
    output.write('LIBSBML_EXTERN\n')
    output.write('void\n')
    output.write('{0}_free'.format(element))
    output.write('({0}_t * {1});\n\n\n'.format(
        element, strFunctions.objAbbrev(element)))
    output.write('/**\n')
    output.write(
        ' * Creates a deep copy of the given {0}_t structure.\n * \n'.format(
            element))
    output.write(
        ' * @param {0} the {1}_t structure to be copied.\n *\n'.format(
            strFunctions.objAbbrev(element), element))
    output.write(
        ' * @returns a (deep) copy of the given {0}_t structure, or a null\n'.
        format(element))
    output.write(' * pointer if a failure occurred.\n *\n')
    output.write(' * @memberof {0}_t\n'.format(element))
    output.write(' */\n')
    output.write('LIBSBML_EXTERN\n')
    output.write('{0}_t *\n'.format(element))
    output.write('{0}_clone'.format(element))
    output.write('({0}_t * {1});\n\n\n'.format(
        element, strFunctions.objAbbrev(element)))
コード例 #8
0
def writeListOfSubFunctions(attrib, output, element, elementDict):
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  output.write('  /**\n')
  output.write('   * Returns the  \"{0}\"'.format(loname))
  output.write(' in this {0} object.\n'.format(element))
  output.write('   *\n')
  output.write('   * @return the \"{0}\"'.format(loname))
  output.write(' attribute of this {0}.\n'.format(element))
  output.write('   */\n')
  output.write('  const {0}*'.format(loname))
  output.write(' getListOf{0}s() const;\n\n\n'.format(strFunctions.cap(attrib['name'])))
  writeListOfHeader.writeGetFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element)
  output.write('  /**\n')
  output.write('   * Adds a copy the given \"{0}\" to this {1}.\n'.format(attrib['element'], element))
  output.write('   *\n')
  output.write('   * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element']))
  output.write('   *\n')
  output.write('   * @return integer value indicating success/failure of the\n')
  output.write('   * function.  @if clike The value is drawn from the\n')
  output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
  output.write('   * returned by this function are:\n')
  output.write('   * @li LIBSEDML_OPERATION_SUCCESS\n')
  output.write('   * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  output.write('   */\n')
  output.write('  int add{0}(const {1}* {2});\n\n\n'.format(strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('  /**\n')
  output.write('   * Get the number of {0} objects in this {1}.\n'.format(attrib['element'], element))
  output.write('   *\n')
  output.write('   * @return the number of {0} objects in this {1}\n'.format(attrib['element'], element))
  output.write('   */\n')
  output.write('  unsigned int getNum{0}s() const;\n\n\n'.format(strFunctions.cap(attrib['name'])))
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
    output.write('  /**\n')
    output.write('   * Creates a new {0} object, adds it to this {1}s\n'.format(attrib['element'], element))
    output.write('   * {0} and returns the {1} object created.\n'.format(loname, attrib['element']))
    output.write('   *\n')
    output.write('   * @return a new {0} object instance\n'.format(attrib['element']))
    output.write('   *\n')
    output.write('   * @see add{0}(const {1}* {2})\n'.format(strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
    output.write('   */\n')
    output.write('  {0}* create{1}();\n\n\n'.format(attrib['element'], strFunctions.cap(attrib['name'])))
  elif attrib.has_key('concrete'):
    for elem in attrib['concrete']:
      output.write('  /**\n')
      output.write('   * Creates a new {0} object, adds it to this {1}s\n'.format(elem['element'], element))
      output.write('   * {0} and returns the {1} object created.\n'.format(loname, elem['element']))
      output.write('   *\n')
      output.write('   * @return a new {0} object instance\n'.format(elem['element']))
      output.write('   *\n')
      output.write('   * @see add{0}(const {0}* {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write('   */\n')
      output.write('  {0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name'])))
  writeListOfHeader.writeRemoveFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element)
コード例 #9
0
def writeHasReqdElementsFunction(output, element):
    output.write("/**\n")
    output.write(" * Predicate returning @c 1 or *c 0 depending on whether all the required\n")
    output.write(" * sub-elements of the given {0}_t structure have been set.\n *\n".format(element))
    output.write(" * @param {0} the {1}_t structure to check.\n *\n".format(strFunctions.objAbbrev(element), element))
    output.write(" * @return @c 1 if all the required sub-elements for this\n")
    output.write(" * structure have been defined, @c 0 otherwise.\n *\n")
    output.write(" * @member of {0}_t\n".format(element))
    output.write(" */\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("int\n")
    output.write("{0}_hasRequiredElements".format(element))
    output.write("(const {0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
コード例 #10
0
def writeConstructors(element, package, output):
    indent = strFunctions.getIndent(element)
    output.write("/**\n")
    output.write(" * Creates a new {0}_t structure using the given SBML @p level and\n".format(element))
    output.write(" * @p version values.\n *\n")
    output.write(" * @param level an unsigned int, the SBML level to assign to this\n")
    output.write(" * {0}_t structure.\n *\n".format(element))
    output.write(" * @param version an unsigned int, the SBML version to assign to this\n")
    output.write(" * {0}_t structure.\n *\n".format(element))
    output.write(" * @returns the newly-created {0}_t structure, or a null pointer if\n".format(element))
    output.write(" * an error occurred during construction.\n *\n")
    output.write(" * @copydetails doc_note_setting_lv\n *\n")
    output.write(" * @memberof {0}_t\n".format(element))
    output.write(" */\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("{0}_t *\n".format(element))
    output.write("{0}_create".format(element))
    output.write("(unsigned int level, unsigned int version,\n")
    output.write("{0}       unsigned int pkgVersion);\n\n\n".format(indent))
    #  output.write('LIBSBML_EXTERN\n')
    #  output.write('{0}_t *\n'.format(element))
    #  output.write('{0}_createWithNS'.format(element))
    #  output.write('(SBMLNamespaces_t *sbmlns);\n\n\n')
    output.write("/**\n")
    output.write(" * Frees the given {0}_t structure.\n * \n".format(element))
    output.write(
        " * @param {0} the {1}_t structure to be freed.\n *\n".format(strFunctions.objAbbrev(element), element)
    )
    output.write(" * @memberof {0}_t\n".format(element))
    output.write(" */\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("void\n")
    output.write("{0}_free".format(element))
    output.write("({0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
    output.write("/**\n")
    output.write(" * Creates a deep copy of the given {0}_t structure.\n * \n".format(element))
    output.write(
        " * @param {0} the {1}_t structure to be copied.\n *\n".format(strFunctions.objAbbrev(element), element)
    )
    output.write(" * @returns a (deep) copy of the given {0}_t structure, or a null\n".format(element))
    output.write(" * pointer if a failure occurred.\n *\n")
    output.write(" * @memberof {0}_t\n".format(element))
    output.write(" */\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("{0}_t *\n".format(element))
    output.write("{0}_clone".format(element))
    output.write("({0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
コード例 #11
0
ファイル: writeCHeader.py プロジェクト: 0u812/libSEDML
def writeConstructors(element, package, output):
  indent = strFunctions.getIndent(element)
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(element))
  output.write('{0}_create'.format(element))
  output.write('(unsigned int level, unsigned int version);\n\n\n')
#  output.write('LIBSEDML_EXTERN\n')
#  output.write('{0}_t *\n'.format(element))
#  output.write('{0}_createWithNS'.format(element))
#  output.write('(SedNamespaces_t *sedmlns);\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('void\n')
  output.write('{0}_free'.format(element))
  output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(element))
  output.write('{0}_clone'.format(element))
  output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
コード例 #12
0
def writeConstructors(element, package, output):
  indent = strFunctions.getIndent(element)
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(element))
  output.write('{0}_create'.format(element))
  output.write('(unsigned int level, unsigned int version);\n\n\n')
#  output.write('LIBSEDML_EXTERN\n')
#  output.write('{0}_t *\n'.format(element))
#  output.write('{0}_createWithNS'.format(element))
#  output.write('(SedNamespaces_t *sedmlns);\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('void\n')
  output.write('{0}_free'.format(element))
  output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(element))
  output.write('{0}_clone'.format(element))
  output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
コード例 #13
0
ファイル: writeCCode.py プロジェクト: nrnb/gsoc2016hovakim
def writeHasReqdElementsFunction(output, element):
  varname = strFunctions.objAbbrev(element)
  output.write('LIBSBML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_hasRequiredElements'.format(element))
  output.write('(const {0}_t * {1})\n'.format(element, varname))
  output.write('{\n')
  output.write('\treturn ({0} != NULL) ? static_cast<int>({0}->hasRequiredElements()) : 0;\n'.format(varname))
  output.write('}\n\n\n')
コード例 #14
0
def writeAddFunction(code, type, listOf, name):
    code.write('/**\n')
    code.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(
        type, listOf))
    code.write(' *\n')
    code.write(' * @param {0}; the {1} object to add\n'.format(
        strFunctions.objAbbrev(type), type))
    code.write(' *\n')
    code.write(' * @return integer value indicating success/failure of the\n')
    code.write(' * function.  @if clike The value is drawn from the\n')
    code.write(
        ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
    )
    code.write(' * returned by this function are:\n')
    code.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
    code.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    code.write(' */\n')
    code.write('int\n')
    code.write('{0}::add{1}(const {2}* {3})\n'.format(
        listOf, strFunctions.cap(name), type, strFunctions.objAbbrev(type)))
    code.write('{\n')

    code.write('  if ({0} == NULL)\n'.format(strFunctions.objAbbrev(type)))
    code.write('  {\n')
    code.write('    return LIBSBML_OPERATION_FAILED;\n')
    code.write('  }\n')
    code.write('  else if ({0}->hasRequiredAttributes() == false)\n'.format(
        strFunctions.objAbbrev(type)))
    code.write('  {\n')
    code.write('    return LIBSBML_INVALID_OBJECT;\n')
    code.write('  }\n')
    code.write('  else if (getLevel() != {0}->getLevel())\n'.format(
        strFunctions.objAbbrev(type)))
    code.write('  {\n')
    code.write('    return LIBSBML_LEVEL_MISMATCH;\n')
    code.write('  }\n')
    code.write('  else if (getVersion() != {0}->getVersion())\n'.format(
        strFunctions.objAbbrev(type)))
    code.write('  {\n')
    code.write('    return LIBSBML_VERSION_MISMATCH;\n')
    code.write('  }\n')
    code.write(
        '  else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>({0})) == false)\n'
        .format(strFunctions.objAbbrev(type)))
    code.write('  {\n')
    code.write('    return LIBSBML_NAMESPACES_MISMATCH;\n')
    code.write('  }\n')
    code.write('  else\n')
    code.write('  {\n')
    code.write('\tappend({0});\n'.format(strFunctions.objAbbrev(type)))
    code.write('    return LIBSBML_OPERATION_SUCCESS;\n')
    code.write('  }\n')
    code.write('}\n\n\n')
コード例 #15
0
def writeHasReqdElementsFunction(output, element):
    output.write('/**\n')
    output.write(
        ' * Predicate returning @c 1 or *c 0 depending on whether all the required\n'
    )
    output.write(
        ' * sub-elements of the given {0}_t structure have been set.\n *\n'.
        format(element))
    output.write(' * @param {0} the {1}_t structure to check.\n *\n'.format(
        strFunctions.objAbbrev(element), element))
    output.write(' * @return @c 1 if all the required sub-elements for this\n')
    output.write(' * structure have been defined, @c 0 otherwise.\n *\n')
    output.write(' * @member of {0}_t\n'.format(element))
    output.write(' */\n')
    output.write('LIBSBML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_hasRequiredElements'.format(element))
    output.write('(const {0}_t * {1});\n\n\n'.format(
        element, strFunctions.objAbbrev(element)))
コード例 #16
0
def writeIsSetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib["type"] != "lo_element" and attrib["type"] != "inline_lo_element":
        output.write("/**\n")
        output.write(' * Predicate returning @c 1 if the given {0}_t structure\'s "{1}"\n'.format(element, attName))
        output.write(" * is set.\n *\n")
        output.write(" * @param {0} the {1}_t structure.\n *\n".format(strFunctions.objAbbrev(element), element))
        output.write(' * @return @c 1 if the "{0}" of this {1}_t structure is\n'.format(attName, element))
        output.write(" * set, @c 0 otherwise.\n *\n")
        output.write(" * @member of {0}_t\n".format(element))
        output.write(" */\n")
        output.write("LIBSBML_EXTERN\n")
        output.write("int\n")
        output.write("{0}_isSet{1}".format(element, capAttName))
        output.write("(const {0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
コード例 #17
0
ファイル: writeCHeader.py プロジェクト: 0u812/libSEDML
def writeListOfSubElements(attrib, output, element):
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  output.write('LIBSEDML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_add{1}({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('{0}_t * {1});\n\n\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(attrib['element']))
    output.write('{0}_create{1}({0}_t * {2}' .format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
    output.write(');\n\n\n')
  elif attrib.has_key('concrete'):
    for elem in attrib['concrete']:
      output.write('LIBSEDML_EXTERN\n')
      output.write('{0}_t *\n'.format(elem['element']))
      output.write('{0}_create{1}({0}_t * {2}' .format(element, strFunctions.cap(elem['name']), strFunctions.objAbbrev(element)))
      output.write(');\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('SedListOf_t *\n')
  output.write('{0}_get{1}({0}_t * {2})'.format(element, loname, strFunctions.objAbbrev(element)))
  output.write(';\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_get{1}({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('unsigned int n);\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_get{1}ById({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('const char * sid);\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('unsigned int\n')
  output.write('{0}_getNum{1}s({0}_t * {2}' .format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write(');\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_remove{1}({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('unsigned int n);\n\n\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_remove{1}ById({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('const char * sid);\n\n\n')
コード例 #18
0
def writeHasReqdAttrFunction(output, element):
  varname = strFunctions.objAbbrev(element)
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_hasRequiredAttributes'.format(element))
  output.write('({0}_t * {1})\n'.format(element, varname))
  output.write('{\n')
  output.write('  return ({0} != NULL) ? static_cast<int>({0}->hasRequiredAttributes()) : 0;\n'.format(varname))
  output.write('}\n\n\n')
コード例 #19
0
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] != 'lo_element':
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_isSet{1}'.format(element, capAttName))
    output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
コード例 #20
0
ファイル: writeCCode.py プロジェクト: hsorby/libSEDML
def writeHasReqdAttrFunction(output, element):
  varname = strFunctions.objAbbrev(element)
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_hasRequiredAttributes'.format(element))
  output.write('({0}_t * {1})\n'.format(element, varname))
  output.write('{\n')
  output.write('\treturn ({0} != NULL) ? static_cast<int>({0}->hasRequiredAttributes()) : 0;\n'.format(varname))
  output.write('}\n\n\n')
コード例 #21
0
def writeUnsetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib['type'] == 'element' or attrib['type'] == 'lo_element' or attrib[
            'type'] == 'inline_lo_element':
        return
    output.write('/**\n')
    output.write(
        ' * Unsets the value of the \"{0}\" attribute of the given \n'.format(
            attName))
    output.write(' * {0}_t structure.\n *\n'.format(element))
    output.write(' * @param {0} the {1}_t structure.\n *\n'.format(
        strFunctions.objAbbrev(element), element))
    output.write(
        ' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(
        ' * enumeration #OperationReturnValues_t. @endif@~ The possible values\n'
    )
    output.write(' * returned by this function are:\n')
    output.write(
        ' * @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink\n'
    )
    output.write(
        ' * @li @link OperationReturnValues_t#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink\n'
    )
    output.write(
        ' * @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink\n *\n'
    )
    output.write(' * @member of {0}_t\n'.format(element))
    output.write(' */\n')
    output.write('LIBSBML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_unset{1}'.format(element, capAttName))
    output.write('({0}_t * {1});\n\n\n'.format(
        element, strFunctions.objAbbrev(element)))
コード例 #22
0
ファイル: writeListOfHeader.py プロジェクト: 0u812/libSEDML
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict):
  header.write('class LIBSEDML_EXTERN {0} :'.format(generalFunctions.writeListOf(nameOfElement)))
  header.write(' public SedListOf\n{0}\n\n'.format('{'))
  header.write('public:\n\n')
  writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header)
  writeGetFunctions(header, nameOfElement, typeOfElement)
  header.write('  /**\n')
  header.write('   * Adds a copy the given \"{0}\" to this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement)))
  header.write('   *\n')
  header.write('   * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(nameOfElement), nameOfElement))
  header.write('   *\n')
  header.write('   * @return integer value indicating success/failure of the\n')
  header.write('   * function.  @if clike The value is drawn from the\n')
  header.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
  header.write('   * returned by this function are:\n')
  header.write('   * @li LIBSEDML_OPERATION_SUCCESS\n')
  header.write('   * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  header.write('   */\n')
  header.write('  int add{0}(const {1}* {2});\n\n\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
  header.write('  /**\n')
  header.write('   * Get the number of {0} objects in this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement)))
  header.write('   *\n')
  header.write('   * @return the number of {0} objects in this {1}\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement)))
  header.write('   */\n')
  header.write('  unsigned int getNum{0}s() const;\n\n\n'.format(nameOfElement))
  if elementDict.has_key('abstract') == False or (elementDict.has_key('abstract') and elementDict['abstract'] == False):
    header.write('  /**\n')
    header.write('   * Creates a new {0} object, adds it to the\n'.format(nameOfElement))
    header.write('   * {0} and returns the {1} object created.\n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement))
    header.write('   *\n')
    header.write('   * @return a new {0} object instance\n'.format(nameOfElement))
    header.write('   *\n')
    header.write('   * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
    header.write('   */\n')
    header.write('  {0}* create{1}();\n\n\n'.format(typeOfElement, nameOfElement))
  elif elementDict.has_key('concrete'):
    for elem in elementDict['concrete']:
      header.write('  /**\n')
      header.write('   * Creates a new {0} object, adds it to the\n'.format(nameOfElement))
      header.write('   * {0} and returns the {1} object created.\n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement))
      header.write('   *\n')
      header.write('   * @return a new {0} object instance\n'.format(nameOfElement))
      header.write('   *\n')
      header.write('   * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
      header.write('   */\n')
      header.write('  {0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name'])))
  writeRemoveFunctions(header, nameOfElement, typeOfElement)
  generalFunctions.writeCommonHeaders(header, nameOfElement, None, True)
  header.write('protected:\n\n')
  writeProtectedFunctions(header, nameOfElement, nameOfPackage)
  header.write('\n};\n\n')
コード例 #23
0
ファイル: writeListOfHeader.py プロジェクト: hsorby/libSEDML
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict):
  header.write('class LIBSEDML_EXTERN {0} :'.format(generalFunctions.writeListOf(nameOfElement)))
  header.write(' public SedListOf\n{0}\n\n'.format('{'))
  header.write('public:\n\n')
  writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header)
  writeGetFunctions(header, nameOfElement, typeOfElement)
  header.write('\t/**\n')
  header.write('\t * Adds a copy the given \"{0}\" to this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement)))
  header.write('\t *\n')
  header.write('\t * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(nameOfElement), nameOfElement))
  header.write('\t *\n')
  header.write('\t * @return integer value indicating success/failure of the\n')
  header.write('\t * function.  @if clike The value is drawn from the\n')
  header.write('\t * enumeration #OperationReturnValues_t. @endif The possible values\n')
  header.write('\t * returned by this function are:\n')
  header.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
  header.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  header.write('\t */\n')
  header.write('\tint add{0}(const {1}* {2});\n\n\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
  header.write('\t/**\n')
  header.write('\t * Get the number of {0} objects in this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement)))
  header.write('\t *\n')
  header.write('\t * @return the number of {0} objects in this {1}\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement)))
  header.write('\t */\n')
  header.write('\tunsigned int getNum{0}s() const;\n\n\n'.format(nameOfElement))
  if elementDict.has_key('abstract') == False or (elementDict.has_key('abstract') and elementDict['abstract'] == False):
    header.write('\t/**\n')
    header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement))
    header.write('\t * {0} and returns the {1} object created. \n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement))
    header.write('\t *\n')
    header.write('\t * @return a new {0} object instance\n'.format(nameOfElement))
    header.write('\t *\n')
    header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
    header.write('\t */\n')
    header.write('\t{0}* create{1}();\n\n\n'.format(typeOfElement, nameOfElement))
  elif elementDict.has_key('concrete'):
    for elem in elementDict['concrete']:
      header.write('\t/**\n')
      header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement))
      header.write('\t * {0} and returns the {1} object created. \n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement))
      header.write('\t *\n')
      header.write('\t * @return a new {0} object instance\n'.format(nameOfElement))
      header.write('\t *\n')
      header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
      header.write('\t */\n')
      header.write('\t{0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name'])))
  writeRemoveFunctions(header, nameOfElement, typeOfElement)
  generalFunctions.writeCommonHeaders(header, nameOfElement, None, True)
  header.write('protected:\n\n')
  writeProtectedFunctions(header, nameOfElement, nameOfPackage)
  header.write('\n};\n\n')
コード例 #24
0
ファイル: writeCCode.py プロジェクト: nrnb/gsoc2016hovakim
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  cleanName = strFunctions.cleanStr(attName)
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  if attrib['type'] == 'array':
    return
  varname = strFunctions.objAbbrev(element)
  if attrib['type'] != 'element' and attrib['type'] != 'lo_element' and attrib['type'] != 'inline_lo_element':
      output.write('LIBSBML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, varname))
      output.write(' {0} {1})\n'.format(attTypeCode, cleanName))
      output.write('{\n')
      output.write('  if ({0} != NULL)\n'.format(varname))
      if num or attrib['type'] == 'enum':
        output.write('    return {1}->set{2}({0});\n'.format(cleanName, varname, capAttName))
      elif attrib['type'] == 'array':
        output.write('    return ({0} == NULL) ? {1}->unset{2}() : {1}->set{2}({0});\n'.format(cleanName, varname, capAttName))
      else:
        output.write('    return ({0} == NULL) ? {1}->set{2}("") : {1}->set{2}({0});\n'.format(cleanName, varname, capAttName))
      output.write('  else\n')
      output.write('    return LIBSBML_INVALID_OBJECT;\n')
#      output.write('  return ({0} != NULL) ? {0}->set{1}({2}) : LIBSBML_INVALID_OBJECT;\n'.format(varname, capAttName, attName))
      output.write('}\n\n\n')
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('LIBSBML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, varname))
      output.write(' const {0} {1})\n'.format('ASTNode_t*', cleanName))
      output.write('{\n')
      output.write('\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSBML_INVALID_OBJECT;\n'.format(varname, capAttName, cleanName))
      output.write('}\n\n\n')
    else:
      output.write('LIBSBML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, varname))
      output.write(' {0}_t* {1})\n'.format(attrib['element'], cleanName))
      output.write('{\n')
      output.write('\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSBML_INVALID_OBJECT;\n'.format(varname, capAttName, cleanName))
      output.write('}\n\n\n')
コード例 #25
0
ファイル: writeCHeader.py プロジェクト: 0u812/libSEDML
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'std::vector<double>':
    return
  elif attrib['type'] != 'lo_element':
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_isSet{1}'.format(element, capAttName))
    output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
コード例 #26
0
def writeUnsetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib['type'] == 'lo_element':
        return
    if attrib['type'] == 'std::vector<double>':
        return
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_unset{1}'.format(element, capAttName))
    output.write('({0}_t * {1});\n\n\n'.format(
        element, strFunctions.objAbbrev(element)))
コード例 #27
0
def writeConstructors(element, package, output):
    indent = strFunctions.getIndent(element)
    output.write('/**\n')
    output.write(' * write comments\n')
    output.write(' */\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(element))
    output.write('{0}_create'.format(element))
    output.write('(unsigned int level, unsigned int version)\n')
    output.write('{\n')
    output.write('\treturn new {0}(level, version);\n'.format(element))
    output.write('}\n\n\n')
    #  output.write('/**\n')
    #  output.write(' * write comments\n')
    #  output.write(' */\n')
    #  output.write('LIBSEDML_EXTERN\n')
    #  output.write('{0}_t *\n'.format(element))
    #  output.write('{0}_createWithNS'.format(element))
    #  output.write('(SedNamespaces_t *sedmlns)\n')
    #  output.write('{\n')
    #  output.write('\treturn new {0}(sedmlns);\n'.format(element))
    #  output.write('}\n\n\n')
    output.write('/**\n')
    output.write(' * write comments\n')
    output.write(' */\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('void\n')
    output.write('{0}_free'.format(element))
    output.write('({0}_t * {1})\n'.format(element,
                                          strFunctions.objAbbrev(element)))
    output.write('{\n')
    output.write('\tif ({0} != NULL)\n'.format(
        strFunctions.objAbbrev(element)))
    output.write('\t\tdelete {0};\n'.format(strFunctions.objAbbrev(element)))
    output.write('}\n\n\n')
    output.write('/**\n')
    output.write(' * write comments\n')
    output.write(' */\n')
    output.write('LIBSEDML_EXTERN\n')
    output.write('{0}_t *\n'.format(element))
    output.write('{0}_clone'.format(element))
    output.write('({0}_t * {1})\n'.format(element,
                                          strFunctions.objAbbrev(element)))
    output.write('{\n')
    output.write('\tif ({0} != NULL)\n'.format(
        strFunctions.objAbbrev(element)))
    output.write('\t{\n')
    output.write('\t\treturn static_cast<{0}_t*>({1}->clone());\n'.format(
        element, strFunctions.objAbbrev(element)))
    output.write('\t}\n')
    output.write('\telse\n')
    output.write('\t{\n')
    output.write('\t\treturn NULL;\n')
    output.write('\t}\n')
    output.write('}\n\n\n')
コード例 #28
0
def writeSetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib['type'] == 'lo_element':
        return
    varname = strFunctions.objAbbrev(element)
    output.write('/**\n')
    output.write(' * write comments\n')
    output.write(' */\n')
    if attrib['type'] != 'element' and attrib['type'] != 'lo_element':
        output.write('LIBSEDML_EXTERN\n')
        output.write('int\n')
        output.write('{0}_set{1}'.format(element, capAttName))
        output.write('({0}_t * {1},'.format(element, varname))
        output.write(' {0} {1})\n'.format(attTypeCode, attName))
        output.write('{\n')
        output.write(
            '\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSEDML_INVALID_OBJECT;\n'
            .format(varname, capAttName, attName))
        output.write('}\n\n\n')
    elif attrib['type'] == 'element':
        if attrib['name'] == 'Math' or attrib['name'] == 'math':
            output.write('LIBSEDML_EXTERN\n')
            output.write('int\n')
            output.write('{0}_set{1}'.format(element, capAttName))
            output.write('({0}_t * {1},'.format(element, varname))
            output.write(' {0} {1})\n'.format('ASTNode_t*', attName))
            output.write('{\n')
            output.write(
                '\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSEDML_INVALID_OBJECT;\n'
                .format(varname, capAttName, attName))
            output.write('}\n\n\n')
        else:
            output.write('LIBSEDML_EXTERN\n')
            output.write('int\n')
            output.write('{0}_set{1}'.format(element, capAttName))
            output.write('({0}_t * {1},'.format(element, varname))
            output.write(' {0}_t* {1})\n'.format(attrib['element'], attName))
            output.write('{\n')
            output.write(
                '\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSEDML_INVALID_OBJECT;\n'
                .format(varname, capAttName, attName))
            output.write('}\n\n\n')
コード例 #29
0
ファイル: writeCCode.py プロジェクト: nrnb/gsoc2016hovakim
def writeUnsetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element' or attrib['type'] == 'element':
    return
  varname = strFunctions.objAbbrev(element)
  output.write('LIBSBML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_unset{1}'.format(element, capAttName))
  output.write('({0}_t * {1})\n'.format(element, varname))
  output.write('{\n')
  output.write('  return ({0} != NULL) ? {0}->unset{1}() : LIBSBML_INVALID_OBJECT;\n'.format(varname, capAttName))
  output.write('}\n\n\n')
コード例 #30
0
ファイル: writeCCode.py プロジェクト: nrnb/gsoc2016hovakim
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  varname = strFunctions.objAbbrev(element)
  output.write('LIBSBML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_isSet{1}'.format(element, capAttName))
  output.write('(const {0}_t * {1})\n'.format(element, varname))
  output.write('{\n')
  output.write('  return ({0} != NULL) ? static_cast<int>({0}->isSet{1}()) : 0;\n'.format(varname, capAttName))
  output.write('}\n\n\n')
コード例 #31
0
ファイル: writeCCode.py プロジェクト: jeicher/libSEDML
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element':
    return
  varname = strFunctions.objAbbrev(element)
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  if attrib['type'] == 'std::vector<double>':
    return
  elif attrib['type'] != 'element' and attrib['type'] != 'lo_element':
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_set{1}'.format(element, capAttName))
    output.write('({0}_t * {1},'.format(element, varname))
    output.write(' {0} {1})\n'.format(attTypeCode, attName))
    output.write('{\n')
    output.write('\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSEDML_INVALID_OBJECT;\n'.format(varname, capAttName, attName))
    output.write('}\n\n\n')
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('LIBSEDML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, varname))
      output.write(' {0} {1})\n'.format('ASTNode_t*', attName))
      output.write('{\n')
      output.write('\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSEDML_INVALID_OBJECT;\n'.format(varname, capAttName, attName))
      output.write('}\n\n\n')
    else:
      output.write('LIBSEDML_EXTERN\n')
      output.write('int\n')
      output.write('{0}_set{1}'.format(element, capAttName))
      output.write('({0}_t * {1},'.format(element, varname))
      output.write(' {0}_t* {1})\n'.format(attrib['element'], attName))
      output.write('{\n')
      output.write('\treturn ({0} != NULL) ? {0}->set{1}({2}) : LIBSEDML_INVALID_OBJECT;\n'.format(varname, capAttName, attName))
      output.write('}\n\n\n')
コード例 #32
0
ファイル: writeCCode.py プロジェクト: hsorby/libSEDML
def writeConstructors(element, package, output):
  indent = strFunctions.getIndent(element)
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(element))
  output.write('{0}_create'.format(element))
  output.write('(unsigned int level, unsigned int version)\n')
  output.write('{\n')
  output.write('\treturn new {0}(level, version);\n'.format(element))
  output.write('}\n\n\n')
#  output.write('/**\n')
#  output.write(' * write comments\n')
#  output.write(' */\n')
#  output.write('LIBSEDML_EXTERN\n')
#  output.write('{0}_t *\n'.format(element))
#  output.write('{0}_createWithNS'.format(element))
#  output.write('(SedNamespaces_t *sedmlns)\n')
#  output.write('{\n')
#  output.write('\treturn new {0}(sedmlns);\n'.format(element))
#  output.write('}\n\n\n')
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('void\n')
  output.write('{0}_free'.format(element))
  output.write('({0}_t * {1})\n'.format(element, strFunctions.objAbbrev(element)))
  output.write('{\n')
  output.write('\tif ({0} != NULL)\n'.format(strFunctions.objAbbrev(element)))
  output.write('\t\tdelete {0};\n'.format(strFunctions.objAbbrev(element)))
  output.write('}\n\n\n')
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('{0}_t *\n'.format(element))
  output.write('{0}_clone'.format(element))
  output.write('({0}_t * {1})\n'.format(element, strFunctions.objAbbrev(element)))
  output.write('{\n')
  output.write('\tif ({0} != NULL)\n'.format(strFunctions.objAbbrev(element)))
  output.write('\t{\n')
  output.write('\t\treturn static_cast<{0}_t*>({1}->clone());\n'.format(element, strFunctions.objAbbrev(element)))
  output.write('\t}\n')
  output.write('\telse\n')
  output.write('\t{\n')
  output.write('\t\treturn NULL;\n')
  output.write('\t}\n')
  output.write('}\n\n\n')
コード例 #33
0
ファイル: writeListOfCode.py プロジェクト: hovo1990/deviser
def writeAddFunction(code, type, listOf, name):
  code.write('/**\n')
  code.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(type, listOf))
  code.write(' *\n')
  code.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(type), type))
  code.write(' *\n')
  code.write(' * @return integer value indicating success/failure of the\n')
  code.write(' * function.  @if clike The value is drawn from the\n')
  code.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  code.write(' * returned by this function are:\n')
  code.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
  code.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
  code.write(' */\n')
  code.write('int\n')
  code.write('{0}::add{1}(const {2}* {3})\n'.format(listOf, strFunctions.cap(name), type, strFunctions.objAbbrev(type)))
  code.write('{\n')

  code.write('  if ({0} == NULL)\n'.format(strFunctions.objAbbrev(type)))
  code.write('  {\n')
  code.write('    return LIBSBML_OPERATION_FAILED;\n')
  code.write('  }\n')
  code.write('  else if ({0}->hasRequiredAttributes() == false)\n'.format(strFunctions.objAbbrev(type)))
  code.write('  {\n')
  code.write('    return LIBSBML_INVALID_OBJECT;\n')
  code.write('  }\n')
  code.write('  else if (getLevel() != {0}->getLevel())\n'.format(strFunctions.objAbbrev(type)))
  code.write('  {\n')
  code.write('    return LIBSBML_LEVEL_MISMATCH;\n')
  code.write('  }\n')
  code.write('  else if (getVersion() != {0}->getVersion())\n'.format(strFunctions.objAbbrev(type)))
  code.write('  {\n')
  code.write('    return LIBSBML_VERSION_MISMATCH;\n')
  code.write('  }\n')
  code.write(
    '  else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>({0})) == false)\n'.format(
      strFunctions.objAbbrev(type)))
  code.write('  {\n')
  code.write('    return LIBSBML_NAMESPACES_MISMATCH;\n')
  code.write('  }\n')
  code.write('  else\n')
  code.write('  {\n')
  code.write('\tappend({0});\n'.format(strFunctions.objAbbrev(type)))
  code.write('    return LIBSBML_OPERATION_SUCCESS;\n')
  code.write('  }\n')
  code.write('}\n\n\n')
コード例 #34
0
ファイル: writeCCode.py プロジェクト: jeicher/libSEDML
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element':
    return
  if attrib['type'] == 'std::vector<double>':
    return
  varname = strFunctions.objAbbrev(element)
  output.write('/**\n')
  output.write(' * write comments\n')
  output.write(' */\n')
  output.write('LIBSEDML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_isSet{1}'.format(element, capAttName))
  output.write('({0}_t * {1})\n'.format(element, varname))
  output.write('{\n')
  output.write('\treturn ({0} != NULL) ? static_cast<int>({0}->isSet{1}()) : 0;\n'.format(varname, capAttName))
  output.write('}\n\n\n')
コード例 #35
0
def writeSetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib['type'] != 'element' and attrib[
            'type'] != 'lo_element' and attrib[
                'type'] != 'XMLNode*' and attrib['type'] != 'inline_lo_element':
        output.write('/**\n')
        output.write(
            ' * Sets the \"{0}\" attribute of the given {1}_t structure.\n *\n'
            .format(attName, element))
        if (attType == 'string'):
            output.write(
                ' * This function copies the string given in @p string.  If the string is\n'
            )
            output.write(
                ' * a null pointer, this function performs {0}_unset{1}() instead.\n *\n'
                .format(element, capAttName))
        output.write(' * @param {0} the {1}_t structure.\n *\n'.format(
            strFunctions.objAbbrev(element), element))
        output.write(
            ' * @param {0} the string to which the structures \"{1}\" attribute should be\n'
            .format(strFunctions.cleanStr(attName), attName))
        output.write(' * set.\n *\n')
        output.write(
            ' * @return integer value indicating success/failure of the\n')
        output.write(' * function.  @if clike The value is drawn from the\n')
        output.write(
            ' * enumeration #OperationReturnValues_t. @endif@~ The possible values\n'
        )
        output.write(' * returned by this function are:\n')
        output.write(
            ' * @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink\n'
        )
        output.write(
            ' * @li @link OperationReturnValues_t#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE@endlink\n'
        )
        output.write(
            ' * @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink\n *\n'
        )
        if (attType == 'string'):
            output.write(
                ' * @note Using this function with a null pointer for @p name is equivalent to\n'
            )
            output.write(
                ' * unsetting the value of the "name" attribute.\n * \n')
        output.write(' * @member of {0}_t\n'.format(element))
        output.write(' */\n')
        output.write('LIBSBML_EXTERN\n')
        output.write('int\n')
        output.write('{0}_set{1}'.format(element, capAttName))
        output.write('({0}_t * {1},'.format(element,
                                            strFunctions.objAbbrev(element)))
        output.write(' {0} {1});\n\n\n'.format(attTypeCode,
                                               strFunctions.cleanStr(attName)))
    elif attrib['type'] == 'XMLNode*':
        output.write('LIBSBML_EXTERN\n')
        output.write('int\n')
        output.write('{0}_set{1}'.format(element, capAttName))
        output.write('({0}_t * {1},'.format(element,
                                            strFunctions.objAbbrev(element)))
        output.write(' XMLNode_t* {0});\n\n\n'.format(
            strFunctions.cleanStr(attName)))
    elif attrib['type'] == 'element':
        if attrib['name'] == 'Math' or attrib['name'] == 'math':
            output.write('/**\n')
            output.write(
                ' * Sets the mathematical expression of the given {0}_t structure.\n *\n'
                .format(element))
            output.write(' * @param {0} the {1}_t structure.\n *\n'.format(
                strFunctions.objAbbrev(element), element))
            output.write(
                ' * @param math an ASTNode_t structure to be assigned as the \"math\"\n'
            )
            output.write(' * subelement of this {0}_t.\n *\n'.format(element))
            output.write(
                ' * @return integer value indicating success/failure of the\n')
            output.write(
                ' * function.  @if clike The value is drawn from the\n')
            output.write(
                ' * enumeration #OperationReturnValues_t. @endif@~ The possible values\n'
            )
            output.write(' * returned by this function are:\n')
            output.write(
                ' * @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink\n'
            )
            output.write(
                ' * @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink\n *\n'
            )
            output.write(' * @member of {0}_t\n'.format(element))
            output.write(' */\n')
            output.write('LIBSBML_EXTERN\n')
            output.write('int\n')
            output.write('{0}_setMath'.format(element))
            output.write('({0}_t * {1},'.format(
                element, strFunctions.objAbbrev(element)))
            output.write(' const ASTNode_t* {0});\n\n\n'.format(
                strFunctions.cleanStr(attName)))
        else:
            output.write('LIBSBML_EXTERN\n')
            output.write('int\n')
            output.write('{0}_set{1}'.format(element, capAttName))
            output.write('({0}_t * {1},'.format(
                element, strFunctions.objAbbrev(element)))
            output.write(' {0}_t* {1});\n\n\n'.format(
                attrib['element'], strFunctions.cleanStr(attName)))
コード例 #36
0
def writeListOfSubFunctions(attrib, output, element, pkgName):
  lotype = generalFunctions.getListOfClassName(attrib, strFunctions.cap(attrib['element']))
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(lotype))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('const {0}*\n'.format(lotype))
  output.write('{0}::get{1}() const\n'.format(element, loname))
  output.write('{\n')
  output.write('  return &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(lotype))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('{0}*\n'.format(lotype))
  output.write('{0}::get{1}()\n'.format(element, loname))
  output.write('{\n')
  output.write('  return &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  writeListOfCode.writeRemoveFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName, attrib)
  writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName, attrib)
  output.write('/*\n')
  output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element']))
  output.write(' *\n')
  output.write(' * @return integer value indicating success/failure of the\n')
  output.write(' * function.  @if clike The value is drawn from the\n')
  output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  output.write(' * returned by this function are:\n')
  output.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
  output.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::add{1}(const {2}* {3})\n'.format(element, strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('{\n')
  output.write('  if ({0} == NULL)\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_OPERATION_FAILED;\n')
  output.write('  }\n')
  output.write('  else if ({0}->hasRequiredAttributes() == false)\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_INVALID_OBJECT;\n')
  output.write('  }\n')
  output.write('  else if (getLevel() != {0}->getLevel())\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_LEVEL_MISMATCH;\n')
  output.write('  }\n')
  output.write('  else if (getVersion() != {0}->getVersion())\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_VERSION_MISMATCH;\n')
  output.write('  }\n')
  if not element.endswith('Plugin'):
    output.write(
      '  else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>({0})) == false)\n'.format(
        strFunctions.objAbbrev(attrib['element'])))
    output.write('  {\n')
    output.write('    return LIBSBML_NAMESPACES_MISMATCH;\n')
    output.write('  }\n')
  output.write('  else\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    m{0}.append({1});\n'.format(strFunctions.capp(attrib['name']),strFunctions.objAbbrev(attrib['element'])))
  output.write('    return LIBSBML_OPERATION_SUCCESS;\n')
  output.write('  }\n')
  output.write('}\n\n\n')
  output.write('/*\n')
  output.write(' * Get the number of {0} objects in this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @return the number of {0} objects in this {1}\n'.format(attrib['element'], element))
  output.write(' */\n')
  output.write('unsigned int\n')
  output.write('{0}::getNum{1}() const\n'.format(element, strFunctions.capp(attrib['name'])))
  output.write('{\n')
  output.write('  return m{0}.size();\n'.format(strFunctions.capp(attrib['name'])))
  output.write('}\n\n\n')
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
      output.write('/*\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(attrib['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(element, attrib['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(attrib['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {0}* {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write(' */\n')
      output.write('{0}*\n'.format(attrib['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(attrib['name'])))
      output.write('{\n')
      output.write('  {0}* {1} = NULL;\n\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write('  try\n')
      output.write('  {\n')
      output.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      output.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element'], pkgName.lower()))
      output.write('    delete {0}ns;\n'.format(pkgName.lower()))
      output.write('  }\n')
      output.write('  catch (...)\n')
      output.write('  {\n')
      output.write('    /* here we do not create a default object as the level/version must\n')
      output.write('     * match the parent object\n')
      output.write('     *\n')
      output.write('     * do nothing\n')
      output.write('     */\n')
      output.write('  }\n\n')
      output.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(attrib['element'])))
      output.write('  {\n')
      output.write('    m{0}.appendAndOwn({1});\n'.format(strFunctions.capp(attrib['name']), strFunctions.objAbbrev(attrib['element'])))
      output.write('  }\n\n')
      output.write('  return {0};\n'.format(strFunctions.objAbbrev(attrib['element'])))
      output.write('}\n\n\n')
  elif attrib.has_key('concrete'):
    for elem in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
      output.write('/**\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(elem['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(lotype, elem['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(elem['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {0}*)\n'.format(strFunctions.cap(attrib['element'])))
      output.write(' */\n')
      output.write('{0}* \n'.format(elem['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(elem['name'])))
      output.write('{\n')
      output.write('  {0}* {1} = NULL;\n\n'.format(elem['element'], strFunctions.objAbbrev(elem['element'])))
      output.write('  try\n')
      output.write('  {\n')
      output.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      output.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(elem['element']), elem['element'], pkgName.lower()))
      output.write('    delete {0}ns;\n'.format(pkgName.lower()))
      output.write('  }\n')
      output.write('  catch (...)\n')
      output.write('  {\n')
      output.write('    /* here we do not create a default object as the level/version must\n')
      output.write('     * match the parent object\n')
      output.write('     *\n')
      output.write('     * do nothing\n')
      output.write('     */\n')
      output.write('  }\n\n')
      output.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(elem['element'])))
      output.write('  {\n')
      output.write('    m{0}.appendAndOwn({1});\n'.format(strFunctions.capp(attrib['name']), strFunctions.objAbbrev(elem['element'])))
      output.write('  }\n\n')
      output.write('  return {0};\n'.format(strFunctions.objAbbrev(elem['element'])))
      output.write('}\n\n\n')
コード例 #37
0
ファイル: writeCCode.py プロジェクト: nrnb/gsoc2016hovakim
def writeGetFunction(attrib, output, element):
  att = generalFunctions.parseAttributeForC(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if att[3] == 'const char *':
    attTypeCode = 'const char *'
  else:
    attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  if attrib['type'] == 'array':
    return
  varname = strFunctions.objAbbrev(element)
  if attrib['type'] == 'std::vector<double>':
    return
  elif attrib['type'] != 'element' and attrib['type'] != 'lo_element' and attrib['type'] != 'inline_lo_element' and attrib['type'] != 'XMLNode*':
    output.write('LIBSBML_EXTERN\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}_get{1}'.format(element, capAttName))
    output.write('(const {0}_t * {1})\n'.format(element, varname))
    output.write('{\n')
    if attType == 'string':
      output.write('\treturn ({0} != NULL && {0}->isSet{1}()) ? {0}->get{1}().c_str() : NULL;\n'.format(varname, capAttName))
#      output.write('\tif ({0} == NULL)\n'.format(varname))
#      output.write('\t\treturn NULL;\n\n')
#      output.write('\treturn {0}->get{1}().empty() ? NULL : safe_strdup({0}->get{1}().c_str());\n'.format(varname, capAttName))
    elif attType == 'boolean':
      output.write('\treturn ({0} != NULL) ? static_cast<int>({0}->get{1}()) : 0;\n'.format(varname, capAttName))
    elif num == True:
      if attTypeCode == 'double':
        output.write('\treturn ({0} != NULL) ? {0}->get{1}() : numeric_limits<double>::quiet_NaN();\n'.format(varname, capAttName))
      else:
        output.write('\treturn ({0} != NULL) ? {0}->get{1}() : SBML_INT_MAX;\n'.format(varname, capAttName))
    elif attrib['type'] == 'array':
      output.write('\treturn ({0} != NULL) ? {0}->get{1}() : NULL;\n'.format(varname, capAttName))
    elif attrib['type'] == 'enum':
      output.write('\treturn ({0} != NULL) ? {0}->get{1}() : {2}_UNKNOWN;\n'.format(varname, capAttName, attrib['element'].upper()))
    output.write('}\n\n\n')
  elif attrib['type'] == 'XMLNode*':
      output.write('LIBSBML_EXTERN\n')
      output.write('XMLNode_t*\n')
      output.write('{0}_get{1}'.format(element, capAttName))
      output.write('({0}_t * {1})\n'.format(element, varname))
      output.write('{\n')
      output.write('\tif ({0} == NULL)\n'.format(varname))
      output.write('\t\treturn NULL;\n\n')
      output.write('\treturn ({0}_t*){1}->get{2}();\n'.format('XMLNode',varname, capAttName))
      output.write('}\n\n\n')
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('LIBSBML_EXTERN\n')
      output.write('const ASTNode_t*\n')
      output.write('{0}_get{1}'.format(element, capAttName))
      output.write('(const {0}_t * {1})\n'.format(element, varname))
      output.write('{\n')
      output.write('\tif ({0} == NULL)\n'.format(varname))
      output.write('\t\treturn NULL;\n\n')
      output.write('\treturn (ASTNode_t*)({0}->get{1}());\n'.format(varname, capAttName))
      output.write('}\n\n\n')
    else:
      output.write('LIBSBML_EXTERN\n')
      output.write('{0}_t*\n'.format(attrib['element']))
      output.write('{0}_get{1}'.format(element, capAttName))
      output.write('({0}_t * {1})\n'.format(element, varname))
      output.write('{\n')
      output.write('\tif ({0} == NULL)\n'.format(varname))
      output.write('\t\treturn NULL;\n\n')
      output.write('\treturn ({0}_t*){1}->get{2}();\n'.format(attrib['element'],varname, capAttName))
      output.write('}\n\n\n')

      if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
        output.write('LIBSBML_EXTERN\n')
        output.write('{0}_t*\n'.format(attrib['element']))
        output.write('{0}_create{1}'.format(element, capAttName))
        output.write('({0}_t * {1})\n'.format(element, varname))
        output.write('{\n')
        output.write('\tif ({0} == NULL)\n'.format(varname))
        output.write('\t\treturn NULL;\n\n')
        output.write('\treturn ({0}_t*){1}->create{2}();\n'.format(attrib['element'],varname, capAttName))
        output.write('}\n\n\n')
      elif attrib.has_key('concrete') and attrib.has_key('root'):
        for elem in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
         output.write('LIBSBML_EXTERN\n')
         output.write('{0}_t *\n'.format(elem['element']))
         output.write('{0}_create{1}({0}_t * {2})\n' .format(element, strFunctions.cap(elem['name']), strFunctions.objAbbrev(element)))
         output.write('{\n')
         output.write('\treturn  ({0} != NULL) ? {0}->create{1}() : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(elem['name'])))
         output.write('}\n\n')
コード例 #38
0
ファイル: writeCCode.py プロジェクト: nrnb/gsoc2016hovakim
def writeListOfSubElements(attrib, output, element):
  loname = generalFunctions.getListOfClassName(attrib,strFunctions.cap(attrib['element']))
  output.write('LIBSBML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_add{1}({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('{0}_t * {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? {0}->add{1}({2}) : LIBSBML_INVALID_OBJECT;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(attrib['name']),strFunctions.objAbbrev(attrib['element'])))
  output.write('}\n\n')
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
    output.write('LIBSBML_EXTERN\n')
    output.write('{0}_t *\n'.format(attrib['element']))
    output.write('{0}_create{1}({0}_t * {2})\n' .format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
    output.write('{\n')
    output.write('\treturn  ({0} != NULL) ? {0}->create{1}() : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(attrib['name'])))
    output.write('}\n\n')
  elif attrib.has_key('concrete') and attrib.has_key('root'):    
    for elem in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
     output.write('LIBSBML_EXTERN\n')
     output.write('{0}_t *\n'.format(elem['element']))
     output.write('{0}_create{1}({0}_t * {2})\n' .format(element, strFunctions.cap(elem['name']), strFunctions.objAbbrev(element)))
     output.write('{\n')
     output.write('\treturn  ({0} != NULL) ? {0}->create{1}() : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(elem['name'])))
     output.write('}\n\n')
  output.write('LIBSBML_EXTERN\n')
  output.write('ListOf_t *\n')
  output.write('{0}_get{1}({0}_t * {2})\n'.format(element, loname, strFunctions.objAbbrev(element)))
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? (ListOf_t *){0}->getListOf{1}() : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.capp(attrib['name'])))
  output.write('}\n\n')
  output.write('LIBSBML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_get{1}({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('unsigned int n)\n')
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? {0}->get{1}(n) : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(attrib['name'])))
  output.write('}\n\n')
  output.write('LIBSBML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_get{1}ById({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('const char * sid)\n')
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? {0}->get{1}(sid) : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(attrib['name'])))
  output.write('}\n\n')
  output.write('LIBSBML_EXTERN\n')
  output.write('unsigned int\n')
  output.write('{0}_getNum{1}({0}_t * {2})\n' .format(element, strFunctions.capp(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? {0}->getNum{1}() : SBML_INT_MAX;\n'.format(strFunctions.objAbbrev(element),strFunctions.capp(attrib['name'])))
  output.write('}\n\n')
  output.write('LIBSBML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_remove{1}({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('unsigned int n)\n')
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? {0}->remove{1}(n) : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(attrib['name'])))
  output.write('}\n\n')
  output.write('LIBSBML_EXTERN\n')
  output.write('{0}_t *\n'.format(attrib['element']))
  output.write('{0}_remove{1}ById({0}_t * {2}, '.format(element, strFunctions.cap(attrib['name']), strFunctions.objAbbrev(element)))
  output.write('const char * sid)\n')
  output.write('{\n')
  output.write('\treturn  ({0} != NULL) ? {0}->remove{1}(sid) : NULL;\n'.format(strFunctions.objAbbrev(element),strFunctions.cap(attrib['name'])))
  output.write('}\n\n')
コード例 #39
0
ファイル: writeListOfCode.py プロジェクト: 0u812/libSEDML
def createCode(element, code):
  type = element['name']
  name = element['name']
  if element.has_key('elementName'):
    name = strFunctions.cap(element['elementName']) 
  if element.has_key('element'):
    type = element['element']
  listOf = generalFunctions.writeListOf(name)
  writeConstructors(name, type, element['package'], code) 
  writeGetFunctions(code, name, type)
  code.write('/**\n')
  code.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(type, listOf))
  code.write(' *\n')
  code.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(type), type))
  code.write(' *\n')
  code.write(' * @return integer value indicating success/failure of the\n')
  code.write(' * function.  @if clike The value is drawn from the\n')
  code.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  code.write(' * returned by this function are:\n')
  code.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
  code.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  code.write(' */\n')
  code.write('int\n')
  code.write('{0}::add{1}(const {2}* {3})\n'.format(listOf, strFunctions.cap(name), type, strFunctions.objAbbrev(type)))
  code.write('{\n')
  code.write('  if({0} == NULL) return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n'.format(strFunctions.objAbbrev(type)))
  code.write('  append({0});\n'.format(strFunctions.objAbbrev(type)))
  code.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
  code.write('}\n\n\n')
  code.write('/**\n')
  code.write(' * Get the number of {0} objects in this {1}.\n'.format(type, listOf))
  code.write(' *\n')
  code.write(' * @return the number of {0} objects in this {1}\n'.format(type, listOf))
  code.write(' */\n')
  code.write('unsigned int\n')
  code.write('{0}::getNum{1}s() const\n'.format(listOf, strFunctions.cap(name)))
  code.write('{\n')
  code.write('  return size();\n')
  code.write('}\n\n')
  if element.has_key('abstract') == False or (element.has_key('abstract') and element['abstract'] == False):
    code.write('/**\n')
    code.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(type, listOf))
    code.write(' * {0} and returns the {1} object created.\n'.format(element['name'], type))
    code.write(' *\n')
    code.write(' * @return a new {0} object instance\n'.format(type))
    code.write(' *\n')
    code.write(' * @see add{0}(const {0}* {1})\n'.format(type, strFunctions.objAbbrev(type)))
    code.write(' */\n')
    code.write('{0}*\n'.format(type))
    code.write('{0}::create{1}()\n'.format(listOf, strFunctions.cap(name)))
    code.write('{\n')
    code.write('  {0} *temp = new {0}();\n'.format(type))
    code.write('  if (temp != NULL) appendAndOwn(temp);\n')
    code.write('  return temp;\n')
    code.write('}\n\n')
  elif element.has_key('concrete'):
    for elem in element['concrete']:
      code.write('/**\n')
      code.write(' * Creates a new {0} object, adds it to this {1}\n'.format(elem['element'], listOf))
      code.write(' * {0} and returns the {1} object created.\n'.format(elem['name'], elem['element']))
      code.write(' *\n')
      code.write(' * @return a new {0} object instance\n'.format(elem['element']))
      code.write(' *\n')
      code.write(' * @see add{0}(const {1}* {2})\n'.format(strFunctions.cap(elem['name']), type, strFunctions.objAbbrev(type)))
      code.write(' */\n')
      code.write('{0}*\n'.format(elem['element']))
      code.write('{0}::create{1}()\n'.format(listOf, strFunctions.cap(elem['name'])))
      code.write('{\n')
      code.write('  {0} *temp = new {0}();\n'.format(elem['element']))
      code.write('  if (temp != NULL) appendAndOwn(temp);\n')
      code.write('  return temp;\n')
      code.write('}\n\n')
  writeRemoveFunctions(code, name, type)
  generalFunctions.writeCommonCPPCode(code, element['name'], element['typecode'],None,  True, False,False, element)
  elementName = element['name']
  if element.has_key('elementName'):
    elementName = element['elementName']
  writeProtectedFunctions(code, element['name'], element['package'], elementName, element)

  
コード例 #40
0
ファイル: writeListOfCode.py プロジェクト: hovo1990/deviser
def writeCreateObject(code, element, listOf, type, name, pkgName):
  if element.has_key('abstract') == False or (element.has_key('abstract') and element['abstract'] == False):
    code.write('/**\n')
    code.write(' * Creates a new {0} object, adds it to this {1}\n'.format(type, listOf))
    code.write(' * {0} and returns the {1} object created. \n'.format(element['name'], type))
    code.write(' *\n')
    code.write(' * @return a new {0} object instance\n'.format(type))
    code.write(' *\n')
    code.write(' * @see add{0}(const {0}* {1})\n'.format(type, strFunctions.objAbbrev(type)))
    code.write(' */\n')
    code.write('{0}* \n'.format(type))
    code.write('{0}::create{1}()\n'.format(listOf, strFunctions.cap(name)))
    code.write('{\n')

    code.write('  {0}* {1} = NULL;\n\n'.format(type, strFunctions.objAbbrev(type)))
    code.write('  try\n')
    code.write('  {\n')
    code.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
    code.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(type), type, pkgName.lower()))
    code.write('    delete {0}ns;\n'.format(pkgName.lower()))
    code.write('  }\n')
    code.write('  catch (...)\n')
    code.write('  {\n')
    code.write('    /* here we do not create a default object as the level/version must\n')
    code.write('     * match the parent object\n')
    code.write('     *\n')
    code.write('     * do nothing\n')
    code.write('     */\n')
    code.write('  }\n\n')
    code.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(type)))
    code.write('  {\n')
    code.write('    appendAndOwn({0});\n'.format(strFunctions.objAbbrev(type)))
    code.write('  }\n\n')
    code.write('  return {0};\n'.format(strFunctions.objAbbrev(type)))
    code.write('}\n\n')
  elif element.has_key('concrete'):
    for elem in generalFunctions.getConcretes(element['root'], element['concrete']):
      code.write('/**\n')
      code.write(' * Creates a new {0} object, adds it to this {1}\n'.format(elem['element'], listOf))
      code.write(' * {0} and returns the {1} object created. \n'.format(elem['name'], elem['element']))
      code.write(' *\n')
      code.write(' * @return a new {0} object instance\n'.format(elem['element']))
      code.write(' *\n')
      code.write(' * @see add{0}(const {1}* {2})\n'.format(strFunctions.cap(elem['name']), type, strFunctions.objAbbrev(type)))
      code.write(' */\n')
      code.write('{0}* \n'.format(elem['element']))
      code.write('{0}::create{1}()\n'.format(listOf, strFunctions.cap(elem['name'])))
      code.write('{\n')

      code.write('  {0}* {1} = NULL;\n\n'.format(elem['element'], strFunctions.objAbbrev(elem['element'])))
      code.write('  try\n')
      code.write('  {\n')
      code.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      code.write(
            '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(elem['element']), elem['element'], pkgName.lower()))
      code.write('    delete {0}ns;\n'.format(pkgName.lower()))
      code.write('  }\n')
      code.write('  catch (...)\n')
      code.write('  {\n')
      code.write('    /* here we do not create a default object as the level/version must\n')
      code.write('     * match the parent object\n')
      code.write('     *\n')
      code.write('     * do nothing\n')
      code.write('     */\n')
      code.write('  }\n\n')
      code.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(elem['element'])))
      code.write('  {\n')
      code.write('    appendAndOwn({0});\n'.format(strFunctions.objAbbrev(elem['element'])))
      code.write('  }\n\n')
      code.write('  return {0};\n'.format(strFunctions.objAbbrev(elem['element'])))
      code.write('}\n\n')
コード例 #41
0
ファイル: writeCode.py プロジェクト: jeicher/libSEDML
def writeListOfSubFunctions(attrib, output, element):
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(loname))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('const {0}*\n'.format(loname))
  output.write('{0}::getListOf{1}s() const\n'.format(element, strFunctions.cap(attrib['name'])))
  output.write('{\n')
  output.write('\treturn &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  writeListOfCode.writeRemoveFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName)
  writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName)
  output.write('/**\n')
  output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element']))
  output.write(' *\n')
  output.write(' * @return integer value indicating success/failure of the\n')
  output.write(' * function.  @if clike The value is drawn from the\n')
  output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  output.write(' * returned by this function are:\n')
  output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
  output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::add{1}(const {2}* {3})\n'.format(element, strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('{\n')
  output.write('\tif({0} == NULL) return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('\tm{0}.append({1});\n'.format(strFunctions.capp(attrib['name']),strFunctions.objAbbrev(attrib['element'])))
  output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
  output.write('}\n\n\n')
  output.write('/**\n')
  output.write(' * Get the number of {0} objects in this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @return the number of {0} objects in this {1}\n'.format(attrib['element'], element))
  output.write(' */\n')
  output.write('unsigned int \n')
  output.write('{0}::getNum{1}s() const\n'.format(element, strFunctions.cap(attrib['name'])))
  output.write('{\n')
  output.write('\treturn m{0}.size();\n'.format(strFunctions.capp(attrib['name'])))
  output.write('}\n\n')
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
    output.write('/**\n')
    output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(attrib['element'], element))
    output.write(' * {0} and returns the {1} object created. \n'.format(element, attrib['element']))
    output.write(' *\n')
    output.write(' * @return a new {0} object instance\n'.format(attrib['element']))
    output.write(' *\n')
    output.write(' * @see add{0}(const {0}* {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
    output.write(' */\n')
    output.write('{0}* \n'.format(attrib['element']))
    output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(attrib['name'])))
    output.write('{\n')
    output.write('\t{0} *temp = new {0}();\n'.format(attrib['element']))
    output.write('\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(strFunctions.capp(attrib['name'])))
    output.write('\treturn temp;\n')
    output.write('}\n\n')
  elif attrib.has_key('concrete'):
    for elem in attrib['concrete']:
      output.write('/**\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(elem['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(element, elem['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(elem['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {1}* {2})\n'.format(strFunctions.cap(elem['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write(' */\n')
      output.write('{0}* \n'.format(elem['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(elem['name'])))
      output.write('{\n')
      output.write('\t{0} *temp = new {0}();\n'.format(elem['element']))
      output.write('\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(strFunctions.capp(attrib['name'])))
      output.write('\treturn temp;\n')
      output.write('}\n\n')
コード例 #42
0
ファイル: writeCHeader.py プロジェクト: 0u812/libSEDML
def writeHasReqdElementsFunction(output, element):
  output.write('LIBSEDML_EXTERN\n')
  output.write('int\n')
  output.write('{0}_hasRequiredElements'.format(element))
  output.write('({0}_t * {1});\n\n\n'.format(element, strFunctions.objAbbrev(element)))
コード例 #43
0
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage,
               elementDict):
    listOf = generalFunctions.getListOfClassName(elementDict, typeOfElement)

    header.write('class LIBSBML_EXTERN {0} :'.format(listOf))
    header.write(' public ListOf\n{0}\n\n'.format('{'))
    header.write('public:\n\n')
    writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header,
                      elementDict)
    writeGetFunctions(header, nameOfElement, typeOfElement, False, "",
                      elementDict)
    header.write('\t/**\n')
    header.write('\t * Adds a copy the given \"{0}\" to this {1}.\n'.format(
        nameOfElement, listOf))
    header.write('\t *\n')
    header.write('\t * @param {0}; the {1} object to add\n'.format(
        strFunctions.objAbbrev(nameOfElement), nameOfElement))
    header.write('\t *\n')
    header.write(
        '\t * @return integer value indicating success/failure of the\n')
    header.write('\t * function.  @if clike The value is drawn from the\n')
    header.write(
        '\t * enumeration #OperationReturnValues_t. @endif The possible values\n'
    )
    header.write('\t * returned by this function are:\n')
    header.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
    header.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    header.write('\t */\n')
    header.write('\tint add{0}(const {1}* {2});\n\n\n'.format(
        nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
    header.write('\t/**\n')
    header.write('\t * Get the number of {0} objects in this {1}.\n'.format(
        nameOfElement, listOf))
    header.write('\t *\n')
    header.write('\t * @return the number of {0} objects in this {1}\n'.format(
        nameOfElement, listOf))
    header.write('\t */\n')
    header.write('\tunsigned int getNum{0}() const;\n\n\n'.format(
        strFunctions.capp(nameOfElement)))
    if elementDict.has_key('abstract') == False or (
            elementDict.has_key('abstract')
            and elementDict['abstract'] == False):
        header.write('\t/**\n')
        header.write('\t * Creates a new {0} object, adds it to the\n'.format(
            nameOfElement))
        header.write('\t * {0} and returns the {1} object created. \n'.format(
            listOf, nameOfElement))
        header.write('\t *\n')
        header.write(
            '\t * @return a new {0} object instance\n'.format(nameOfElement))
        header.write('\t *\n')
        header.write('\t * @see add{0}(const {1}* {2})\n'.format(
            nameOfElement, typeOfElement,
            strFunctions.objAbbrev(nameOfElement)))
        header.write('\t */\n')
        header.write('\t{0}* create{1}();\n\n\n'.format(
            typeOfElement, nameOfElement))
    elif elementDict.has_key('concrete'):
        for elem in generalFunctions.getConcretes(elementDict['root'],
                                                  elementDict['concrete']):
            header.write('\t/**\n')
            header.write(
                '\t * Creates a new {0} object, adds it to the\n'.format(
                    nameOfElement))
            header.write(
                '\t * {0} and returns the {1} object created. \n'.format(
                    listOf, nameOfElement))
            header.write('\t *\n')
            header.write('\t * @return a new {0} object instance\n'.format(
                nameOfElement))
            header.write('\t *\n')
            header.write('\t * @see add{0}(const {1}* {2})\n'.format(
                nameOfElement, typeOfElement,
                strFunctions.objAbbrev(nameOfElement)))
            header.write('\t */\n')
            header.write('\t{0}* create{1}();\n\n\n'.format(
                elem['element'], strFunctions.cap(elem['name'])))

    writeRemoveFunctions(header, nameOfElement, typeOfElement, False, "",
                         elementDict)
    generalFunctions.writeCommonHeaders(header, typeOfElement, None, True,
                                        False, False, elementDict)
    header.write('protected:\n\n')
    writeProtectedFunctions(header, nameOfElement, nameOfPackage, elementDict)

    if elementDict.has_key('concrete'):
        header.write('\tvirtual bool isValidTypeForList(SBase * item) {\n')
        header.write('\t\tint code = item->getTypeCode();\n')
        header.write('\t\treturn code == getItemTypeCode() ')
        for elem in generalFunctions.getConcretes(elementDict['root'],
                                                  elementDict['concrete']):
            typecode = 'SBML_{0}_{1}'.format(nameOfPackage.upper(),
                                             elem['element'].upper())
            if elem.has_key('root'):
                concrete = generalFunctions.getElement(elem['root'],
                                                       elem['element'])
                if (concrete != None):
                    typecode = concrete['typecode']
            header.write('|| code == {0} '.format(typecode))
        header.write(';\n')
        header.write('\t}\n\n\n')

    friends = getInlineListOfClasses(elementDict, typeOfElement)
    for friend in friends:
        header.write('\tfriend class {0};\n'.format(friend))

    header.write('\n};\n\n')
コード例 #44
0
def writeSetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if (
        attrib["type"] != "element"
        and attrib["type"] != "lo_element"
        and attrib["type"] != "XMLNode*"
        and attrib["type"] != "inline_lo_element"
    ):
        output.write("/**\n")
        output.write(' * Sets the "{0}" attribute of the given {1}_t structure.\n *\n'.format(attName, element))
        if attType == "string":
            output.write(" * This function copies the string given in @p string.  If the string is\n")
            output.write(
                " * a null pointer, this function performs {0}_unset{1}() instead.\n *\n".format(element, capAttName)
            )
        output.write(" * @param {0} the {1}_t structure.\n *\n".format(strFunctions.objAbbrev(element), element))
        output.write(
            ' * @param {0} the string to which the structures "{1}" attribute should be\n'.format(
                strFunctions.cleanStr(attName), attName
            )
        )
        output.write(" * set.\n *\n")
        output.write(" * @return integer value indicating success/failure of the\n")
        output.write(" * function.  @if clike The value is drawn from the\n")
        output.write(" * enumeration #OperationReturnValues_t. @endif@~ The possible values\n")
        output.write(" * returned by this function are:\n")
        output.write(
            " * @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink\n"
        )
        output.write(
            " * @li @link OperationReturnValues_t#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE@endlink\n"
        )
        output.write(" * @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink\n *\n")
        if attType == "string":
            output.write(" * @note Using this function with a null pointer for @p name is equivalent to\n")
            output.write(' * unsetting the value of the "name" attribute.\n * \n')
        output.write(" * @member of {0}_t\n".format(element))
        output.write(" */\n")
        output.write("LIBSBML_EXTERN\n")
        output.write("int\n")
        output.write("{0}_set{1}".format(element, capAttName))
        output.write("({0}_t * {1},".format(element, strFunctions.objAbbrev(element)))
        output.write(" {0} {1});\n\n\n".format(attTypeCode, strFunctions.cleanStr(attName)))
    elif attrib["type"] == "XMLNode*":
        output.write("LIBSBML_EXTERN\n")
        output.write("int\n")
        output.write("{0}_set{1}".format(element, capAttName))
        output.write("({0}_t * {1},".format(element, strFunctions.objAbbrev(element)))
        output.write(" XMLNode_t* {0});\n\n\n".format(strFunctions.cleanStr(attName)))
    elif attrib["type"] == "element":
        if attrib["name"] == "Math" or attrib["name"] == "math":
            output.write("/**\n")
            output.write(" * Sets the mathematical expression of the given {0}_t structure.\n *\n".format(element))
            output.write(" * @param {0} the {1}_t structure.\n *\n".format(strFunctions.objAbbrev(element), element))
            output.write(' * @param math an ASTNode_t structure to be assigned as the "math"\n')
            output.write(" * subelement of this {0}_t.\n *\n".format(element))
            output.write(" * @return integer value indicating success/failure of the\n")
            output.write(" * function.  @if clike The value is drawn from the\n")
            output.write(" * enumeration #OperationReturnValues_t. @endif@~ The possible values\n")
            output.write(" * returned by this function are:\n")
            output.write(
                " * @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink\n"
            )
            output.write(
                " * @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink\n *\n"
            )
            output.write(" * @member of {0}_t\n".format(element))
            output.write(" */\n")
            output.write("LIBSBML_EXTERN\n")
            output.write("int\n")
            output.write("{0}_setMath".format(element))
            output.write("({0}_t * {1},".format(element, strFunctions.objAbbrev(element)))
            output.write(" const ASTNode_t* {0});\n\n\n".format(strFunctions.cleanStr(attName)))
        else:
            output.write("LIBSBML_EXTERN\n")
            output.write("int\n")
            output.write("{0}_set{1}".format(element, capAttName))
            output.write("({0}_t * {1},".format(element, strFunctions.objAbbrev(element)))
            output.write(" {0}_t* {1});\n\n\n".format(attrib["element"], strFunctions.cleanStr(attName)))
コード例 #45
0
ファイル: writeListOfHeader.py プロジェクト: hovo1990/deviser
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict):
  listOf = generalFunctions.getListOfClassName(elementDict, typeOfElement)

  header.write('class LIBSBML_EXTERN {0} :'.format(listOf))
  header.write(' public ListOf\n{0}\n\n'.format('{'))
  header.write('public:\n\n')
  writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header,elementDict)
  writeGetFunctions(header, nameOfElement, typeOfElement, False, "", elementDict)
  header.write('\t/**\n')
  header.write('\t * Adds a copy the given \"{0}\" to this {1}.\n'.format(nameOfElement, listOf))
  header.write('\t *\n')
  header.write('\t * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(nameOfElement), nameOfElement))
  header.write('\t *\n')
  header.write('\t * @return integer value indicating success/failure of the\n')
  header.write('\t * function.  @if clike The value is drawn from the\n')
  header.write('\t * enumeration #OperationReturnValues_t. @endif The possible values\n')
  header.write('\t * returned by this function are:\n')
  header.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
  header.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  header.write('\t */\n')
  header.write('\tint add{0}(const {1}* {2});\n\n\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
  header.write('\t/**\n')
  header.write('\t * Get the number of {0} objects in this {1}.\n'.format(nameOfElement, listOf))
  header.write('\t *\n')
  header.write('\t * @return the number of {0} objects in this {1}\n'.format(nameOfElement, listOf))
  header.write('\t */\n')
  header.write('\tunsigned int getNum{0}() const;\n\n\n'.format(strFunctions.capp(nameOfElement)))
  if elementDict.has_key('abstract') == False or (elementDict.has_key('abstract') and elementDict['abstract'] == False):
    header.write('\t/**\n')
    header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement))
    header.write('\t * {0} and returns the {1} object created. \n'.format(listOf, nameOfElement))
    header.write('\t *\n')
    header.write('\t * @return a new {0} object instance\n'.format(nameOfElement))
    header.write('\t *\n')
    header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
    header.write('\t */\n')
    header.write('\t{0}* create{1}();\n\n\n'.format(typeOfElement, nameOfElement))
  elif elementDict.has_key('concrete'):
    for elem in generalFunctions.getConcretes(elementDict['root'], elementDict['concrete']):
      header.write('\t/**\n')
      header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement))
      header.write('\t * {0} and returns the {1} object created. \n'.format(listOf, nameOfElement))
      header.write('\t *\n')
      header.write('\t * @return a new {0} object instance\n'.format(nameOfElement))
      header.write('\t *\n')
      header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement)))
      header.write('\t */\n')
      header.write('\t{0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name'])))

  writeRemoveFunctions(header, nameOfElement, typeOfElement, False, "", elementDict)
  generalFunctions.writeCommonHeaders(header, typeOfElement, None, True, False, False, elementDict)
  header.write('protected:\n\n')
  writeProtectedFunctions(header, nameOfElement, nameOfPackage, elementDict)

  if elementDict.has_key('concrete'):
    header.write('\tvirtual bool isValidTypeForList(SBase * item) {\n')
    header.write('\t\tint code = item->getTypeCode();\n')
    header.write('\t\treturn code == getItemTypeCode() ')
    for elem in generalFunctions.getConcretes(elementDict['root'], elementDict['concrete']):
      typecode = 'SBML_{0}_{1}'.format(nameOfPackage.upper(),elem['element'].upper())
      if elem.has_key('root'):
        concrete = generalFunctions.getElement(elem['root'], elem['element'])
        if (concrete != None):
           typecode = concrete['typecode']
      header.write('|| code == {0} '.format(typecode))
    header.write(';\n')
    header.write('\t}\n\n\n');

  friends = getInlineListOfClasses(elementDict, typeOfElement)
  for friend in friends:
    header.write('\tfriend class {0};\n'.format(friend))

  header.write('\n};\n\n')
コード例 #46
0
def writeGetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    if att[3] == "const char *":
        attTypeCode = "const char *"
    else:
        attTypeCode = att[3]
    num = att[4]
    type = attrib["type"]
    if type != "element" and type != "lo_element" and type != "XMLNode*" and type != "inline_lo_element":
        output.write("/**\n")
        output.write(' * Returns the value of the "{0}" attribute of the given {1}_t\n'.format(attName, element))
        output.write(" * structure.\n *\n")
        output.write(" * @param {0} the {1}_t structure.\n *\n".format(strFunctions.objAbbrev(element), element))
        output.write(" * @return the {0} of this structure.\n *\n".format(attName))
        output.write(" * @member of {0}_t\n".format(element))
        output.write(" */\n")
        output.write("LIBSBML_EXTERN\n")
        output.write("{0}\n".format(attTypeCode))
        output.write("{0}_get{1}".format(element, capAttName))
        output.write("(const {0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
    elif type == "XMLNode*":
        output.write("LIBSBML_EXTERN\n")
        output.write("XMLNode_t*\n")
        output.write("{0}_get{1}".format(element, capAttName))
        output.write("({0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
    elif type == "element":
        if attrib["name"] == "Math" or attrib["name"] == "math":
            output.write("/**\n")
            output.write(" * Gets the mathematical expression of this {0}_t structure as an\n".format(element))
            output.write(" * ASTNode_t structure.\n *\n")
            output.write(" * @param {0} the {1}_t structure.\n *\n".format(strFunctions.objAbbrev(element), element))
            output.write(" * @return the math for this {0}_t, as an ASTNode_t.\n *\n".format(element))
            output.write(" * @member of {0}_t\n".format(element))
            output.write(" */\n")
            output.write("LIBSBML_EXTERN\n")
            output.write("const ASTNode_t*\n")
            output.write("{0}_getMath".format(element))
            output.write("(const {0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
        else:
            output.write("LIBSBML_EXTERN\n")
            output.write("{0}_t*\n".format(strFunctions.cap(attrib["element"])))
            output.write("{0}_get{1}".format(element, capAttName))
            output.write("({0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))

            if attrib.has_key("abstract") == False or (attrib.has_key("abstract") and attrib["abstract"] == False):
                output.write("LIBSBML_EXTERN\n")
                output.write("{0}_t*\n".format(strFunctions.cap(attrib["element"])))
                output.write("{0}_create{1}".format(element, capAttName))
                output.write("({0}_t * {1});\n\n\n".format(element, strFunctions.objAbbrev(element)))
            else:
                for elem in generalFunctions.getConcretes(attrib["root"], attrib["concrete"]):
                    output.write("LIBSBML_EXTERN\n")
                    output.write("{0}_t *\n".format(elem["element"]))
                    output.write(
                        "{0}_create{1}({0}_t * {2}".format(
                            element, strFunctions.cap(elem["name"]), strFunctions.objAbbrev(element)
                        )
                    )
                    output.write(");\n\n\n")
コード例 #47
0
def writeLOFunctions(fileOut, object, nameOfClass, pkg):
  ob = strFunctions.objAbbrev(object) 
  fileOut.write('/*\n')
  fileOut.write(' * Returns the ListOf{0}s in this plugin object.\n'.format(object))
  fileOut.write(' */\n')
  fileOut.write('const ListOf{0}s* \n'.format(object))
  fileOut.write('{0}::getListOf{1}s () const\n'.format(nameOfClass, object))
  fileOut.write('{\n')
  fileOut.write('  return &this->m{0}s;\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Returns the ListOf{0}s in this plugin object.\n'.format(object))
  fileOut.write(' */\n')
  fileOut.write('ListOf{0}s* \n'.format(object))
  fileOut.write('{0}::getListOf{1}s ()\n'.format(nameOfClass, object))
  fileOut.write('{\n')
  fileOut.write('  return &this->m{0}s;\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Returns the {0} object that belongs to the given index.\n'.format(object)) 
  fileOut.write(' */\n')
  fileOut.write('const {0}*\n'.format(object))
  fileOut.write('{0}::get{1}(unsigned int n) const\n'.format(nameOfClass, object))
  fileOut.write('{\n')
  fileOut.write('  return static_cast<const {0}*>(m{0}s.get(n));\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Returns the {0} object that belongs to the given index.\n'.format(object)) 
  fileOut.write(' */\n')
  fileOut.write('{0}*\n'.format(object))
  fileOut.write('{0}::get{1}(unsigned int n)\n'.format(nameOfClass, object))
  fileOut.write('{\n')
  fileOut.write('  return static_cast<{0}*>(m{0}s.get(n));\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Returns the {0} object based on its identifier.\n'.format(object)) 
  fileOut.write(' */\n')
  fileOut.write('const {0}*\n'.format(object))
  fileOut.write('{0}::get{1}(const std::string& sid) const\n'.format(nameOfClass, object))
  fileOut.write('{\n')
  fileOut.write('  return static_cast<const {0}*>(m{0}s.get(sid));\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Returns the {0} object based on its identifier.\n'.format(object)) 
  fileOut.write(' */\n')
  fileOut.write('{0}*\n'.format(object))
  fileOut.write('{0}::get{1}(const std::string& sid)\n'.format(nameOfClass, object))
  fileOut.write('{\n')
  fileOut.write('  return static_cast<{0}*>(m{0}s.get(sid));\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Adds a copy of the given {0} to the ListOf{0}s in this plugin object.\n'.format(object))
  fileOut.write(' */\n')
  fileOut.write('int\n')
  fileOut.write('{2}::add{0} (const {0}* {1})\n'.format(object, strFunctions.lowerFirst(object), nameOfClass))
  fileOut.write('{\n')
  fileOut.write('  if ({0} == NULL)\n'.format(strFunctions.lowerFirst(object)))
  fileOut.write('  {\n')
  fileOut.write('    return LIBSBML_OPERATION_FAILED;\n')
  fileOut.write('  }\n')
  fileOut.write('  else if ({0}->hasRequiredElements() == false)\n'.format(strFunctions.lowerFirst(object)))
  fileOut.write('  {\n')
  fileOut.write('    return LIBSBML_INVALID_OBJECT;\n')
  fileOut.write('  }\n')
  fileOut.write('  else if (getLevel() != {0}->getLevel())\n'.format(strFunctions.lowerFirst(object)))
  fileOut.write('  {\n')
  fileOut.write('    return LIBSBML_LEVEL_MISMATCH;\n')
  fileOut.write('  }\n')
  fileOut.write('  else if (getVersion() != {0}->getVersion())\n'.format(strFunctions.lowerFirst(object)))
  fileOut.write('  {\n')
  fileOut.write('    return LIBSBML_VERSION_MISMATCH;\n')
  fileOut.write('  }\n')
  fileOut.write('  else if (getPackageVersion() != {0}->getPackageVersion())\n'.format(strFunctions.lowerFirst(object)))
  fileOut.write('  {\n')
  fileOut.write('    return LIBSBML_PKG_VERSION_MISMATCH;\n')
  fileOut.write('  }\n')
  fileOut.write('  else\n')
  fileOut.write('  {\n')
  fileOut.write('    m{0}s.append({1});\n'.format(object, strFunctions.lowerFirst(object)))
  fileOut.write('  }\n\n')
  fileOut.write('  return LIBSBML_OPERATION_SUCCESS;\n\n')
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Creates a new {0} object and adds it to the ListOf{0}s in this plugin object.\n'.format(object))
  fileOut.write(' */\n')
  fileOut.write('{0}* \n'.format(object))
  fileOut.write('{1}::create{0} ()\n'.format(object, nameOfClass))
  fileOut.write('{\n')
  fileOut.write('   {0}* {1} = NULL;\n\n'.format(object, ob))
  fileOut.write('  try\n')
  fileOut.write('  {\n')
  fileOut.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkg.upper(), pkg.lower()))
  fileOut.write('    {0} = new {1}({2}ns);\n'.format(ob, object, pkg.lower()))
  fileOut.write('    delete {0}ns;\n'.format(pkg.lower()))
  fileOut.write('  }\n')
  fileOut.write('  catch(...)\n')
  fileOut.write('  {\n')
  fileOut.write('  }\n\n')
  fileOut.write('  if ({0} != NULL)\n'.format(ob))
  fileOut.write('  {\n')
  fileOut.write('    m{0}s.appendAndOwn({1});\n'.format(object, ob))
  fileOut.write('  }\n\n')
  fileOut.write('  return {0};\n'.format(ob))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Removes the nth {0} object from this plugin object\n'.format(object)) 
  fileOut.write(' */\n')
  fileOut.write('{0}* \n'.format(object))
  fileOut.write('{1}::remove{0}(unsigned int n)\n'.format(object, nameOfClass))
  fileOut.write('{\n')
  fileOut.write('  return static_cast<{0}*>(m{0}s.remove(n));\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Removes the {0} object with the given id from this plugin object\n'.format(object)) 
  fileOut.write(' */\n')
  fileOut.write('{0}* \n'.format(object))
  fileOut.write('{1}::remove{0}(const std::string& sid)\n'.format(object, nameOfClass))
  fileOut.write('{\n')
  fileOut.write('  return static_cast<{0}*>(m{0}s.remove(sid));\n'.format(object))
  fileOut.write('}\n\n\n')
  fileOut.write('/*\n')
  fileOut.write(' * Returns the number of {0} objects in this plugin object.\n'.format(object))
  fileOut.write(' */\n')
  fileOut.write('unsigned int \n')
  fileOut.write('{1}::getNum{0}s () const\n'.format(object, nameOfClass))
  fileOut.write('{\n')
  fileOut.write('  return m{0}s.size();\n'.format(object))
  fileOut.write('}\n\n\n')
コード例 #48
0
def writeListOfSubFunctions(attrib, output, element):
    loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    output.write('/*\n')
    output.write(' * Returns the  \"{0}\"'.format(loname))
    output.write(' in this {0} object.\n'.format(element))
    output.write(' */\n')
    output.write('const {0}*\n'.format(loname))
    output.write('{0}::getListOf{1}s() const\n'.format(
        element, strFunctions.cap(attrib['name'])))
    output.write('{\n')
    output.write('\treturn &m{0};\n'.format(capAttName))
    output.write('}\n\n\n')
    writeListOfCode.writeRemoveFunctions(output,
                                         strFunctions.cap(attrib['name']),
                                         attrib['element'], True, element,
                                         capAttName)
    writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']),
                                      attrib['element'], True, element,
                                      capAttName)
    output.write('/**\n')
    output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(
        attrib['element'], element))
    output.write(' *\n')
    output.write(' * @param {0}; the {1} object to add\n'.format(
        strFunctions.objAbbrev(attrib['element']), attrib['element']))
    output.write(' *\n')
    output.write(
        ' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(
        ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
    )
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::add{1}(const {2}* {3})\n'.format(
        element, strFunctions.cap(attrib['name']), attrib['element'],
        strFunctions.objAbbrev(attrib['element'])))
    output.write('{\n')
    output.write(
        '\tif({0} == NULL) return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n'.format(
            strFunctions.objAbbrev(attrib['element'])))
    output.write('\tm{0}.append({1});\n'.format(
        strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(attrib['element'])))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
    output.write('/**\n')
    output.write(' * Get the number of {0} objects in this {1}.\n'.format(
        attrib['element'], element))
    output.write(' *\n')
    output.write(' * @return the number of {0} objects in this {1}\n'.format(
        attrib['element'], element))
    output.write(' */\n')
    output.write('unsigned int \n')
    output.write('{0}::getNum{1}s() const\n'.format(
        element, strFunctions.cap(attrib['name'])))
    output.write('{\n')
    output.write('\treturn m{0}.size();\n'.format(
        strFunctions.cap(attrib['name'])))
    output.write('}\n\n')
    if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and
                                               attrib['abstract'] == False):
        output.write('/**\n')
        output.write(
            ' * Creates a new {0} object, adds it to this {1}s\n'.format(
                attrib['element'], element))
        output.write(' * {0} and returns the {1} object created. \n'.format(
            element, attrib['element']))
        output.write(' *\n')
        output.write(' * @return a new {0} object instance\n'.format(
            attrib['element']))
        output.write(' *\n')
        output.write(' * @see add{0}(const {0}* {1})\n'.format(
            attrib['element'], strFunctions.objAbbrev(attrib['element'])))
        output.write(' */\n')
        output.write('{0}* \n'.format(attrib['element']))
        output.write('{0}::create{1}()\n'.format(
            element, strFunctions.cap(attrib['name'])))
        output.write('{\n')
        output.write('\t{0} *temp = new {0}();\n'.format(attrib['element']))
        output.write('\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(
            strFunctions.cap(attrib['name'])))
        output.write('\treturn temp;\n')
        output.write('}\n\n')
    elif attrib.has_key('concrete'):
        for elem in attrib['concrete']:
            output.write('/**\n')
            output.write(
                ' * Creates a new {0} object, adds it to this {1}s\n'.format(
                    elem['element'], element))
            output.write(
                ' * {0} and returns the {1} object created. \n'.format(
                    element, elem['element']))
            output.write(' *\n')
            output.write(' * @return a new {0} object instance\n'.format(
                elem['element']))
            output.write(' *\n')
            output.write(' * @see add{0}(const {1}* {2})\n'.format(
                strFunctions.cap(elem['name']), attrib['element'],
                strFunctions.objAbbrev(attrib['element'])))
            output.write(' */\n')
            output.write('{0}* \n'.format(elem['element']))
            output.write('{0}::create{1}()\n'.format(
                element, strFunctions.cap(elem['name'])))
            output.write('{\n')
            output.write('\t{0} *temp = new {0}();\n'.format(elem['element']))
            output.write(
                '\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(
                    strFunctions.cap(attrib['name'])))
            output.write('\treturn temp;\n')
            output.write('}\n\n')
コード例 #49
0
def createCode(element, code):
    type = element['name']
    name = element['name']
    if element.has_key('elementName'):
        name = strFunctions.cap(element['elementName'])
    if element.has_key('element'):
        type = element['element']
    listOf = generalFunctions.writeListOf(name)
    writeConstructors(name, type, element['package'], code)
    writeGetFunctions(code, name, type)
    code.write('/**\n')
    code.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(
        type, listOf))
    code.write(' *\n')
    code.write(' * @param {0}; the {1} object to add\n'.format(
        strFunctions.objAbbrev(type), type))
    code.write(' *\n')
    code.write(' * @return integer value indicating success/failure of the\n')
    code.write(' * function.  @if clike The value is drawn from the\n')
    code.write(
        ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
    )
    code.write(' * returned by this function are:\n')
    code.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
    code.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    code.write(' */\n')
    code.write('int\n')
    code.write('{0}::add{1}(const {2}* {3})\n'.format(
        listOf, strFunctions.cap(name), type, strFunctions.objAbbrev(type)))
    code.write('{\n')
    code.write(
        '  if({0} == NULL) return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n'.format(
            strFunctions.objAbbrev(type)))
    code.write('  append({0});\n'.format(strFunctions.objAbbrev(type)))
    code.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
    code.write('}\n\n\n')
    code.write('/**\n')
    code.write(' * Get the number of {0} objects in this {1}.\n'.format(
        type, listOf))
    code.write(' *\n')
    code.write(' * @return the number of {0} objects in this {1}\n'.format(
        type, listOf))
    code.write(' */\n')
    code.write('unsigned int\n')
    code.write('{0}::getNum{1}s() const\n'.format(listOf,
                                                  strFunctions.cap(name)))
    code.write('{\n')
    code.write('  return size();\n')
    code.write('}\n\n')
    if element.has_key('abstract') == False or (element.has_key('abstract') and
                                                element['abstract'] == False):
        code.write('/**\n')
        code.write(
            ' * Creates a new {0} object, adds it to this {1}s\n'.format(
                type, listOf))
        code.write(' * {0} and returns the {1} object created.\n'.format(
            element['name'], type))
        code.write(' *\n')
        code.write(' * @return a new {0} object instance\n'.format(type))
        code.write(' *\n')
        code.write(' * @see add{0}(const {0}* {1})\n'.format(
            type, strFunctions.objAbbrev(type)))
        code.write(' */\n')
        code.write('{0}*\n'.format(type))
        code.write('{0}::create{1}()\n'.format(listOf, strFunctions.cap(name)))
        code.write('{\n')
        code.write('  {0} *temp = new {0}();\n'.format(type))
        code.write('  if (temp != NULL) appendAndOwn(temp);\n')
        code.write('  return temp;\n')
        code.write('}\n\n')
    elif element.has_key('concrete'):
        for elem in element['concrete']:
            code.write('/**\n')
            code.write(
                ' * Creates a new {0} object, adds it to this {1}\n'.format(
                    elem['element'], listOf))
            code.write(' * {0} and returns the {1} object created.\n'.format(
                elem['name'], elem['element']))
            code.write(' *\n')
            code.write(' * @return a new {0} object instance\n'.format(
                elem['element']))
            code.write(' *\n')
            code.write(' * @see add{0}(const {1}* {2})\n'.format(
                strFunctions.cap(elem['name']), type,
                strFunctions.objAbbrev(type)))
            code.write(' */\n')
            code.write('{0}*\n'.format(elem['element']))
            code.write('{0}::create{1}()\n'.format(
                listOf, strFunctions.cap(elem['name'])))
            code.write('{\n')
            code.write('  {0} *temp = new {0}();\n'.format(elem['element']))
            code.write('  if (temp != NULL) appendAndOwn(temp);\n')
            code.write('  return temp;\n')
            code.write('}\n\n')
    writeRemoveFunctions(code, name, type)
    generalFunctions.writeCommonCPPCode(code, element['name'],
                                        element['typecode'], None, True, False,
                                        False, element)
    elementName = element['name']
    if element.has_key('elementName'):
        elementName = element['elementName']
    writeProtectedFunctions(code, element['name'], element['package'],
                            elementName, element)
コード例 #50
0
def writeGetFunction(attrib, output, element):
    att = generalFunctions.parseAttributeForC(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    if att[3] == 'const char *':
        attTypeCode = 'const char *'
    else:
        attTypeCode = att[3]
    num = att[4]
    type = attrib['type']
    if type != 'element' and type != 'lo_element' and type != 'XMLNode*' and type != 'inline_lo_element':
        output.write('/**\n')
        output.write(
            ' * Returns the value of the \"{0}\" attribute of the given {1}_t\n'
            .format(attName, element))
        output.write(' * structure.\n *\n')
        output.write(' * @param {0} the {1}_t structure.\n *\n'.format(
            strFunctions.objAbbrev(element), element))
        output.write(
            ' * @return the {0} of this structure.\n *\n'.format(attName))
        output.write(' * @member of {0}_t\n'.format(element))
        output.write(' */\n')
        output.write('LIBSBML_EXTERN\n')
        output.write('{0}\n'.format(attTypeCode))
        output.write('{0}_get{1}'.format(element, capAttName))
        output.write('(const {0}_t * {1});\n\n\n'.format(
            element, strFunctions.objAbbrev(element)))
    elif type == 'XMLNode*':
        output.write('LIBSBML_EXTERN\n')
        output.write('XMLNode_t*\n')
        output.write('{0}_get{1}'.format(element, capAttName))
        output.write('({0}_t * {1});\n\n\n'.format(
            element, strFunctions.objAbbrev(element)))
    elif type == 'element':
        if attrib['name'] == 'Math' or attrib['name'] == 'math':
            output.write('/**\n')
            output.write(
                ' * Gets the mathematical expression of this {0}_t structure as an\n'
                .format(element))
            output.write(' * ASTNode_t structure.\n *\n')
            output.write(' * @param {0} the {1}_t structure.\n *\n'.format(
                strFunctions.objAbbrev(element), element))
            output.write(
                ' * @return the math for this {0}_t, as an ASTNode_t.\n *\n'.
                format(element))
            output.write(' * @member of {0}_t\n'.format(element))
            output.write(' */\n')
            output.write('LIBSBML_EXTERN\n')
            output.write('const ASTNode_t*\n')
            output.write('{0}_getMath'.format(element))
            output.write('(const {0}_t * {1});\n\n\n'.format(
                element, strFunctions.objAbbrev(element)))
        else:
            output.write('LIBSBML_EXTERN\n')
            output.write('{0}_t*\n'.format(strFunctions.cap(
                attrib['element'])))
            output.write('{0}_get{1}'.format(element, capAttName))
            output.write('({0}_t * {1});\n\n\n'.format(
                element, strFunctions.objAbbrev(element)))

            if attrib.has_key('abstract') == False or (
                    attrib.has_key('abstract')
                    and attrib['abstract'] == False):
                output.write('LIBSBML_EXTERN\n')
                output.write('{0}_t*\n'.format(
                    strFunctions.cap(attrib['element'])))
                output.write('{0}_create{1}'.format(element, capAttName))
                output.write('({0}_t * {1});\n\n\n'.format(
                    element, strFunctions.objAbbrev(element)))
            else:
                for elem in generalFunctions.getConcretes(
                        attrib['root'], attrib['concrete']):
                    output.write('LIBSBML_EXTERN\n')
                    output.write('{0}_t *\n'.format(elem['element']))
                    output.write('{0}_create{1}({0}_t * {2}'.format(
                        element, strFunctions.cap(elem['name']),
                        strFunctions.objAbbrev(element)))
                    output.write(');\n\n\n')
コード例 #51
0
def writeListOfSubElements(attrib, output, element):
    loname = generalFunctions.getListOfClassName(attrib, strFunctions.cap(attrib["element"]))
    output.write("LIBSBML_EXTERN\n")
    output.write("int\n")
    output.write(
        "{0}_add{1}({0}_t * {2}, ".format(element, strFunctions.cap(attrib["name"]), strFunctions.objAbbrev(element))
    )
    output.write("{0}_t * {1});\n\n\n".format(attrib["element"], strFunctions.objAbbrev(attrib["element"])))
    if attrib.has_key("abstract") == False or (attrib.has_key("abstract") and attrib["abstract"] == False):
        output.write("LIBSBML_EXTERN\n")
        output.write("{0}_t *\n".format(attrib["element"]))
        output.write(
            "{0}_create{1}({0}_t * {2}".format(
                element, strFunctions.cap(attrib["name"]), strFunctions.objAbbrev(element)
            )
        )
        output.write(");\n\n\n")
    elif attrib.has_key("concrete") and attrib.has_key("root"):
        for elem in generalFunctions.getConcretes(attrib["root"], attrib["concrete"]):
            output.write("LIBSBML_EXTERN\n")
            output.write("{0}_t *\n".format(elem["element"]))
            output.write(
                "{0}_create{1}({0}_t * {2}".format(
                    element, strFunctions.cap(elem["name"]), strFunctions.objAbbrev(element)
                )
            )
            output.write(");\n\n\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("ListOf_t *\n")
    output.write("{0}_get{1}({0}_t * {2}) ".format(element, loname, strFunctions.objAbbrev(element)))
    output.write(";\n\n\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("{0}_t *\n".format(attrib["element"]))
    output.write(
        "{0}_get{1}({0}_t * {2}, ".format(element, strFunctions.cap(attrib["name"]), strFunctions.objAbbrev(element))
    )
    output.write("unsigned int n);\n\n\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("{0}_t *\n".format(attrib["element"]))
    output.write(
        "{0}_get{1}ById({0}_t * {2}, ".format(
            element, strFunctions.cap(attrib["name"]), strFunctions.objAbbrev(element)
        )
    )
    output.write("const char * sid);\n\n\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("unsigned int\n")
    output.write(
        "{0}_getNum{1}({0}_t * {2}".format(element, strFunctions.capp(attrib["name"]), strFunctions.objAbbrev(element))
    )
    output.write(");\n\n\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("{0}_t *\n".format(attrib["element"]))
    output.write(
        "{0}_remove{1}({0}_t * {2}, ".format(element, strFunctions.cap(attrib["name"]), strFunctions.objAbbrev(element))
    )
    output.write("unsigned int n);\n\n\n")
    output.write("LIBSBML_EXTERN\n")
    output.write("{0}_t *\n".format(attrib["element"]))
    output.write(
        "{0}_remove{1}ById({0}_t * {2}, ".format(
            element, strFunctions.cap(attrib["name"]), strFunctions.objAbbrev(element)
        )
    )
    output.write("const char * sid);\n\n\n")
コード例 #52
0
def writeHasReqdElementsFunction(output, element):
    output.write('LIBSEDML_EXTERN\n')
    output.write('int\n')
    output.write('{0}_hasRequiredElements'.format(element))
    output.write('({0}_t * {1});\n\n\n'.format(
        element, strFunctions.objAbbrev(element)))
コード例 #53
0
def writeLOFunctions(fileOut, object, nameOfClass, pkg):
    ob = strFunctions.objAbbrev(object)
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the ListOf{0}s in this plugin object.\n'.format(object))
    fileOut.write(' */\n')
    fileOut.write('const ListOf{0}s* \n'.format(object))
    fileOut.write('{0}::getListOf{1}s () const\n'.format(nameOfClass, object))
    fileOut.write('{\n')
    fileOut.write('  return &this->m{0}s;\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the ListOf{0}s in this plugin object.\n'.format(object))
    fileOut.write(' */\n')
    fileOut.write('ListOf{0}s* \n'.format(object))
    fileOut.write('{0}::getListOf{1}s ()\n'.format(nameOfClass, object))
    fileOut.write('{\n')
    fileOut.write('  return &this->m{0}s;\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the {0} object that belongs to the given index.\n'.format(
            object))
    fileOut.write(' */\n')
    fileOut.write('const {0}*\n'.format(object))
    fileOut.write('{0}::get{1}(unsigned int n) const\n'.format(
        nameOfClass, object))
    fileOut.write('{\n')
    fileOut.write(
        '  return static_cast<const {0}*>(m{0}s.get(n));\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the {0} object that belongs to the given index.\n'.format(
            object))
    fileOut.write(' */\n')
    fileOut.write('{0}*\n'.format(object))
    fileOut.write('{0}::get{1}(unsigned int n)\n'.format(nameOfClass, object))
    fileOut.write('{\n')
    fileOut.write('  return static_cast<{0}*>(m{0}s.get(n));\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the {0} object based on its identifier.\n'.format(object))
    fileOut.write(' */\n')
    fileOut.write('const {0}*\n'.format(object))
    fileOut.write('{0}::get{1}(const std::string& sid) const\n'.format(
        nameOfClass, object))
    fileOut.write('{\n')
    fileOut.write(
        '  return static_cast<const {0}*>(m{0}s.get(sid));\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the {0} object based on its identifier.\n'.format(object))
    fileOut.write(' */\n')
    fileOut.write('{0}*\n'.format(object))
    fileOut.write('{0}::get{1}(const std::string& sid)\n'.format(
        nameOfClass, object))
    fileOut.write('{\n')
    fileOut.write(
        '  return static_cast<{0}*>(m{0}s.get(sid));\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Adds a copy of the given {0} to the ListOf{0}s in this plugin object.\n'
        .format(object))
    fileOut.write(' */\n')
    fileOut.write('int\n')
    fileOut.write('{2}::add{0} (const {0}* {1})\n'.format(
        object, strFunctions.lowerFirst(object), nameOfClass))
    fileOut.write('{\n')
    fileOut.write('  if ({0} == NULL)\n'.format(
        strFunctions.lowerFirst(object)))
    fileOut.write('  {\n')
    fileOut.write('    return LIBSBML_OPERATION_FAILED;\n')
    fileOut.write('  }\n')
    fileOut.write('  else if ({0}->hasRequiredElements() == false)\n'.format(
        strFunctions.lowerFirst(object)))
    fileOut.write('  {\n')
    fileOut.write('    return LIBSBML_INVALID_OBJECT;\n')
    fileOut.write('  }\n')
    fileOut.write('  else if (getLevel() != {0}->getLevel())\n'.format(
        strFunctions.lowerFirst(object)))
    fileOut.write('  {\n')
    fileOut.write('    return LIBSBML_LEVEL_MISMATCH;\n')
    fileOut.write('  }\n')
    fileOut.write('  else if (getVersion() != {0}->getVersion())\n'.format(
        strFunctions.lowerFirst(object)))
    fileOut.write('  {\n')
    fileOut.write('    return LIBSBML_VERSION_MISMATCH;\n')
    fileOut.write('  }\n')
    fileOut.write(
        '  else if (getPackageVersion() != {0}->getPackageVersion())\n'.format(
            strFunctions.lowerFirst(object)))
    fileOut.write('  {\n')
    fileOut.write('    return LIBSBML_PKG_VERSION_MISMATCH;\n')
    fileOut.write('  }\n')
    fileOut.write('  else\n')
    fileOut.write('  {\n')
    fileOut.write('    m{0}s.append({1});\n'.format(
        object, strFunctions.lowerFirst(object)))
    fileOut.write('  }\n\n')
    fileOut.write('  return LIBSBML_OPERATION_SUCCESS;\n\n')
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Creates a new {0} object and adds it to the ListOf{0}s in this plugin object.\n'
        .format(object))
    fileOut.write(' */\n')
    fileOut.write('{0}* \n'.format(object))
    fileOut.write('{1}::create{0} ()\n'.format(object, nameOfClass))
    fileOut.write('{\n')
    fileOut.write('   {0}* {1} = NULL;\n\n'.format(object, ob))
    fileOut.write('  try\n')
    fileOut.write('  {\n')
    fileOut.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(
        pkg.upper(), pkg.lower()))
    fileOut.write('    {0} = new {1}({2}ns);\n'.format(ob, object,
                                                       pkg.lower()))
    fileOut.write('    delete {0}ns;\n'.format(pkg.lower()))
    fileOut.write('  }\n')
    fileOut.write('  catch(...)\n')
    fileOut.write('  {\n')
    fileOut.write('  }\n\n')
    fileOut.write('  if ({0} != NULL)\n'.format(ob))
    fileOut.write('  {\n')
    fileOut.write('    m{0}s.appendAndOwn({1});\n'.format(object, ob))
    fileOut.write('  }\n\n')
    fileOut.write('  return {0};\n'.format(ob))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Removes the nth {0} object from this plugin object\n'.format(
            object))
    fileOut.write(' */\n')
    fileOut.write('{0}* \n'.format(object))
    fileOut.write('{1}::remove{0}(unsigned int n)\n'.format(
        object, nameOfClass))
    fileOut.write('{\n')
    fileOut.write(
        '  return static_cast<{0}*>(m{0}s.remove(n));\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Removes the {0} object with the given id from this plugin object\n'
        .format(object))
    fileOut.write(' */\n')
    fileOut.write('{0}* \n'.format(object))
    fileOut.write('{1}::remove{0}(const std::string& sid)\n'.format(
        object, nameOfClass))
    fileOut.write('{\n')
    fileOut.write(
        '  return static_cast<{0}*>(m{0}s.remove(sid));\n'.format(object))
    fileOut.write('}\n\n\n')
    fileOut.write('/*\n')
    fileOut.write(
        ' * Returns the number of {0} objects in this plugin object.\n'.format(
            object))
    fileOut.write(' */\n')
    fileOut.write('unsigned int \n')
    fileOut.write('{1}::getNum{0}s () const\n'.format(object, nameOfClass))
    fileOut.write('{\n')
    fileOut.write('  return m{0}s.size();\n'.format(object))
    fileOut.write('}\n\n\n')