else
trueEnd=nbt;
int nbComp=getNumberOfComponents();
- DataArrayDouble *ret=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
ret->alloc(trueEnd-tupleIdBg,nbComp);
ret->copyStringInfoFrom(*this);
std::copy(getConstPointer()+tupleIdBg*nbComp,getConstPointer()+trueEnd*nbComp,ret->getPointer());
- return ret;
+ return ret.retn();
}
/*!
else
trueEnd=nbt;
int nbComp=getNumberOfComponents();
- DataArrayInt *ret=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(trueEnd-tupleIdBg,nbComp);
ret->copyStringInfoFrom(*this);
std::copy(getConstPointer()+tupleIdBg*nbComp,getConstPointer()+trueEnd*nbComp,ret->getPointer());
- return ret;
+ return ret.retn();
}
/*!
static void FindTupleIdsNearTuplesAlg(const BBTree<SPACEDIM,int>& myTree, const double *pos, int nbOfTuples, double eps,
DataArrayInt *c, DataArrayInt *cI);
private:
+ ~DataArrayDouble() { }
DataArrayDouble() { }
private:
MemArray<double> _mem;
MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
private:
+ ~DataArrayInt() { }
DataArrayInt() { }
private:
MemArray<int> _mem;
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isUniform(char val) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayChar *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayChar *changeNbOfComponents(int newNbOfComp, char dftValue) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const throw(INTERP_KERNEL::Exception);
private:
+ ~DataArrayByte() { }
DataArrayByte() { }
};
MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const throw(INTERP_KERNEL::Exception);
private:
+ ~DataArrayAsciiChar() { }
DataArrayAsciiChar() { }
DataArrayAsciiChar(const std::string& st) throw(INTERP_KERNEL::Exception);
DataArrayAsciiChar(const std::vector<std::string>& vst, char defaultChar) throw(INTERP_KERNEL::Exception);
declareAsNew();
}
+/*!
+ * Returns a shorten copy of \a this array. The new DataArrayChar contains all
+ * tuples starting from the \a tupleIdBg-th tuple and including all tuples located before
+ * the \a tupleIdEnd-th one. This methods has a similar behavior as std::string::substr().
+ * This method is a specialization of selectByTupleId2().
+ * \param [in] tupleIdBg - index of the first tuple to copy from \a this array.
+ * \param [in] tupleIdEnd - index of the tuple before which the tuples to copy are located.
+ * If \a tupleIdEnd == -1, all the tuples till the end of \a this array are copied.
+ * \return DataArrayChar * - the new instance of DataArrayChar that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a tupleIdBg < 0.
+ * \throw If \a tupleIdBg > \a this->getNumberOfTuples().
+ \throw If \a tupleIdEnd != -1 && \a tupleIdEnd < \a this->getNumberOfTuples().
+ * \sa DataArrayChar::selectByTupleId2
+ */
+DataArrayChar *DataArrayChar::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbt=getNumberOfTuples();
+ if(tupleIdBg<0)
+ throw INTERP_KERNEL::Exception("DataArrayChar::substr : The tupleIdBg parameter must be greater than 0 !");
+ if(tupleIdBg>nbt)
+ throw INTERP_KERNEL::Exception("DataArrayChar::substr : The tupleIdBg parameter is greater than number of tuples !");
+ int trueEnd=tupleIdEnd;
+ if(tupleIdEnd!=-1)
+ {
+ if(tupleIdEnd>nbt)
+ throw INTERP_KERNEL::Exception("DataArrayChar::substr : The tupleIdBg parameter is greater or equal than number of tuples !");
+ }
+ else
+ trueEnd=nbt;
+ int nbComp=getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayChar> ret=buildEmptySpecializedDAChar();
+ ret->alloc(trueEnd-tupleIdBg,nbComp);
+ ret->copyStringInfoFrom(*this);
+ std::copy(getConstPointer()+tupleIdBg*nbComp,getConstPointer()+trueEnd*nbComp,ret->getPointer());
+ return ret.retn();
+}
+
/*!
* Returns a shorten or extended copy of \a this array. If \a newNbOfComp is less
* than \a this->getNumberOfComponents() then the result array is shorten as each tuple
%newobject ParaMEDMEM::DataArrayByte::deepCpy;
%newobject ParaMEDMEM::DataArrayByte::performCpy;
%newobject ParaMEDMEM::DataArrayByteTuple::buildDAByte;
+%newobject ParaMEDMEM::DataArrayChar::substr;
%newobject ParaMEDMEM::DataArrayAsciiChar::New;
%newobject ParaMEDMEM::DataArrayAsciiChar::__iter__;
%newobject ParaMEDMEM::DataArrayAsciiChar::deepCpy;
%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();"
%feature("unref") MEDCouplingCMesh "$this->decrRef();"
%feature("unref") DataArrayInt "$this->decrRef();"
+%feature("unref") DataArrayAsciiChar "$this->decrRef();"
+%feature("unref") DataArrayByte "$this->decrRef();"
%feature("unref") MEDCouplingField "$this->decrRef();"
%feature("unref") MEDCouplingFieldDiscretizationP0 "$this->decrRef();"
%feature("unref") MEDCouplingFieldDiscretizationP1 "$this->decrRef();"
std::vector<int> stdvecTyyppArr;
std::pair<int, std::pair<int,int> > sTyyppArr;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
- int nbOfCompo=self->getNumberOfTuples();
- convertObjToPossibleCpp2(obj,nbOfCompo,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ int nbOfCompo=self->getNumberOfComponents();
+ int nbOfTuples=self->getNumberOfTuples();
+ convertObjToPossibleCpp2(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
int sw2;
char vc; std::string sc; std::vector<std::string> vsc; DataArrayChar *dacc=0;
convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc);