本文整理汇总了C++中CellMatrix::ColumnsInStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ CellMatrix::ColumnsInStructure方法的具体用法?C++ CellMatrix::ColumnsInStructure怎么用?C++ CellMatrix::ColumnsInStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CellMatrix
的用法示例。
在下文中一共展示了CellMatrix::ColumnsInStructure方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vRows
/* converting a CellMatrix to a std::vector<string> */
vector<string> FromCellMatrixToVectorStr(const CellMatrix& aCM, const vector<bool>& aIsDate)
{
size_t vRows(aCM.RowsInStructure()), vCols(aCM.ColumnsInStructure());
vector<string> vVect(vRows*vCols);
CellValue vTmpCell;
double vTmpDbl;
MG_Date vTmpDate;
for(size_t i=0; i<vRows; ++i)
{
for(size_t j=0; j<vCols; ++j)
{
vTmpCell = aCM(i,j);
if (vTmpCell.IsAString())
{
vVect[j+i*vCols] = aCM(i,j);
continue;
}
if (vTmpCell.IsANumber())
{
vTmpDbl = aCM(i,j);
if (aIsDate[j])
{
vTmpDate = MG_Date(FromXLDateToJulianDay(vTmpDbl));
vVect[j+i*vCols] = vTmpDate.ToString('/');
continue;
}
vVect[j+i*vCols] = ftoa(vTmpDbl);
continue;
}
}
}
return vVect;
}
示例2: MergeCellMatrices
xlw::CellMatrix xlw::MergeCellMatrices(const CellMatrix& Top, const CellMatrix& Bottom)
{
size_t cols = maxi(Top.ColumnsInStructure(), Bottom.ColumnsInStructure());
size_t rows = Top.RowsInStructure()+Bottom.RowsInStructure();
CellMatrix merged(rows,cols);
{for (size_t i=0; i < Top.ColumnsInStructure(); i++)
for (size_t j=0; j < Top.RowsInStructure(); j++)
merged(j,i) = Top(j,i);}
for (size_t i=0; i < Bottom.ColumnsInStructure(); i++)
for (size_t j=0; j < Bottom.RowsInStructure(); j++)
merged(j+Top.RowsInStructure(),i) = Bottom(j,i);
return merged;
}
示例3: FromCellMatrixToMGVectorDate
/* converting a CellMatrix to a MG_Vector */
MG_Vector FromCellMatrixToMGVectorDate(const CellMatrix& aCM, const size_t& aIndex)
{
if (aCM.ColumnsInStructure()!=1 && aCM.RowsInStructure()!=1)
MG_THROW("CellMatrix should be a one row or column structure");
bool vIsRow = aCM.ColumnsInStructure() == 1;
size_t vSize = vIsRow ? aCM.RowsInStructure() : aCM.ColumnsInStructure();
MG_Vector vRes(vSize);
if (vIsRow)
{
for(size_t i=0; i<vSize; ++i)
vRes[i] = FromXLDateToJulianDay(aCM(i, aIndex).NumericValue());
return vRes;
}
for(size_t i=0; i<vSize; ++i)
vRes[i] = FromXLDateToJulianDay(aCM(aIndex, i).NumericValue());
return vRes;
}
示例4: FromCellMatrixToMGMatrix
/* converting a CellMatrix to a MG_Matrix */
MG_Matrix FromCellMatrixToMGMatrix(const CellMatrix& aCM)
{
size_t vRows(aCM.RowsInStructure()), vCols(aCM.ColumnsInStructure());
MG_Matrix vMat(vRows, vCols);
for(size_t i=0; i<vRows; ++i)
for(size_t j=0; j<vCols; ++j)
vMat(i, j) = aCM(i, j).NumericValue();
return vMat;
}
示例5: FromCellMatrixToVectorDouble
/* converting a CellMatrix to a std::vector<double> */
vector<double> FromCellMatrixToVectorDouble(const CellMatrix& aCM, const size_t& aIndex)
{
if (aCM.ColumnsInStructure()!=1 && aCM.RowsInStructure()!=1)
MG_THROW("CellMatrix should be a one row or column structure");
bool vIsRow = aCM.ColumnsInStructure() == 1;
size_t vSize = vIsRow ? aCM.RowsInStructure() : aCM.ColumnsInStructure();
vector<double> vRes(vSize);
if (vIsRow)
{
for(size_t i=0; i<vSize; ++i)
vRes[i] = aCM(i, aIndex).NumericValue();
return vRes;
}
for(size_t i=0; i<vSize; ++i)
vRes[i] = aCM(aIndex, i).NumericValue();
return vRes;
}
示例6: ExtractCells
CellMatrix ExtractCells(CellMatrix& cells,
unsigned long row,
unsigned long column,
std::string ErrorId,
std::string thisName,
bool nonNumeric)
{
if (!cells(row,column).IsANumber())
throw(ErrorId+" "+thisName+" rows and columns expected.");
if (cells.ColumnsInStructure() <= column+1)
throw(ErrorId+" "+thisName+" rows and columns expected.");
if (!cells(row,column+1).IsANumber())
throw(ErrorId+" "+thisName+" rows and columns expected.");
unsigned long numberRows = cells(row,column);
unsigned long numberColumns = cells(row,column+1);
cells(row,column).clear();
cells(row,column+1).clear();
CellMatrix result(numberRows,numberColumns);
if (numberRows +row+1>cells.RowsInStructure())
throw(ErrorId+" "+thisName+" insufficient rows in structure");
if (numberColumns +column>cells.ColumnsInStructure())
throw(ErrorId+" "+thisName+" insufficient columns in structure");
for (unsigned long i=0; i < numberRows; i++)
for (unsigned long j=0; j < numberColumns; j++)
{
result(i,j) = cells(row+1+i,column+j);
cells(row+1+i,column+j).clear();
if (!result(i,j).IsANumber())
nonNumeric = true;
}
return result;
}
示例7:
bool // checks to see if there's an error
ContainsError(const CellMatrix& input // data to check for errors
)
{
for (unsigned long i=0; i < input.RowsInStructure(); ++i)
for (unsigned long j=0; j < input.ColumnsInStructure(); ++j)
if (input(i,j).IsError())
return true;
return false;
}
示例8: cells
xlw::DoubleOrNothing::DoubleOrNothing(const CellMatrix& cells, const std::string& identifier)
{
if (cells.ColumnsInStructure() != 1 || cells.RowsInStructure() != 1)
THROW_XLW("Multiple values given where one expected for DoubleOrNothing " << identifier);
if (!cells(0,0).IsEmpty() && !cells(0,0).IsANumber() )
THROW_XLW("expected a double or nothing, got something else " << identifier);
Empty = cells(0,0).IsEmpty();
Value = Empty ? 0.0 : cells(0,0).NumericValue();
}
示例9: MG_XLObjectPtr
MG_XLObjectPtr
GenSec_Create(const CellMatrix& aDealDesc)
{
size_t vColsSize = aDealDesc.ColumnsInStructure();
vector<bool> vIsDate(vColsSize);
string vTmp, vDateStr("DATE");
for(size_t i=0; i<vColsSize; ++i)
{
vTmp = aDealDesc(0,i).StringValue();
vTmp = ToUpper(vTmp.substr(vTmp.size()-4));
vIsDate[i] = vTmp==vDateStr ? true : false;
}
vector<string> vDealDesc = FromCellMatrixToVectorStr(aDealDesc, vIsDate);
return MG_XLObjectPtr(new MG_GenSecurity(vDealDesc, vColsSize));
}
示例10: newRowsResize
void xlw::CellMatrix::PushBottom(const CellMatrix& newRows)
{
CellMatrix newRowsResize(newRows);
size_t newColumns = maxi(newRows.ColumnsInStructure(),Columns);
if (newColumns > Columns)
for (size_t i=0; i < Rows; i++)
Cells[i].resize(newColumns);
if (newColumns > newRows.Columns)
for (size_t i=0; i < newRowsResize.Rows; i++)
newRowsResize.Cells[i].resize(newColumns);
for (size_t i=0; i < newRowsResize.Rows; i++)
Cells.push_back(newRowsResize.Cells[i]);
Rows = static_cast<size_t>(Cells.size());
Columns = newColumns;
}
示例11: thisName
ArgumentList::ArgumentList(CellMatrix cells,
std::string ErrorId)
{
CellValue empty;
unsigned long rows = cells.RowsInStructure();
unsigned long columns = cells.ColumnsInStructure();
if (rows == 0)
throw(std::string("Argument List requires non empty cell matix ")+ErrorId);
if (!cells(0,0).IsAString())
throw(std::string("a structure name must be specified for argument list class ")+ErrorId);
else
{
StructureName = cells(0,0).StringValueLowerCase();
cells(0,0) = empty;
}
{for (unsigned long i=1; i < columns; i++)
if (!cells(0,i).IsEmpty() )
throw("An argument list should only have the structure name on the first line: "+StructureName+ " " + ErrorId);
}
ErrorId +=" "+StructureName;
{for (unsigned long i=1; i < rows; i++)
for (unsigned long j=0; j < columns; j++)
if (cells(i,j).IsError())
GenerateThrow("Error Cell passed in ",i,j);}
unsigned long row=1UL;
while (row < rows)
{
unsigned long rowsDown=1;
unsigned column = 0;
while (column < columns)
{
if (cells(row,column).IsEmpty())
{
// check nothing else in row
while (column< columns)
{
if (!cells(row,column).IsEmpty())
GenerateThrow("data or value where unexpected.",row, column);
++column;
}
}
else // we have data
{
if (!cells(row,column).IsAString())
GenerateThrow("data where name expected.", row, column);
std::string thisName(cells(row,column).StringValueLowerCase());
if (thisName =="")
GenerateThrow("empty name not permissible.", row, column);
if (rows == row+1)
GenerateThrow("No space where data expected below name", row, column);
cells(row,column).clear();
// weird syntax to satisfy VC6
CellValue* belowPtr = &cells(row+1,column);
CellValue& cellBelow = *belowPtr;
if (cellBelow.IsEmpty())
GenerateThrow("Data expected below name", row, column);
if (cellBelow.IsANumber())
{
add(thisName, cellBelow.NumericValue());
column++;
cellBelow=empty;
}
else
if (cellBelow.IsBoolean())
{
add(thisName, cellBelow.BooleanValue());
column++;
cellBelow=empty;
}
else // ok its a string
{
std::string stringVal = cellBelow.StringValueLowerCase();
if ( (cellBelow.StringValueLowerCase() == "list") ||
(cellBelow.StringValueLowerCase() == "matrix") ||
(cellBelow.StringValueLowerCase() == "cells") )
{
bool nonNumeric = false;
CellMatrix extracted(ExtractCells(cells,row+2,column,ErrorId,thisName,nonNumeric));
//.........这里部分代码省略.........
示例12: assert
bool
ConvertCellMatrixToPyObject( const CellMatrix& rCM,
PyObject*& rpObj )
{
bool rc = true;
long i, j, cols, rows;
PyObject *pCols, *pValue;
rows = rCM.RowsInStructure();
cols = rCM.ColumnsInStructure();
assert(rows && cols);
if (rows == 1 && cols == 1) {
// Don't build a nested tuple; extract the single value
const CellValue& rCV = rCM(0, 0);
rc = ConvertCellValueToPyObject( rCV, rpObj );
if (rc) {
assert(rpObj);
} else {
assert(!rpObj);
ERROUT("Failed to convert single cell to PyObject");
rc = false;
}
} else if (rows == 1) { // Single horizontal rows should NOT be double-nested; they're vectors, not matrices
assert(cols > 1);
rpObj = PyTuple_New(cols); // Just ONE ROW here, with cols # of elements
for (j = 0; rc && j < cols; ++j) {
const CellValue& rCV = rCM(0, j);
rc = ConvertCellValueToPyObject( rCV, pValue );
if (rc) {
assert(pValue);
PyTuple_SetItem(rpObj, j, pValue); // pValue reference stolen here
} else {
assert(!pValue);
ERROUT("Failed to convert element %d of single-row cell to PyObject", j);
Py_DECREF(rpObj); // Get rid of the entire row; it owns elements and will delete them
rpObj = NULL;
rc = false;
}
} // end j
} else { // 2-D matrix
rpObj = PyTuple_New(rows);
for (i = 0; rc && i < rows; ++i) {
pCols = PyTuple_New(cols);
PyTuple_SetItem(rpObj, i, pCols); // pCols reference stolen here
for (j = 0; rc && j < cols; ++j) {
const CellValue& rCV = rCM(i, j);
rc = ConvertCellValueToPyObject( rCV, pValue );
if (rc) {
assert(pValue);
PyTuple_SetItem(pCols, j, pValue); // pValue reference stolen here
} else {
assert(!pValue);
ERROUT("Failed to convert element %d, %d of matrix cell to PyObject", i, j);
Py_DECREF(rpObj); // Get rid of the entire matrix; it owns elements and will delete them
rpObj = NULL;
rc = false;
}
} // end j
} // end i
} // end 2-D matrix code
return rc;
}