src/c/CreateIntegerVariable.c \
src/c/CreateSparseVariable.c \
src/c/GetMatlabVariable.c \
- src/c/GetCharVariable.c \
src/c/GetMlistVariable.c \
src/c/GetSparseVariable.c
src/cpp/CreateStructVariable.cpp \
src/cpp/ConvertSciVarToMatVar.cpp \
src/cpp/GetIntegerVariable.cpp \
+ src/cpp/GetCharVariable.cpp \
src/cpp/GetDoubleVariable.cpp
libscimatio_la_LDFLAGS = $(AM_LDFLAGS)
src/c/CreateMatlabVariable.c src/c/CreateBooleanVariable.c \
src/c/CreateCharVariable.c src/c/CreateDoubleVariable.c \
src/c/CreateIntegerVariable.c src/c/CreateSparseVariable.c \
- src/c/GetMatlabVariable.c src/c/GetCharVariable.c \
- src/c/GetMlistVariable.c src/c/GetSparseVariable.c \
- src/cpp/CreateCellVariable.cpp \
+ src/c/GetMatlabVariable.c src/c/GetMlistVariable.c \
+ src/c/GetSparseVariable.c src/cpp/CreateCellVariable.cpp \
src/cpp/CreateHyperMatrixVariable.cpp \
src/cpp/CreateMatlabTreeVariable.cpp \
src/cpp/GetCellVariable.cpp src/cpp/GetStructVariable.cpp \
src/cpp/CreateStructVariable.cpp \
src/cpp/ConvertSciVarToMatVar.cpp \
- src/cpp/GetIntegerVariable.cpp src/cpp/GetDoubleVariable.cpp
+ src/cpp/GetIntegerVariable.cpp src/cpp/GetCharVariable.cpp \
+ src/cpp/GetDoubleVariable.cpp
am__dirstamp = $(am__leading_dot)dirstamp
@MATIO_TRUE@am__objects_1 = \
@MATIO_TRUE@ src/c/libscimatio_algo_la-matfile_manager.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateIntegerVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateSparseVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMatlabVariable.lo \
-@MATIO_TRUE@ src/c/libscimatio_algo_la-GetCharVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMlistVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-GetSparseVariable.lo
@MATIO_TRUE@am__objects_2 = \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-CreateStructVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-ConvertSciVarToMatVar.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetIntegerVariable.lo \
+@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetCharVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetDoubleVariable.lo
am_libscimatio_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libscimatio_algo_la_OBJECTS = $(am_libscimatio_algo_la_OBJECTS)
@MATIO_TRUE@ src/c/CreateIntegerVariable.c \
@MATIO_TRUE@ src/c/CreateSparseVariable.c \
@MATIO_TRUE@ src/c/GetMatlabVariable.c \
-@MATIO_TRUE@ src/c/GetCharVariable.c \
@MATIO_TRUE@ src/c/GetMlistVariable.c \
@MATIO_TRUE@ src/c/GetSparseVariable.c
@MATIO_TRUE@ src/cpp/CreateStructVariable.cpp \
@MATIO_TRUE@ src/cpp/ConvertSciVarToMatVar.cpp \
@MATIO_TRUE@ src/cpp/GetIntegerVariable.cpp \
+@MATIO_TRUE@ src/cpp/GetCharVariable.cpp \
@MATIO_TRUE@ src/cpp/GetDoubleVariable.cpp
@MATIO_TRUE@libscimatio_la_LDFLAGS = $(AM_LDFLAGS)
src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
src/c/libscimatio_algo_la-GetMatlabVariable.lo: src/c/$(am__dirstamp) \
src/c/$(DEPDIR)/$(am__dirstamp)
-src/c/libscimatio_algo_la-GetCharVariable.lo: src/c/$(am__dirstamp) \
- src/c/$(DEPDIR)/$(am__dirstamp)
src/c/libscimatio_algo_la-GetMlistVariable.lo: src/c/$(am__dirstamp) \
src/c/$(DEPDIR)/$(am__dirstamp)
src/c/libscimatio_algo_la-GetSparseVariable.lo: src/c/$(am__dirstamp) \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libscimatio_algo_la-GetIntegerVariable.lo: \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscimatio_algo_la-GetCharVariable.lo: \
+ src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libscimatio_algo_la-GetDoubleVariable.lo: \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-CreateIntegerVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-CreateMatlabVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-CreateSparseVariable.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetMatlabVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-CreateMatlabTreeVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-CreateStructVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCellVariable.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetDoubleVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetIntegerVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetStructVariable.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscimatio_algo_la-GetMatlabVariable.lo `test -f 'src/c/GetMatlabVariable.c' || echo '$(srcdir)/'`src/c/GetMatlabVariable.c
-src/c/libscimatio_algo_la-GetCharVariable.lo: src/c/GetCharVariable.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscimatio_algo_la-GetCharVariable.lo -MD -MP -MF src/c/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Tpo -c -o src/c/libscimatio_algo_la-GetCharVariable.lo `test -f 'src/c/GetCharVariable.c' || echo '$(srcdir)/'`src/c/GetCharVariable.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Tpo src/c/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/c/GetCharVariable.c' object='src/c/libscimatio_algo_la-GetCharVariable.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscimatio_algo_la-GetCharVariable.lo `test -f 'src/c/GetCharVariable.c' || echo '$(srcdir)/'`src/c/GetCharVariable.c
-
src/c/libscimatio_algo_la-GetMlistVariable.lo: src/c/GetMlistVariable.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscimatio_algo_la-GetMlistVariable.lo -MD -MP -MF src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Tpo -c -o src/c/libscimatio_algo_la-GetMlistVariable.lo `test -f 'src/c/GetMlistVariable.c' || echo '$(srcdir)/'`src/c/GetMlistVariable.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Tpo src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscimatio_algo_la-GetIntegerVariable.lo `test -f 'src/cpp/GetIntegerVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetIntegerVariable.cpp
+src/cpp/libscimatio_algo_la-GetCharVariable.lo: src/cpp/GetCharVariable.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscimatio_algo_la-GetCharVariable.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Tpo -c -o src/cpp/libscimatio_algo_la-GetCharVariable.lo `test -f 'src/cpp/GetCharVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetCharVariable.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Tpo src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/cpp/GetCharVariable.cpp' object='src/cpp/libscimatio_algo_la-GetCharVariable.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscimatio_algo_la-GetCharVariable.lo `test -f 'src/cpp/GetCharVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetCharVariable.cpp
+
src/cpp/libscimatio_algo_la-GetDoubleVariable.lo: src/cpp/GetDoubleVariable.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscimatio_algo_la-GetDoubleVariable.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscimatio_algo_la-GetDoubleVariable.Tpo -c -o src/cpp/libscimatio_algo_la-GetDoubleVariable.lo `test -f 'src/cpp/GetDoubleVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetDoubleVariable.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscimatio_algo_la-GetDoubleVariable.Tpo src/cpp/$(DEPDIR)/libscimatio_algo_la-GetDoubleVariable.Plo
<ClCompile Include="src\cpp\CreateMatlabTreeVariable.cpp" />
<ClCompile Include="src\cpp\CreateStructVariable.cpp" />
<ClCompile Include="src\cpp\GetCellVariable.cpp" />
+ <ClCompile Include="src\cpp\GetCharVariable.cpp" />
<ClCompile Include="src\cpp\GetDoubleVariable.cpp" />
<ClCompile Include="src\cpp\GetIntegerVariable.cpp" />
<ClCompile Include="src\cpp\GetStructVariable.cpp" />
<ClCompile Include="src\c\CreateMatlabVariable.c" />
<ClCompile Include="src\c\CreateSparseVariable.c" />
<ClCompile Include="src\c\DllmainMatio.c" />
- <ClCompile Include="src\c\GetCharVariable.c" />
<ClCompile Include="src\c\GetMatlabVariable.c" />
<ClCompile Include="src\c\GetMlistVariable.c" />
<ClCompile Include="src\c\GetSparseVariable.c" />
<ClCompile Include="src\c\DllmainMatio.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\c\GetCharVariable.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\c\GetMatlabVariable.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\cpp\GetIntegerVariable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\cpp\GetCharVariable.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\c\CreateMatlabVariable.h">
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA - Vincent COUVERT
- * Copyright (C) 2010 - DIGITEO - Yann COLLETTE
- * Copyright (C) 2010 - DIGITEO - Vincent COUVERT
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
- *
- */
-#include <string.h>
-#include "GetMatlabVariable.h"
-#include "api_scilab.h"
-#include "sci_types.h"
-#include "freeArrayOfString.h"
-#include "sci_malloc.h"
-#include "localization.h"
-
-matvar_t *GetCharVariable(void *pvApiCtx, int iVar, const char *name, int * parent, int item_position)
-{
- int rank = 0, i = 0, j = 0;
- size_t *pszDims = NULL;
- int *piDims = NULL;
- matvar_t *createdVar = NULL;
- int* piLen = NULL;
- char** pstData = NULL;
- char* pstMatData = NULL;
- int * piAddr = NULL;
- int * item_addr = NULL;
- int var_type;
- int saveDim = 0; /* Used to save old dimension before restoring it */
- SciErr sciErr;
-
- if (parent == NULL)
- {
- sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddr);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- sciErr = getVarType(pvApiCtx, piAddr, &var_type);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- }
- else
- {
- sciErr = getListItemAddress(pvApiCtx, parent, item_position, &item_addr);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- sciErr = getVarType(pvApiCtx, item_addr, &var_type);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- }
-
- if (var_type == sci_strings) /* 2-D array */
- {
- rank = 2;
- piDims = (int*)MALLOC(sizeof(int) * rank);
- if (piDims == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetCharVariable");
- return NULL;
- }
-
- if (parent == NULL)
- {
- // First call to retrieve dimensions
- sciErr = getMatrixOfString(pvApiCtx, piAddr, &piDims[0], &piDims[1], NULL, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- piLen = (int *)MALLOC(piDims[0] * piDims[1] * sizeof(int));
- // Second call to retrieve length of each string
- sciErr = getMatrixOfString(pvApiCtx, piAddr, &piDims[0], &piDims[1], piLen, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- pstData = (char**)MALLOC(sizeof(char*) * piDims[0] * piDims[1]);
- for (i = 0 ; i < piDims[0] * piDims[1] ; i++)
- {
- pstData[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1)); //+ 1 for null termination
- }
- // Third call to retrieve data
- sciErr = getMatrixOfString(pvApiCtx, piAddr, &piDims[0], &piDims[1], piLen, pstData);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
- else
- {
- // First call to retrieve dimensions
- sciErr = getMatrixOfStringInList(pvApiCtx, parent, item_position, &piDims[0], &piDims[1], NULL, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- piLen = (int *)MALLOC(piDims[0] * piDims[1] * sizeof(int));
- // Second call to retrieve length of each string
- sciErr = getMatrixOfStringInList(pvApiCtx, parent, item_position, &piDims[0], &piDims[1], piLen, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- pstData = (char**)MALLOC(sizeof(char*) * piDims[0] * piDims[1]);
- for (i = 0 ; i < piDims[0] * piDims[1] ; i++)
- {
- pstData[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1)); //+ 1 for null termination
- }
- // Third call to retrieve data
- sciErr = getMatrixOfStringInList(pvApiCtx, parent, item_position, &piDims[0], &piDims[1], piLen, pstData);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return NULL;
- }
- }
-
- pszDims = (size_t*) MALLOC(rank * sizeof(size_t));
- if (pszDims == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetCharVariable");
- return NULL;
- }
- for (i = 0; i < rank; i++)
- {
- pszDims[i] = piDims[i];
- }
-
- if (piDims[0] == 0) /* Empty character string */
- {
- createdVar = Mat_VarCreate(name, MAT_C_CHAR, MAT_T_UINT8, rank, pszDims, pstData[0], 0);
- }
- else if (piDims[0]*piDims[1] == 1) /* Scalar character string */
- {
- saveDim = piDims[1];
- pszDims[1] = piLen[0];
- createdVar = Mat_VarCreate(name, MAT_C_CHAR, MAT_T_UINT8, rank, pszDims, pstData[0], 0);
- pszDims[1] = saveDim;
- }
- else /* More than one character string -> save as a Cell */
- {
- if (piDims[0] == 1)
- {
- /* TODO: Should be saved as a cell */
- Scierror(999, _("%s: Row array of strings saving is not implemented.\n"), "GetCharVariable");
- freeArrayOfString(pstData, piDims[0]*piDims[1]);
- FREE(pszDims);
- FREE(piDims);
- FREE(piLen);
- return NULL;
- }
- else if (piDims[1] == 1)
- {
- /* Check that all strings have the same length */
- for (i = 0 ; i < piDims[0] ; i++)
- {
- if (piLen[0] != piLen[i])
- {
- /* TODO: Should be saved as a cell */
- Scierror(999, _("%s: Column array of strings with different lengths saving is not implemented.\n"), "GetCharVariable");
- freeArrayOfString(pstData, piDims[0]*piDims[1]);
- FREE(pszDims);
- FREE(piDims);
- FREE(piLen);
- return NULL;
- }
- }
-
- /* Reorder characters */
- pstMatData = (char*)MALLOC(sizeof(char) * piDims[0] * piLen[0]);
- for (i = 0 ; i < piDims[0] ; i++)
- {
- for (j = 0 ; j < piLen[0] ; j++)
- {
- pstMatData[i + j * piDims[0]] = pstData[i][j];
- }
- }
-
- /* Save the variable */
- saveDim = piDims[1];
- pszDims[1] = piLen[0];
- createdVar = Mat_VarCreate(name, MAT_C_CHAR, MAT_T_UINT8, rank, pszDims, pstMatData, 0);
- pszDims[1] = saveDim;
-
- freeArrayOfString(pstData, piDims[0]*piDims[1]); /* FREE now because dimensions are changed just below */
- FREE(pstMatData);
- FREE(pszDims);
- FREE(piDims);
- FREE(piLen);
- }
- else
- {
- /* TODO: Should be saved as a cell */
- Scierror(999, _("%s: 2D array of strings saving is not implemented.\n"), "GetCharVariable");
- freeArrayOfString(pstData, piDims[0]*piDims[1]);
- FREE(pszDims);
- FREE(piDims);
- FREE(piLen);
- return NULL;
- }
- }
- }
- else
- {
- Scierror(999, _("%s: Wrong type for first input argument: String matrix expected.\n"), "GetCharVariable");
- freeArrayOfString(pstData, piDims[0]*piDims[1]);
- FREE(pszDims);
- FREE(piDims);
- FREE(piLen);
- return NULL;
- }
-
- return createdVar;
-}
break;
case GenericType::ScilabString:
{
- String* pStr = pIT->getAs<String>();
- return Mat_VarCreate(name, MAT_C_CHAR, MAT_T_UINT8, Dims, psize_t, pStr->get(), 0);
+ return GetCharMatVar(pIT->getAs<String>(), name);
}
break;
case GenericType::ScilabSparse:
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Vincent COUVERT
+ * Copyright (C) 2010 - DIGITEO - Yann COLLETTE
+ * Copyright (C) 2010 - DIGITEO - Vincent COUVERT
+ * Copyright (C) 2015 - Scilab Enterprises - Sylvain GENIN
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "GetMatlabVariable.hxx"
+#include "ConvertSciVarToMatVar.hxx"
+
+extern "C"
+{
+#include <string.h>
+#include "api_scilab.h"
+#include "sci_types.h"
+#include "freeArrayOfString.h"
+#include "sci_malloc.h"
+#include "localization.h"
+}
+
+matvar_t *GetCharVariable(void *pvApiCtx, int iVar, const char *name, int * parent, int item_position)
+{
+ types::GatewayStruct* pGS = (types::GatewayStruct*)pvApiCtx;
+ types::typed_list in = *pGS->m_pIn;
+
+ if (in[iVar - 1]->isString() == false)
+ {
+ Scierror(999, _("%s: Wrong type for first input argument: String matrix expected.\n"), "GetCharVariable");
+ return NULL;
+ }
+
+ types::String* pStr = in[iVar - 1]->getAs<types::String>();
+
+ return GetCharMatVar(pStr, name);
+}
+
+matvar_t* GetCharMatVar(types::String* pStr, const char* name)
+{
+ int Dims = pStr->getDims();
+ int* pDims = pStr->getDimsArray();
+ matvar_t * pMatVarOut = NULL;
+ int* piLen = NULL;
+
+ if (Dims > 2)
+ {
+ Scierror(999, _("%s: Row array of strings saving is not implemented.\n"), "GetCharMatVar");
+ return NULL;
+ }
+
+ if (pDims[1] != 1)
+ {
+ Scierror(999, _("%s: Row array of strings saving is not implemented.\n"), "GetCharMatVar");
+ return NULL;
+ }
+
+ char* pcName = wide_string_to_UTF8(pStr->get(0));
+ int iLen = strlen(pcName);
+ FREE(pcName);
+
+ for (int i = 1; i < pStr->getSize(); ++i)
+ {
+ pcName = wide_string_to_UTF8(pStr->get(i));
+ if (iLen != strlen(pcName))
+ {
+ Scierror(999, _("%s: Column array of strings with different lengths saving is not implemented.\n"), "GetCharMatVar");
+ FREE(pcName);
+ return NULL;
+ }
+ FREE(pcName);
+ }
+
+ size_t* psize_t = (size_t*)MALLOC(Dims * sizeof(size_t));
+ if (psize_t == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "GetCharMatVar");
+ return NULL;
+ }
+
+ /* Reorder characters */
+ char* pstMatData = (char*)MALLOC(sizeof(char) * pDims[0] * iLen);
+ for (int i = 0; i < pDims[0]; ++i)
+ {
+ pcName = wide_string_to_UTF8(pStr->get(i));
+ for (int j = 0; j < iLen; ++j)
+ {
+ pstMatData[i + j * pDims[0]] = pcName[j];
+ }
+ FREE(pcName);
+ }
+
+
+ /* Save the variable */
+ psize_t[0] = pDims[0];
+ psize_t[1] = iLen;
+
+ pMatVarOut = Mat_VarCreate(name, MAT_C_CHAR, MAT_T_UINT8, Dims, psize_t, pstMatData, 0);
+
+ FREE(pstMatData);
+ FREE(psize_t);
+
+ return pMatVarOut;
+}
+
#include "int.hxx"
#include "struct.hxx"
#include "context.hxx"
+#include "string.hxx"
extern "C"
{
matvar_t* GetIntegerMatVar(types::InternalType* pITIn, const char* name);
+matvar_t* GetCharMatVar(types::String* pStr, const char* name);
+
#endif /* !__GETMATLABVARIABLE_HXX__ */