source: trunk/lang/octave/rpLibGet.cc @ 1727

Last change on this file since 1727 was 1262, checked in by dkearney, 15 years ago

attempting to fix compiler warning for octave's print_usage function
this seems to work for octave3.0
also adding checks to configure for more header files

File size: 2.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpLibGet(libHandle,path)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2005
10 *  Purdue Research Foundation, West Lafayette, IN
11 * ======================================================================
12 */
13
14#include "RpOctaveInterface.h"
15
16/**********************************************************************/
17// METHOD: [retStr,err] = rpLibGet(libHandle,path)
18/// Query the value of a node.
19/**
20 * Clients use this to query the value of a node.  If the path
21 * is not specified, it returns the value associated with the
22 * root node.  Otherwise, it returns the value for the element
23 * specified by the path. Values are returned as strings.
24 *
25 * Error code, err=0 on success, anything else is failure.
26 */
27
28DEFUN_DLD (rpLibGet, args, ,
29"-*- texinfo -*-\n\
30[retStr,err] = rpLibGet(@var{libHandle},@var{path})\n\
31\n\
32Clients use this to query the value of a node.  If the path\n\
33is not specified, it returns the value associated with the\n\
34root node.  Otherwise, it returns the value for the element\n\
35specified by the path. Values are returned as strings.\n\
36Error code, err=0 on success, anything else is failure.")
37{
38    static std::string who = "rpLibGet";
39
40    // The list of values to return.
41    octave_value_list retval;
42    int err = 1;
43    int nargin = args.length ();
44    std::string path = "";
45    int libHandle = 0;
46    RpLibrary* lib = NULL;
47    std::string retStr = "";
48
49    if (nargin == 2) {
50
51        if (    args(0).is_real_scalar () &&
52                args(1).is_string      ()   ) {
53
54            libHandle = args(0).int_value ();
55            path = args(1).string_value ();
56
57            /* Call the C subroutine. */
58            // path can be an empty string
59            if ( (libHandle >= 0) ) {
60
61                lib = (RpLibrary*) getObject_Void(libHandle);
62
63                if (lib) {
64                    retStr = lib->get(path);
65                    err = 0;
66                }
67                else {
68                    // lib was null (not found in dictionary)
69                }
70            }
71            else {
72                // invalid libHandle
73                _PRINT_USAGE (who.c_str());
74            }
75        }
76        else {
77            // wrong arg types
78            _PRINT_USAGE (who.c_str());
79        }
80    }
81    else {
82        // wrong number of args.
83        _PRINT_USAGE (who.c_str());
84    }
85
86    retval(0) = retStr;
87    retval(1) = err;
88    return retval;
89}
Note: See TracBrowser for help on using the repository browser.