source: branches/1.6/src/objects/RpString.cc @ 6131

Last change on this file since 6131 was 5679, checked in by ldelgass, 9 years ago

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  Rappture 2.0 String Object Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#include "RpString.h"
15
16using namespace Rappture;
17
18String::String (
19            const char *path,
20            const char *val
21        )
22    :   Object    ()
23{
24    this->path(path);
25    this->label("");
26    this->desc("");
27    this->hints("");
28    this->def(val);
29    this->cur(val);
30    this->width(0);
31    this->height(0);
32}
33
34String::String (
35            const char *path,
36            const char *val,
37            const char *label,
38            const char *desc,
39            const char *hints,
40            size_t width,
41            size_t height
42        )
43    :   Object    ()
44{
45    this->path(path);
46    this->label(label);
47    this->desc(desc);
48    this->hints(hints);
49    this->def(val);
50    this->cur(val);
51    this->width(width);
52    this->height(height);
53}
54
55// copy constructor
56String::String ( const String& o )
57    :   Object(o)
58{
59    this->hints(o.hints());
60    this->def(o.def());
61    this->cur(o.cur());
62    this->width(o.width());
63    this->height(o.height());
64}
65
66// default destructor
67String::~String ()
68{
69    // clean up dynamic memory
70}
71
72/**********************************************************************/
73// METHOD: xml()
74/// view this object's xml
75/**
76 * View this object as an xml element returned as text.
77 */
78
79const char *
80String::xml(size_t indent, size_t tabstop)
81{
82    size_t l1width = indent + tabstop;
83    size_t l2width = indent + (2*tabstop);
84    const char *sp = "";
85
86    Path p(path());
87    _tmpBuf.clear();
88
89    _tmpBuf.appendf(
90"%12$*9$s<string id='%1$s'>\n\
91%12$*10$s<about>\n\
92%12$*11$s<label>%2$s</label>\n\
93%12$*11$s<description>%3$s</description>\n\
94%12$*11$s<hints>%4$s</hints>\n\
95%12$*10$s</about>\n\
96%12$*10$s<size>%5$ix%6$i</size>\n\
97%12$*10$s<default>%7$s</default>\n\
98%12$*10$s<current>%8$s</current>\n\
99%12$*9$s</string>\n",
100       p.id(),label(),desc(),hints(),width(),height(),def(),cur(),
101       indent, l1width, l2width, sp);
102
103    return _tmpBuf.bytes();
104}
105
106/**********************************************************************/
107// METHOD: is()
108/// what kind of object is this
109/**
110 * return hex value telling what kind of object this is.
111 */
112
113const int
114String::is() const
115{
116    // return "stri" in hex
117    return 0x73747269;
118}
119
120// -------------------------------------------------------------------- //
121
Note: See TracBrowser for help on using the repository browser.