pgRouting
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 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 
30 
31 #if defined(__MINGW32__) || defined(_MSC_VER)
32 #include <winsock2.h>
33 #include <windows.h>
34 #endif
35 
36 #include <sstream>
37 #include <iomanip>
38 #include <vector>
39 #include <cstring>
41 #include "./../../common/src/pgr_assert.h"
42 
44  Matrix_cell_t *matrix_rows,
45  size_t total_rows,
46  char ** log_msg,
47  char ** err_msg) {
48  std::ostringstream log;
49  std::ostringstream err;
50  try {
51  pgassert(!(*log_msg));
52  pgassert(!(*err_msg));
53 
54  std::vector< Matrix_cell_t > matrix(matrix_rows, matrix_rows + total_rows);
55 
56  log << "Original: \n" <<
57  std::setprecision(32);
58  for (const auto row : matrix) {
59  log << "start_vid = " << row.from_vid
60  << "\tend_vid = " << row.to_vid
61  << "\tagg_cost = " << row.cost;
62  }
63 
64  *err_msg = NULL;
65  *log_msg = strdup(log.str().c_str());
66  return true;
67  } catch (AssertFailedException &except) {
68  log << except.what() << "\n";
69  *err_msg = strdup(log.str().c_str());
70  return false;
71  } catch (std::exception& except) {
72  log << except.what() << "\n";
73  *err_msg = strdup(log.str().c_str());
74  return false;
75  } catch(...) {
76  log << "Caught unknown exception!\n";
77  *err_msg = strdup(log.str().c_str());
78  return false;
79  }
80 }
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:62
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)