source: trunk/src/matlab/rpLibPutStringId.cc @ 154

Last change on this file since 154 was 154, checked in by dkearney, 19 years ago

modified matlab bindings and tests.
includes all popular functions available in RpLibrary? and RpUnits
compile and run, but not all tests work as they should
some of these functions will be removed soon because the id field is
no longer a valid argument. path ids should be incorporated in paths from now on.

File size: 2.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [err] = rpLibPutStringId(libHandle,path,value,id,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] = rpLibPutStringId (libHandle,path,value,id,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 * 'id' is used to set the identifier field for the tag at the`
29 * tail of the path.  If the append flag is set to 1, then the`
30 * value is appended to the current value.  Otherwise, the`
31 * value specified in the function call replaces the current value.
32 *
33 */
34
35
36void mexFunction(int nlhs, mxArray *plhs[],
37                 int nrhs, const mxArray *prhs[])
38{
39    int         libIndex = 0;
40    int         append = 0;
41    int         err = 0;
42    RpLibrary*  lib = NULL;
43    RpLibrary*  retLib = NULL;
44    char*       path = NULL;
45    char*       value = NULL;
46    char*       id = NULL;
47
48    /* Check for proper number of arguments. */
49    if (nrhs != 5)
50        mexErrMsgTxt("Two input required.");
51    else if (nlhs > 1)
52        mexErrMsgTxt("Too many output arguments.");
53
54    libIndex = getIntInput(prhs[0]);
55    path = getStringInput(prhs[1]);
56    value = getStringInput(prhs[2]);
57    id = getStringInput(prhs[3]);
58    append = getIntInput(prhs[4]);
59
60    /* Call the C subroutine. */
61    if ( (libIndex > 0) && path && value  && id) {
62        lib = getObject_Lib(libIndex);
63
64        if (lib) {
65            rpPutStringId(lib,path,value,id,append);
66            err = 0;
67        }
68    }
69
70    plhs[0] = mxCreateDoubleScalar(err);
71
72    return;
73}
Note: See TracBrowser for help on using the repository browser.