[97] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Matlab Rappture Library Source |
---|
| 4 | * |
---|
[154] | 5 | * [err] = rpLibPutString(libHandle,path,value,append) |
---|
[97] | 6 | * |
---|
| 7 | * ====================================================================== |
---|
| 8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
[3177] | 9 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[115] | 10 | * |
---|
| 11 | * See the file "license.terms" for information on usage and |
---|
| 12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[97] | 13 | * ====================================================================== |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "RpMatlabInterface.h" |
---|
| 17 | |
---|
[154] | 18 | /**********************************************************************/ |
---|
| 19 | // METHOD: [err] = rpLibPutString (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 | |
---|
[97] | 34 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 35 | int nrhs, const mxArray *prhs[]) |
---|
| 36 | { |
---|
| 37 | int libIndex = 0; |
---|
| 38 | int append = 0; |
---|
[154] | 39 | int err = 1; |
---|
[97] | 40 | RpLibrary* lib = NULL; |
---|
[162] | 41 | std::string path = ""; |
---|
| 42 | std::string value = ""; |
---|
[97] | 43 | |
---|
| 44 | /* Check for proper number of arguments. */ |
---|
[162] | 45 | if (nrhs != 4) { |
---|
[97] | 46 | mexErrMsgTxt("Two input required."); |
---|
[162] | 47 | } |
---|
[97] | 48 | |
---|
| 49 | libIndex = getIntInput(prhs[0]); |
---|
| 50 | path = getStringInput(prhs[1]); |
---|
| 51 | value = getStringInput(prhs[2]); |
---|
| 52 | append = getIntInput(prhs[3]); |
---|
| 53 | |
---|
[162] | 54 | /* Call the C++ subroutine. */ |
---|
| 55 | if ( (libIndex > 0) && (!path.empty()) ) { |
---|
[1085] | 56 | lib = (RpLibrary*) getObject_Void(libIndex); |
---|
[97] | 57 | |
---|
| 58 | if (lib) { |
---|
[162] | 59 | lib->put(path,value,"",append); |
---|
[154] | 60 | err = 0; |
---|
[97] | 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
[154] | 64 | plhs[0] = mxCreateDoubleScalar(err); |
---|
| 65 | |
---|
[97] | 66 | return; |
---|
| 67 | } |
---|