source: trunk/lang/matlab/rpLibPutData.cc @ 1018

Last change on this file since 1018 was 597, checked in by dkearney, 17 years ago

adjusted core makefile to not remove setup.py when doing a make clean
adjusted putFile and putData commands and flags in matlab, octave,fortran,perl
changed the RPLIB_[TEXT,BINARY] flags to RPLIB_COMPRESS and RPLIB_NO_COMPRESS flags
adjusted the c-example for compress to incorporate newly named flags.
adjusted rappture library header to find rappture buffer header files in rappture2 directory.

File size: 2.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [err] = rpLibPutData (libHandle,path,bytes,nbytes,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] = rpLibPutData (libHandle,path,bytes,nbytes,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 * FileName is the name of the file to import into the rappture object
29 * Compress is an integer telling if you want the data compressed (use 1)
30 * or uncompressed (use 0).
31 * Append is an integer telling if this new data should overwrite
32 * (use 0) or be appended (use 1) to previous data in this node.
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         nbytes = 0;
42    int         err = 1;
43    RpLibrary*  lib = NULL;
44    std::string path = "";
45    std::string bytes = "";
46
47    /* Check for proper number of arguments. */
48    if (nrhs != 5) {
49        mexErrMsgTxt("Five inputs required.");
50    }
51
52    libIndex = getIntInput(prhs[0]);
53    path = getStringInput(prhs[1]);
54    bytes = getStringInput(prhs[2]);
55    nbytes = getIntInput(prhs[3]);
56    append = getIntInput(prhs[4]);
57
58    /* Call the C++ subroutine. */
59    if ( (libIndex > 0) && (!path.empty()) ) {
60        lib = getObject_Lib(libIndex);
61
62        if (lib) {
63            lib->putData(path,bytes.c_str(),nbytes,append);
64            err = 0;
65        }
66    }
67
68    plhs[0] = mxCreateDoubleScalar(err);
69
70    return;
71}
Note: See TracBrowser for help on using the repository browser.