/** *Matrixdatatypethatcanstorevaluesofmixedtypes.Eachelementcan *beoneofthefollowingtypes:numeric,string,boolean,empty,andempty *path.
*/ class ScMatrix final
{ friendclass ScMatrixImpl;
mutable size_t nRefCnt; // reference count mutablebool mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call.
std::unique_ptr<ScMatrixImpl> pImpl;
/** Checks nC or nR for zero and uses GetElementsMax() whether a matrix of thesizeofnC*nRcouldbeallocated.Azerosize(bothnCandnRzero) matrixisallowedforlaterresize.
*/ boolstatic IsSizeAllocatable( SCSIZE nC, SCSIZE nR );
/// Value or boolean. staticbool IsValueType( ScMatValType nType )
{ return nType <= ScMatValType::Boolean;
}
/// String, empty or empty path, but not value nor boolean. staticbool IsNonValueType( ScMatValType nType )
{ returnbool(nType & ScMatValType::NonvalueMask);
}
/** String, but not empty or empty path or any other type. NotnamedIsStringTypetopreventconfusionbecausepreviously
IsNonValueType was named IsStringType. */ staticbool IsRealStringType( ScMatValType nType )
{ return (nType & ScMatValType::NonvalueMask) == ScMatValType::String;
}
/// Empty, but not empty path or any other type. staticbool IsEmptyType( ScMatValType nType )
{ return (nType & ScMatValType::NonvalueMask) == ScMatValType::Empty;
}
/// Empty path, but not empty or any other type. staticbool IsEmptyPathType( ScMatValType nType )
{ return (nType & ScMatValType::NonvalueMask) == ScMatValType::EmptyPath;
}
/** Clone the matrix. */
ScMatrix* Clone() const;
/** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise
return _this_ matrix, to be assigned to a ScMatrixRef. */
ScMatrix* CloneIfConst();
/** Set the matrix to mutable for CloneIfConst(), only the interpreter
should do this and know the consequences. */ void SetMutable();
/** Set the matrix to immutable for CloneIfConst(), only the interpreter
should do this and know the consequences. */ void SetImmutable() const;
/** Clone the matrix and extend it to the new size. nNewCols and nNewRows
MUST be at least of the size of the original matrix. */
ScMatrix* CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const;
/** For a row vector or column vector, if the position does not point into thevectorbutisavalidcolumnorrowoffsetitisadaptedsuchthat itpointstoanelementtobereplicated,samecolumnrow0forarow vector,samerowcolumn0foracolumnvector.Else,fora2Dmatrix, returnsfalse.
*/ bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const;
/** Checks if the matrix position is within the matrix. If it is not, for a rowvectororcolumnvectorthepositionisadaptedsuchthatitpoints toanelementtobereplicated,samecolumnrow0forarowvector, samerowcolumn0foracolumnvector.Else,fora2Dmatrixand positionnotwithinmatrix,returnsfalse.
*/ bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const;
/** Put a column vector of doubles, starting at row nR, must fit into dimensions. */ void PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ) ;
/** Put a column vector of strings, starting at row nR, must fit into dimensions. */ void PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ) ;
/** Put a column vector of empties, starting at row nR, must fit into dimensions. */ void PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) ;
/** Put a column vector of empty results, starting at row nR, must fit into dimensions. */ void PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) ;
/** Put a column vector of empty paths, starting at row nR, must fit into dimensions. */ void PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) ;
/** May be used before obtaining the double value of an element to avoid passingitsNANaround. @ATTENTION:MUSTNOTbeusediftheelementisastring! UseGetErrorIfNotString()insteadifnotsure.
@returns 0 if no error, else one of err... constants */
FormulaError GetError( SCSIZE nC, SCSIZE nR) const ;
/** Use in ScInterpreter to obtain the error code, if any.
@returns 0 if no error or string element, else one of err... constants */
FormulaError GetErrorIfNotString( SCSIZE nC, SCSIZE nR) const
{ return IsValue( nC, nR) ? GetError( nC, nR) : FormulaError::NONE; }
/// @return 0.0 if empty or empty path, else value or DoubleError. double GetDouble( SCSIZE nC, SCSIZE nR) const ; /// @return 0.0 if empty or empty path, else value or DoubleError. double GetDouble( SCSIZE nIndex) const ; /// @return value or DoubleError or string converted to value. double GetDoubleWithStringConversion( SCSIZE nC, SCSIZE nR ) const ;
/// @return empty string if empty or empty path, else string content.
svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const ; /// @return empty string if empty or empty path, else string content.
svl::SharedString GetString( SCSIZE nIndex) const ;
/** @returns the matrix element's string if one is present, otherwise the numericalvalueformattedasstring,orincaseofanerrortheerror stringisreturned;anemptystringforempty,a"FALSE"stringfor
empty path. */
svl::SharedString GetString( ScInterpreterContext& rContext, SCSIZE nC, SCSIZE nR) const ;
/// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate /// an empty string!
SC_DLLPUBLIC ScMatrixValue Get( SCSIZE nC, SCSIZE nR) const ;
/** @return <TRUE/> if string or any empty, empty cell, empty result, empty
path, in fact non-value. */ bool IsStringOrEmpty( SCSIZE nIndex ) const ;
/** @return <TRUE/> if string or any empty, empty cell, empty result, empty
path, in fact non-value. */ bool IsStringOrEmpty( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if empty or empty cell or empty result, not empty path. bool IsEmpty( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if empty cell, not empty or empty result or empty path. bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if empty result, not empty or empty cell or empty path. bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if empty path, not empty or empty cell or empty result. bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if value or boolean. bool IsValue( SCSIZE nIndex ) const ;
/// @return <TRUE/> if value or boolean. bool IsValue( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if value or boolean or empty or empty path. bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if boolean. bool IsBoolean( SCSIZE nC, SCSIZE nR ) const ;
/// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties bool IsNumeric() const ;
doubleAnd() const ; // logical AND of all matrix values, or NAN doubleOr() const ; // logical OR of all matrix values, or NAN doubleXor() const ; // logical XOR of all matrix values, or NAN
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.