source: trunk/src/matlab/rpLibPutFile.cc @ 591

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

Added putFile capability to octave, matlab, fortran, perl bindings
Adjusted the core putFile function and all put functions to accept unsigned ints
added enum flags for binary and text file for the putFile function in c/c++

File size: 2.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [err] = rpLibPutFile(libHandle,path,fileName,fileType,append)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2004-2007  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] = rpLibPutFile (libHandle,path,fileName,fileType,append)
20/// Set the value of a node.
21/**
22 * Clients use this to set the value of a node to the contents of a file.
23 * If the path 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 * FileType is an integer representing the type of file to include, text
30 * (use 0) or binary (use 1).
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    unsigned int append = 0;
41    unsigned int fileType = 0;
42    int          err = 1;
43    RpLibrary*   lib = NULL;
44    std::string  path = "";
45    std::string  fileName = "";
46
47    /* Check for proper number of arguments. */
48    if (nrhs != 4) {
49        mexErrMsgTxt("Two input required.");
50    }
51
52    libIndex = getIntInput(prhs[0]);
53    path     = getStringInput(prhs[1]);
54    fileName = getStringInput(prhs[2]);
55    fileType = (unsigned int) getIntInput(prhs[3]);
56    append   = (unsigned int) 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->putFile(path,fileName,fileType,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.