1 /* 2 3 Copyright (C) 2012-2019 Olaf Till <i7tiol@t-online.de> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; If not, see <http://www.gnu.org/licenses/>. 17 18 */ 19 20 #include <octave/oct.h> 21 22 #include "pq_connection.h" 23 #include "error-helpers.h" 24 25 26 // PKG_ADD: autoload ("__pq_connect__", "pq_interface.oct"); 27 // PKG_DEL: autoload ("__pq_connect__", "pq_interface.oct", "remove"); 28 29 DEFUN_DLD (__pq_connect__, args, , 30 "-*- texinfo -*-\n\ 31 @deftypefn {Loadable Function} {@var{id}} __pq_connect__ (@var{options})\n\ 32 Text.\n\ 33 \n\ 34 @end deftypefn") 35 { 36 std::string fname ("__pq_connect__"); 37 38 octave_value retval; 39 40 if (args.length () != 1) 41 { 42 print_usage (); 43 44 return octave_value_list (); 45 } 46 47 std::string opt_string; 48 CHECK_ERROR (opt_string = args(0).string_value (), retval, 49 "%s: argument not a string", fname.c_str ()); 50 51 octave_pq_connection *oct_pq_conn = new octave_pq_connection (opt_string); 52 53 if (! oct_pq_conn->get_rep ()->octave_pq_get_conn ()) 54 error ("%s failed", fname.c_str ()); 55 else 56 retval = oct_pq_conn; 57 58 return retval; 59 } 60