source: trunk/lang/matlab/rpLibPut.cc @ 1025

Last change on this file since 1025 was 162, checked in by dkearney, 18 years ago

changed matlab api to call c++ functions instead of rappture's c api
removed following functions because they are outdated and should not be included at matlab/octave's release
src/octave/rpLibPutDoubleId.cc
src/octave/rpLibPutStringId.cc
src/matlab/rpLibPutDoubleId.cc
src/matlab/rpLibPutStringId.cc
cleaned up makefile to reflect the removal of above functions.
matlab bindings need to be retested. they receive a runtime error about undefined symbols

File size: 2.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [err] = rpLibPut(libHandle,path,value,append)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2004-2005  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15
16#include "RpMatlabInterface.h"
17
18/**********************************************************************/
19// METHOD: [err] = rpLibPut (libHandle,path,value,append)
20/// Set the value of a node.
21/**
22 * Clients use this to set the value of a node.  If the path
23 * is not specified, it sets the value for the root node.
24 * Otherwise, it sets the value for the element specified
25 * by the path.  The value is treated as the text within the`
26 * tag at the tail of the path.
27 *
28 * If the append flag is set to 1, then the`
29 * value is appended to the current value.  Otherwise, the`
30 * value specified in the function call replaces the current value.
31 *
32 */
33
34void mexFunction(int nlhs, mxArray *plhs[],
35                 int nrhs, const mxArray *prhs[])
36{
37    int         libIndex = 0;
38    int         append = 0;
39    int         err    = 1;
40    RpLibrary*  lib = NULL;
41    std::string path = "";
42    std::string value = "";
43
44    /* Check for proper number of arguments. */
45    if (nrhs != 4) {
46        mexErrMsgTxt("Two input required.");
47    }
48
49    libIndex = getIntInput(prhs[0]);
50    path = getStringInput(prhs[1]);
51    value = getStringInput(prhs[2]);
52    append = getIntInput(prhs[3]);
53
54    /* Call the C++ subroutine. */
55    if ( (libIndex > 0) && (!path.empty()) ) {
56        lib = getObject_Lib(libIndex);
57
58        if (lib) {
59            lib->put(path,value,"",append);
60            err = 0;
61        }
62    }
63
64    plhs[0] = mxCreateDoubleScalar(err);
65
66    return;
67}
Note: See TracBrowser for help on using the repository browser.