- Code: Select all
CellMatrix Map(const CellMatrix &x) {
std::map<std::string, std::string> in;
MatrixToMap(x,in);
CellMatrix out(in.size(),2);
MapToMatrix(in,out);
return out;
}
void MatrixToMap(const CellMatrix &source, std::map<std::string, std::string> &dest) {
if (source.ColumnsInStructure() != 2) {
THROW_XLW("Expected a two-column array of strings");
}
for (size_t i = 0; i < source.RowsInStructure(); i++) {
dest[source(i, 0)] = source(i, 1);
}
}
void MapToMatrix(const std::map<std::string, std::string> &source, CellMatrix &dest) {
size_t i = 0;
for (std::map<std::string, std::string>::const_iterator it = source.begin(); it != source.end(); it++) {
dest(i, 0) = it->first;
dest(i, 1) = it->second;
i++;
}
}
I've tried different stuff with
- Code: Select all
dest[source(i, 0).StringValue()] = source(i, 1).StringValue()
- Code: Select all
dest(i, 0) = it->first.c_str()