source: branches/uq/lang/octave/src/rpLibGetString.cc @ 5679

Last change on this file since 5679 was 5679, checked in by ldelgass, 9 years ago

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpLibGetString(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] = rpLibGetString(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 (rpLibGetString, args, ,
29"-*- texinfo -*-\n\
30[retStr,err] = rpLibGetString(@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 = "rpLibGetString";
39
40    // The list of values to return.
41    octave_value_list retval;
42    int err = 1;
43    int argc;
44    std::string retStr = "";
45
46    argc = args.length();
47    if (argc == 2) {
48        if ((args(0).is_real_scalar()) && (args(1).is_string())) {
49            std::string path;
50            int libHandle;
51
52            libHandle = args(0).int_value ();
53
54            path = args(1).string_value ();
55            /* Call the C subroutine. */
56            // path can be an empty string
57            if (libHandle >= 0) {
58                RpLibrary* lib;
59
60                lib = (RpLibrary*) getObject_Void(libHandle);
61                if (lib != NULL) {
62                    retval(0) = lib->getString(path);
63                    retval(1) = 0;
64                    return retval;
65                }
66            } else {
67                // invalid libHandle
68                _PRINT_USAGE(who.c_str());
69            }
70        } else {
71            // wrong arg types
72            _PRINT_USAGE(who.c_str());
73        }
74    } else {
75        // wrong number of args.
76        _PRINT_USAGE(who.c_str());
77    }
78    retval(0) = retStr;
79    retval(1) = 1;
80    return retval;
81}
Note: See TracBrowser for help on using the repository browser.