2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #ifndef __XMLLIST_INSERT_HPP__
14 #define __XMLLIST_INSERT_HPP__
16 #include "XMLRhsValue.hxx"
23 #include "api_scilab.h"
24 #include "xml_mlist.h"
25 #include "localization.h"
28 using namespace org_modules_xml;
30 /*--------------------------------------------------------------------------*/
33 * Function to handle insertion in XMLNodeList
34 * @param fname the function name
35 * @param fname_len the function name length
38 int sci_XMLList_insertion(char * fname, void* pvApiCtx)
53 err = getVarAddressFromPosition(pvApiCtx, 1, &indexaddr);
57 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
61 if (!isDoubleType(pvApiCtx, indexaddr))
63 Scierror(999, gettext("%s: Wrong type for input argument #%i: A double expected.\n"), fname, 1);
67 getScalarDouble(pvApiCtx, indexaddr, &index);
69 err = getVarAddressFromPosition(pvApiCtx, 2, &rhsaddr);
73 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
77 err = getVarAddressFromPosition(pvApiCtx, 3, &lhsaddr);
81 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
85 lhsid = getXMLObjectId(lhsaddr, pvApiCtx);
86 a = XMLObject::getFromId<XMLNodeList>(lhsid);
89 Scierror(999, gettext("%s: XML object does not exist.\n"), fname);
93 success = XMLRhsValue::get(fname, rhsaddr, &b, pvApiCtx);
96 Scierror(999, gettext("%s: Error in getting rhs argument.\n"), fname);
100 a->setElementAtPosition(index, *b);
102 if (typeid(T) == typeid(std::string))
107 if (a->createOnStack(Rhs + 1, pvApiCtx))