00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 //--------------------------------------------------------------------------- 00040 // Includes 00041 //--------------------------------------------------------------------------- 00042 00043 #include <stdlib.h> 00044 #include <stdio.h> 00045 00046 #include <OSGConfig.h> 00047 #include <OSGSysFieldDataType.h> 00048 00049 #include "OSGStatStringElem.h" 00050 00051 OSG_USING_NAMESPACE 00052 00053 00054 /***************************************************************************\ 00055 * Description * 00056 \***************************************************************************/ 00057 00065 /***************************************************************************\ 00066 * Instance methods * 00067 \***************************************************************************/ 00068 00069 /*------------- constructors & destructors --------------------------------*/ 00070 00071 StatStringElem::StatStringElem(StatElemDescBase *desc) 00072 : StatElem(desc), _value() 00073 { 00074 } 00075 00076 StatElem *StatStringElem::create(StatElemDescBase *desc) 00077 { 00078 return new StatStringElem(desc); 00079 } 00080 00081 StatStringElem::~StatStringElem(void) 00082 { 00083 } 00084 00085 /*------------------------------ access -----------------------------------*/ 00086 00087 void StatStringElem::putToString(std::string &str, const char *format) const 00088 { 00089 if(!format) 00090 { 00091 str = _value; 00092 } 00093 else 00094 { 00095 char *temp = new char [strlen(format) + _value.size() + 10]; 00096 sprintf(temp, format, _value.c_str()); 00097 str = temp; 00098 delete [] temp; 00099 } 00100 } 00101 00102 bool StatStringElem::getFromString(const Char8 *&inVal) 00103 { 00104 if(inVal != 0) 00105 { 00106 _value = inVal; 00107 } 00108 00109 return true; 00110 } 00111 00112 Real64 StatStringElem::getValue(void) const 00113 { 00114 return 0; 00115 } 00116 00117 00118 void StatStringElem::reset(void) 00119 { 00120 _value.resize(0); 00121 } 00122 00123 /*-------------------------- assignment -----------------------------------*/ 00124 00125 StatStringElem& StatStringElem::operator = (const StatStringElem &source) 00126 { 00127 if (this == &source) 00128 return *this; 00129 00130 set(source.get()); 00131 00132 return *this; 00133 } 00134 00135 /*-------------------------- comparison -----------------------------------*/ 00136 00137 bool StatStringElem::operator < (const StatStringElem &other) const 00138 { 00139 return this < &other; 00140 } 00141 00142 /*--------------------------- creation ------------------------------------*/ 00143 00144 StatElem *StatStringElem::clone(void) const 00145 { 00146 StatStringElem *e = new StatStringElem(getDesc()); 00147 00148 *e = *this; 00149 00150 return e; 00151 } 00152 00153 /*--------------------------- operators ------------------------------------*/ 00154 00155 StatElem &StatStringElem::operator += (const StatElem &other) 00156 { 00157 const StatStringElem *o = dynamic_cast<const StatStringElem *>(&other); 00158 00159 _value += " " + o->_value; 00160 00161 return *this; 00162 } 00163 00164 00165 /*-------------------------------------------------------------------------*/ 00166 /* cvs id's */ 00167 00168 #ifdef __sgi 00169 #pragma set woff 1174 00170 #endif 00171 00172 #ifdef OSG_LINUX_ICC 00173 #pragma warning( disable : 177 ) 00174 #endif 00175 00176 namespace 00177 { 00178 static Char8 cvsid_cpp[] = "@(#)$Id: $"; 00179 static Char8 cvsid_hpp[] = OSGSTATSTRINGELEM_HEADER_CVSID; 00180 static Char8 cvsid_inl[] = OSGSTATSTRINGELEM_INLINE_CVSID; 00181 }
1.5.5