| 564 | typename T |
| 565 | > |
| 566 | typename dlib::enable_if<is_array_type<T> >::type |
| 567 | assign_std_vector ( |
| 568 | const long arg_idx, |
| 569 | T& dest, |
| 570 | const mxArray* src |
| 571 | ) |
| 572 | { |
| 573 | const long nr = mxGetM(src); |
| 574 | const long nc = mxGetN(src); |
| 575 | |
| 576 | typedef typename inner_type<T>::type type; |
| 577 | |
| 578 | if (!mxIsCell(src)) |
| 579 | { |
| 580 | std::ostringstream sout; |
| 581 | sout << "Input argument " << arg_idx+1 << " must be a cell array"; |
| 582 | throw invalid_args_exception(sout); |
| 583 | } |
| 584 | if (nr != 1 && nc != 1) |
| 585 | { |
| 586 | std::ostringstream sout; |
| 587 | sout << "Input argument " << arg_idx+1 << " must be a cell array with exactly 1 row or 1 column (i.e. a row or column vector)"; |
| 588 | throw invalid_args_exception(sout); |
| 589 | } |
| 590 | |
| 591 | const long size = nr*nc; |
| 592 | dest.resize(size); |
| 593 | |
| 594 | for (unsigned long i = 0; i < dest.size(); ++i) |
| 595 | { |
| 596 | try |
| 597 | { |
| 598 | validate_and_populate_arg(i, mxGetCell(src, i), dest[i]); |
| 599 | } |
| 600 | catch (invalid_args_exception& e) |
| 601 | { |
| 602 | std::ostringstream sout; |
| 603 | sout << "Error in argument " << arg_idx+1 << ": element " << i+1 << " of cell array not the expected type.\n"; |
| 604 | sout << "\t" << e.what(); |
| 605 | throw invalid_args_exception(sout); |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | } |
| 610 | |
| 611 | template < |
| 612 | typename T |
no test coverage detected