source: trunk/src/core/RpString.cc @ 121

Last change on this file since 121 was 121, checked in by dkearney, 19 years ago

added basic doxygen tags for function definitions.

File size: 3.8 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  Rappture 2.0 String Object Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2005  Purdue Research Foundation
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
16/**********************************************************************/
17// METHOD: setDefaultValue()
18/// set the default value of this object.
19/**
20 */
21
22RpString&
23RpString::setDefaultValue(std::string newDefaultVal)
24{
25    std::string* def = NULL;
26   
27    def = (std::string*) RpVariable::getDefaultValue();
28
29    if (!def) {
30        RpVariable::setDefaultValue(new std::string (newDefaultVal));
31    }
32    else {
33        *def = newDefaultVal;
34    }
35
36    return *this;
37}
38
39/**********************************************************************/
40// METHOD: setCurrentValue()
41/// set the current value of this object
42/**
43 */
44
45RpString&
46RpString::setCurrentValue(std::string newCurrentVal)
47{
48    std::string* cur = (std::string*) RpVariable::getCurrentValue();
49    std::string* def = (std::string*) RpVariable::getDefaultValue();
50
51    if (cur == def) {
52        RpVariable::setCurrentValue(new std::string (newCurrentVal));
53    }
54    else {
55        *cur = newCurrentVal;
56    }
57
58    return *this;
59}
60
61/**********************************************************************/
62// METHOD: setSize()
63/// set the size (width and height) of this object.
64/**
65 */
66
67RpString&
68RpString::setSize(std::string sizeWxH)
69{
70    unsigned int xloc = sizeWxH.find("x");
71
72    if (xloc == std::string::npos) {
73        // sizeWxH is of incorrect format
74        // raise error!
75
76    }
77    else {           
78        this->width = atoi(sizeWxH.substr(0,xloc).c_str());
79        this->height = atoi(sizeWxH.substr(xloc).c_str());
80    }
81
82    return *this;
83}
84
85/**********************************************************************/
86// METHOD: setWidth()
87/// set the width of this object
88/**
89 */
90
91RpString&
92RpString::setWidth(int newWidth)
93{
94    this->width = newWidth;
95    return *this;
96}
97
98/**********************************************************************/
99// METHOD: setHeight()
100/// set the height of this object.
101/**
102 */
103
104RpString&
105RpString::setHeight(int newHeight)
106{
107    this->height = newHeight;
108    return *this;
109}
110
111
112/**********************************************************************/
113// METHOD: getDefaultValue()
114/// report the default value of this object.
115/**
116 */
117
118std::string
119RpString::getDefaultValue(void* null_val) const
120{
121    return *((std::string*) RpVariable::getDefaultValue());
122}
123
124/**********************************************************************/
125// METHOD: getCurrentValue()
126/// report the current value of this object.
127/**
128 */
129
130std::string
131RpString::getCurrentValue(void* null_val) const
132{
133    return *((std::string*) RpVariable::getCurrentValue());
134}
135
136/**********************************************************************/
137// METHOD: getSize()
138/// report the size of this object  in the form  Height x Width
139/**
140 */
141
142std::string
143RpString::getSize() const
144{
145    std::stringstream tmpStr;
146
147    tmpStr << getWidth() << "x" << getHeight();
148    return (tmpStr.str());
149}
150
151/**********************************************************************/
152// METHOD: getHeight()
153/// report the Height of this object.
154/**
155 */
156
157int
158RpString::getHeight() const
159{
160    return height;
161}
162
163/**********************************************************************/
164// METHOD: getWidth()
165/// report the Width of this object.
166/**
167 */
168
169int
170RpString::getWidth() const
171{
172    return width;
173}
174
175// -------------------------------------------------------------------- //
176
Note: See TracBrowser for help on using the repository browser.