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)))
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)))
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)))
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))
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))
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)))
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)))
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')
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)))
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')
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')
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')
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')
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)))
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)))
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')
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] 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('{0}\n'.format(attTypeCode)) output.write('{0}_get{1}'.format(element, capAttName)) output.write('({0}_t * {1})\n'.format(element, varname)) output.write('{\n') if attType == 'string': 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 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}() : SEDML_INT_MAX;\n' .format(varname, capAttName)) elif attType == 'boolean': output.write( '\treturn ({0} != NULL) ? static_cast<int>({0}->get{1}()) : 0;\n' .format(varname, capAttName)) output.write('}\n\n\n') 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}_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 (ASTNode_t*){0}->get{1}();\n'.format( varname, capAttName)) output.write('}\n\n\n') else: output.write('LIBSEDML_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') output.write('LIBSEDML_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')
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')
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')
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)))
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)))
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] 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('{0}\n'.format(attTypeCode)) output.write('{0}_get{1}'.format(element, capAttName)) output.write('({0}_t * {1})\n'.format(element, varname)) output.write('{\n') if attType == 'string': 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 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}() : SEDML_INT_MAX;\n'.format(varname, capAttName)) elif attType == 'boolean': output.write('\treturn ({0} != NULL) ? static_cast<int>({0}->get{1}()) : 0;\n'.format(varname, capAttName)) output.write('}\n\n\n') 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}_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 (ASTNode_t*){0}->get{1}();\n'.format(varname, capAttName)) output.write('}\n\n\n') else: output.write('LIBSEDML_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') output.write('LIBSEDML_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')
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")