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-2012 HUBzero Foundation, LLC |
---|
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 | |
---|
36 | void 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 = (RpLibrary*) getObject_Void(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 | } |
---|