[115] | 1 | /* |
---|
[121] | 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * Rappture 2.0 String Object Source |
---|
| 4 | * |
---|
[115] | 5 | * ====================================================================== |
---|
[121] | 6 | * AUTHOR: Derrick Kearney, Purdue University |
---|
[3177] | 7 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[115] | 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 | */ |
---|
[37] | 13 | |
---|
[121] | 14 | #include "RpString.h" |
---|
[37] | 15 | |
---|
[1386] | 16 | using namespace Rappture; |
---|
[121] | 17 | |
---|
[1386] | 18 | String::String ( |
---|
| 19 | const char *path, |
---|
| 20 | const char *val |
---|
| 21 | ) |
---|
[1528] | 22 | : Object () |
---|
[37] | 23 | { |
---|
[1386] | 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); |
---|
[37] | 32 | } |
---|
| 33 | |
---|
[1386] | 34 | String::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 | ) |
---|
[1528] | 43 | : Object () |
---|
[37] | 44 | { |
---|
[1386] | 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); |
---|
[37] | 53 | } |
---|
| 54 | |
---|
[1386] | 55 | // copy constructor |
---|
| 56 | String::String ( const String& o ) |
---|
[1528] | 57 | : Object(o) |
---|
[37] | 58 | { |
---|
[1386] | 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()); |
---|
[37] | 64 | } |
---|
| 65 | |
---|
[1386] | 66 | // default destructor |
---|
| 67 | String::~String () |
---|
[37] | 68 | { |
---|
[1386] | 69 | // clean up dynamic memory |
---|
[37] | 70 | } |
---|
| 71 | |
---|
[1528] | 72 | /**********************************************************************/ |
---|
| 73 | // METHOD: xml() |
---|
| 74 | /// view this object's xml |
---|
| 75 | /** |
---|
| 76 | * View this object as an xml element returned as text. |
---|
| 77 | */ |
---|
| 78 | |
---|
| 79 | const char * |
---|
[1560] | 80 | String::xml(size_t indent, size_t tabstop) |
---|
[1528] | 81 | { |
---|
[1560] | 82 | size_t l1width = indent + tabstop; |
---|
| 83 | size_t l2width = indent + (2*tabstop); |
---|
| 84 | const char *sp = ""; |
---|
| 85 | |
---|
[1528] | 86 | Path p(path()); |
---|
| 87 | _tmpBuf.clear(); |
---|
| 88 | |
---|
| 89 | _tmpBuf.appendf( |
---|
[1560] | 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); |
---|
[1528] | 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 | |
---|
| 113 | const int |
---|
| 114 | String::is() const |
---|
| 115 | { |
---|
| 116 | // return "stri" in hex |
---|
| 117 | return 0x73747269; |
---|
| 118 | } |
---|
| 119 | |
---|
[37] | 120 | // -------------------------------------------------------------------- // |
---|
| 121 | |
---|