1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Octave Rappture Library Source |
---|
4 | * |
---|
5 | * [retStr,err] = rpLibXml(libHandle) |
---|
6 | * |
---|
7 | * ====================================================================== |
---|
8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
9 | * Copyright (c) 2005 |
---|
10 | * Purdue Research Foundation, West Lafayette, IN |
---|
11 | * ====================================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | #include "RpOctaveInterface.h" |
---|
15 | |
---|
16 | /**********************************************************************/ |
---|
17 | // METHOD: [retStr,err] = rpLibXml (libHandle) |
---|
18 | /// Returns the xml from the Rappture Object represented by 'libHandle'. |
---|
19 | /** |
---|
20 | * Usually called by user when they need to retrieve the character |
---|
21 | * representation of the xml being stored in the Rappture Library Object |
---|
22 | * Error code, err=0 on success, anything else is failure. |
---|
23 | */ |
---|
24 | |
---|
25 | DEFUN_DLD (rpLibXml, args, , |
---|
26 | "-*- texinfo -*-\n\ |
---|
27 | [retText, err] = rpLibXml (@var{libHandle})\n\ |
---|
28 | \n\ |
---|
29 | Returns the xml text of the Rappture Object represented by the\n\ |
---|
30 | handle @var{libHandle}. Also returns an error code,\n\ |
---|
31 | err = 0 is success, anything else is failure.") |
---|
32 | { |
---|
33 | static std::string who = "rpLibXml"; |
---|
34 | |
---|
35 | // The list of values to return. |
---|
36 | octave_value_list retval; |
---|
37 | |
---|
38 | int nargin = args.length (); |
---|
39 | std::string output_buf = ""; |
---|
40 | RpLibrary* lib = NULL; |
---|
41 | int libIndex = 0; |
---|
42 | |
---|
43 | retval(0) = ""; |
---|
44 | retval(1) = 1; |
---|
45 | |
---|
46 | if (nargin == 1) { |
---|
47 | if (args(0).is_real_scalar ()) { |
---|
48 | libIndex = args(0).int_value (); |
---|
49 | if (libIndex > 0) { |
---|
50 | lib = getObject_Lib(libIndex); |
---|
51 | if (lib) { |
---|
52 | output_buf = lib->xml(); |
---|
53 | if (output_buf.length() > 0) { |
---|
54 | retval(1) = 0; |
---|
55 | } |
---|
56 | retval(0) = output_buf; |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | else { |
---|
62 | print_usage (who.c_str()); |
---|
63 | } |
---|
64 | |
---|
65 | return retval; |
---|
66 | } |
---|