PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_matrixRows_driver.cpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: testXYedges_driver.cpp
3 
4 Generated with Template by:
5 Copyright (c) 2015 pgRouting developers
6 Mail: project@pgrouting.org
7 
8 Function's developer:
9 Copyright (c) 2015 Celia Virginia Vergara Castillo
10 Mail:
11 
12 ------
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 
28 ********************************************************************PGR-GNU*/
29 
31 
32 #include <sstream>
33 #include <iomanip>
34 #include <vector>
35 #include <cstring>
36 
37 #include "./../../common/src/pgr_assert.h"
38 
40  Matrix_cell_t *matrix_rows,
41  size_t total_rows,
42  char ** log_msg,
43  char ** err_msg) {
44  std::ostringstream log;
45  std::ostringstream err;
46  try {
47  pgassert(!(*log_msg));
48  pgassert(!(*err_msg));
49 
50  std::vector< Matrix_cell_t > matrix(matrix_rows, matrix_rows + total_rows);
51 
52  log << "Original: \n" <<
53  std::setprecision(32);
54  for (const auto row : matrix) {
55  log << "start_vid = " << row.from_vid
56  << "\tend_vid = " << row.to_vid
57  << "\tagg_cost = " << row.cost;
58  }
59 
60  *err_msg = NULL;
61  *log_msg = strdup(log.str().c_str());
62  return true;
63  } catch (AssertFailedException &except) {
64  log << except.what() << "\n";
65  *err_msg = strdup(log.str().c_str());
66  return false;
67  } catch (std::exception& except) {
68  log << except.what() << "\n";
69  *err_msg = strdup(log.str().c_str());
70  return false;
71  } catch(...) {
72  log << "Caught unknown exception!\n";
73  *err_msg = strdup(log.str().c_str());
74  return false;
75  }
76 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
virtual const char * what() const
Definition: pgr_assert.cpp:53
char * err_msg
Definition: BDATester.cpp:50
bool do_pgr_test_matrixRows(Matrix_cell_t *matrix_rows, size_t total_rows, char **log_msg, char **err_msg)