Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::IDStringLink Class Reference
[Base]

#include <OSGIDStringLink.h>

Inheritance diagram for osg::IDStringLink:

osg::IDString List of all members.

Public Types

typedef std::vector< IDStringStringVec
typedef std::vector< IDString * > StringPVec
enum  MemType { COPY, LINK }

Public Member Functions

Constructors
IDStringLink (const Char8 *str=0)
 IDStringLink (const IDStringLink &obj)
 IDStringLink (const IDString &obj)
Destructor
*virtual ~IDStringLink ()
Operators
*const IDStringLinkoperator= (const IDStringLink &obj)
Access
*const Char8str (void) const
bool isEmpty (void) const
void set (const Char8 *str, MemType memType=COPY)
void toUpper (void)
void toLower (void)
UInt32 getLength (void) const
void setLength (UInt32 length)
void tokenize (StringVec &v)
void tokenize (StringPVec &v)
Comparison
*bool operator== (const IDString &obj) const
bool operator!= (const IDString &obj) const
bool operator< (const IDString &obj) const
bool operator> (const IDString &obj) const
bool operator>= (const IDString &obj) const
bool operator<= (const IDString &obj) const

Protected Attributes

Char8_str
MemType _memType

Private Types

typedef IDString Inherited

Detailed Description

Definition at line 53 of file OSGIDStringLink.h.


Member Typedef Documentation

typedef IDString osg::IDStringLink::Inherited [private]
 

Definition at line 90 of file OSGIDStringLink.h.

typedef std::vector<IDString > osg::IDString::StringVec [inherited]
 

Definition at line 74 of file OSGIDString.h.

typedef std::vector<IDString *> osg::IDString::StringPVec [inherited]
 

Definition at line 75 of file OSGIDString.h.


Member Enumeration Documentation

enum osg::IDString::MemType [inherited]
 

Enumerator:
COPY 
LINK 

Definition at line 68 of file OSGIDString.h.

00069     {
00070         COPY,
00071         LINK
00072     };


Constructor & Destructor Documentation

IDStringLink::IDStringLink const Char8 str = 0  )  [explicit]
 

Definition at line 50 of file OSGIDStringLink.cpp.

00050                                            : 
00051     Inherited(str, IDString::LINK)
00052 {
00053 }

IDStringLink::IDStringLink const IDStringLink obj  ) 
 

Definition at line 55 of file OSGIDStringLink.cpp.

00055                                                   : 
00056     Inherited(obj.str(), IDString::LINK)
00057 {
00058 }

IDStringLink::IDStringLink const IDString obj  )  [explicit]
 

Definition at line 60 of file OSGIDStringLink.cpp.

00060                                               : 
00061     Inherited(obj.str(), IDString::LINK)
00062 {
00063 }

IDStringLink::~IDStringLink  )  [virtual]
 

Definition at line 67 of file OSGIDStringLink.cpp.

00068 {
00069 }


Member Function Documentation

const IDStringLink & osg::IDStringLink::operator= const IDStringLink obj  )  [inline]
 

Definition at line 41 of file OSGIDStringLink.inl.

References osg::IDString::LINK, osg::IDString::set(), and osg::IDString::str().

00042 {
00043     set(obj.str(), LINK);
00044     
00045     return *this;
00046 }

const Char8 * osg::IDString::str void   )  const [inline, inherited]
 

Definition at line 42 of file OSGIDString.inl.

References osg::IDString::_str.

Referenced by osg::FieldContainerType::addDescription(), osg::SharePtrGraphOp::compareFCs(), osg::deepClone(), osg::SimpleStatisticsForeground::draw(), osg::StatElemDescBase::findDescByName(), osg::TypeBase::getCName(), osg::FieldDescription::getCName(), osg::TypeBase::getCParentName(), osg::ImageFileHandler::getDefaultType(), osg::FieldDescription::getDefaultValue(), osg::FieldDescription::getField(), osg::ImageFileType::getMimeType(), osg::FieldContainerType::initFields(), osg::FieldContainerType::initialize(), osg::FieldContainerType::initParentFields(), osg::operator<<(), operator=(), osg::StatElemDescBase::print(), osg::RemoteAspect::receiveSync(), and osg::FieldContainerType::registerType().

00043 {
00044     return _str; 
00045 }

bool osg::IDString::isEmpty void   )  const [inline, inherited]
 

Definition at line 48 of file OSGIDString.inl.

References osg::IDString::_str.

Referenced by osg::TypeFactory::registerType().

00049 {
00050     return (_str != NULL && *_str != '\0') ? false : true; 
00051 }

void IDString::set const Char8 str,
MemType  memType = COPY
[inherited]
 

Definition at line 88 of file OSGIDString.cpp.

References osg::IDString::_memType, osg::IDString::_str, and osg::IDString::COPY.

Referenced by osg::ImageFileHandler::addImageFileType(), osg::SceneFileHandler::addSceneFileType(), osg::SceneFileHandler::getFileType(), osg::ImageFileHandler::getFileType(), osg::IDString::IDString(), osg::ImageFileType::ImageFileType(), operator=(), osg::IDString::operator=(), and osg::SceneFileHandler::subSceneFileType().

00089 {
00090     if(str == _str)
00091     {
00092         // !!! can you change _memType here? I think not. IMHO
00093         return;
00094     }
00095 
00096     if(_memType == COPY)
00097         delete [] _str;
00098 
00099     if(memType == COPY)
00100     {
00101         if(str != NULL)
00102         {
00103             _str = new Char8[strlen(str) + 1];
00104 
00105             strcpy(_str, str);
00106         }
00107         else
00108         {
00109             _str = NULL;
00110         }
00111     }
00112     else
00113     {
00114         _str = const_cast<Char8 *>(str);
00115     }
00116 
00117     _memType = memType;
00118 }

void IDString::toUpper void   )  [inherited]
 

Definition at line 124 of file OSGIDString.cpp.

References osg::IDString::_str, and osg::IDString::getLength().

00125 {
00126     UInt32 l = getLength();
00127 
00128     for(UInt32 i = 0; i < l; ++i)
00129     {
00130         _str[i] = ::toupper(_str[i]);
00131     }
00132 
00133 }

void IDString::toLower void   )  [inherited]
 

Definition at line 135 of file OSGIDString.cpp.

References osg::IDString::_str, and osg::IDString::getLength().

Referenced by osg::ImageFileHandler::addImageFileType(), osg::SceneFileHandler::addSceneFileType(), osg::SceneFileHandler::getFileType(), osg::ImageFileHandler::getFileType(), and osg::SceneFileHandler::subSceneFileType().

00136 {
00137     UInt32 l = getLength();
00138 
00139     for(UInt32 i = 0; i < l; ++i)
00140     {
00141         _str[i] = ::tolower(_str[i]);
00142     }
00143 
00144 }

UInt32 IDString::getLength void   )  const [inherited]
 

Definition at line 150 of file OSGIDString.cpp.

References osg::IDString::_str.

Referenced by osg::FieldDescription::isValid(), osg::IDString::tokenize(), osg::IDString::toLower(), and osg::IDString::toUpper().

00151 {
00152     return (_str != NULL) ? ::strlen(_str) : 0;
00153 }

void IDString::setLength UInt32  length  )  [inherited]
 

Definition at line 155 of file OSGIDString.cpp.

References osg::IDString::_memType, osg::IDString::_str, and osg::IDString::COPY.

Referenced by osg::IDString::IDString().

00156 {
00157     if(_memType == COPY)
00158         delete [] _str;
00159 
00160     if(length != 0)
00161     {
00162          _str = new Char8[length];
00163         *_str = 0;
00164     }
00165     else
00166     {
00167         _str = 0;
00168     }
00169 
00170     _memType = COPY;
00171 }

void IDString::tokenize StringVec v  )  [inherited]
 

Definition at line 173 of file OSGIDString.cpp.

References osg::IDString::_str, osg::IDString::getLength(), and osg::IDString::IDString().

00174 {
00175     UInt32 l        = getLength();
00176     UInt32 oldpos   = 0;
00177     UInt32 pos      = 0;
00178     bool   inQuotes = false;
00179     bool   inToken  = false;
00180 
00181     if(l > 0)
00182     {
00183         Char8 *buf = new Char8[l + 1];
00184 
00185         for(pos = 0; pos <= l; ++pos)
00186         {
00187             if(!inQuotes)
00188             {
00189                 if(!inToken)
00190                 {
00191                     if(_str[pos] == '"')
00192                     {
00193                         inQuotes = true;
00194                         oldpos   = pos + 1;
00195                     }
00196                     else if(_str[pos] != ' ')
00197                     {
00198                         inToken = true;
00199                         oldpos  = pos;
00200                     }
00201                 }
00202                 else if(inToken)
00203                 {
00204                     if(_str[pos] == '"')
00205                     {
00206                         inToken = false;
00207 
00208                         strncpy(buf, _str + oldpos, pos - oldpos);
00209 
00210                         buf[pos - oldpos] = '\0';
00211 
00212                         v.push_back(IDString(buf));
00213 
00214                         inQuotes = true;
00215                         oldpos   = pos;
00216                     }
00217                     else if(_str[pos] == ' ')
00218                     {
00219                         inToken = false;
00220 
00221                         strncpy(buf, _str + oldpos, pos - oldpos);
00222 
00223                         buf[pos - oldpos] = '\0';
00224 
00225                         v.push_back(IDString(buf));
00226                     }
00227                     else if(pos == l)
00228                     {
00229                         strncpy(buf, _str + oldpos, pos - oldpos);
00230 
00231                         buf[pos - oldpos] = '\0';
00232 
00233                         v.push_back(IDString(buf));
00234                     }
00235                 }
00236             }
00237             else if(inQuotes)
00238             {
00239                 if(_str[pos] == '"')
00240                 {
00241                     inQuotes = false;
00242 
00243                     if(pos > oldpos)
00244                     {
00245                         strncpy(buf, _str + oldpos, pos - oldpos);
00246 
00247                         buf[pos - oldpos] = '\0';
00248 
00249                         v.push_back(IDString(buf));
00250                     }
00251                 }
00252                 else if(pos == l)
00253                 {
00254                     if(pos > oldpos)
00255                     {
00256                         strncpy(buf, _str + oldpos, pos - oldpos);
00257 
00258                         buf[pos - oldpos] = '\0';
00259 
00260                         v.push_back(IDString(buf));
00261                     }
00262                 }
00263             }
00264         }
00265 
00266         delete [] buf;
00267     }
00268 }

void IDString::tokenize StringPVec v  )  [inherited]
 

Definition at line 270 of file OSGIDString.cpp.

References osg::IDString::_str, osg::IDString::getLength(), and osg::IDString::IDString().

00271 {
00272     UInt32 l        = getLength();
00273     UInt32 oldpos   = 0;
00274     UInt32 pos      = 0;
00275     bool   inQuotes = false;
00276     bool   inToken  = false;
00277 
00278     IDString *pString = NULL;
00279 
00280     if(l > 0)
00281     {
00282         Char8 *buf = new Char8[l + 1];
00283 
00284         for(pos = 0; pos <= l; ++pos)
00285         {
00286             if(!inQuotes)
00287             {
00288                 if(!inToken)
00289                 {
00290                     if(_str[pos] == '"')
00291                     {
00292                         inQuotes = true;
00293                         oldpos   = pos + 1;
00294                     }
00295                     else if(_str[pos] != ' ')
00296                     {
00297                         inToken = true;
00298                         oldpos  = pos;
00299                     }
00300                 }
00301                 else if(inToken)
00302                 {
00303                     if(_str[pos] == '"')
00304                     {
00305                         inToken = false;
00306 
00307                         strncpy(buf, _str + oldpos, pos - oldpos);
00308 
00309                         buf[pos - oldpos] = '\0';
00310 
00311                         pString =  new IDString(buf);
00312 
00313                         v.push_back(pString);
00314 
00315                         inQuotes = true;
00316                         oldpos   = pos;
00317 
00318                     }
00319                     else if(_str[pos] == ' ')
00320                     {
00321                         inToken = false;
00322 
00323                         strncpy(buf, _str + oldpos, pos - oldpos);
00324 
00325                         buf[pos - oldpos] = '\0';
00326 
00327                         pString =  new IDString(buf);
00328 
00329                         v.push_back(pString);
00330                     }
00331                     else if(pos == l)
00332                     {
00333                         strncpy(buf, _str + oldpos, pos - oldpos);
00334 
00335                         buf[pos - oldpos] = '\0';
00336 
00337                         pString =  new IDString(buf);
00338 
00339                         v.push_back(pString);
00340                     }
00341                 }
00342             }
00343             else if(inQuotes)
00344             {
00345                 if(_str[pos] == '"')
00346                 {
00347                     inQuotes = false;
00348 
00349                     if(pos > oldpos)
00350                     {
00351                         strncpy(buf, _str + oldpos, pos - oldpos);
00352 
00353                         buf[pos - oldpos] = '\0';
00354 
00355                         pString =  new IDString(buf);
00356 
00357                         v.push_back(pString);
00358                     }
00359                 }
00360                 else if(pos == l)
00361                 {
00362                     if(pos > oldpos)
00363                     {
00364                         strncpy(buf, _str + oldpos, pos - oldpos);
00365 
00366                         buf[pos - oldpos] = '\0';
00367 
00368                         pString =  new IDString(buf);
00369 
00370                         v.push_back(pString);
00371                     }
00372                 }
00373             }
00374         }
00375 
00376         delete [] buf;
00377     }
00378 }

bool osg::IDString::operator== const IDString obj  )  const [inline, inherited]
 

Definition at line 62 of file OSGIDString.inl.

References osg::IDString::_str.

00063 {
00064     return ((_str == obj._str) ? 
00065             1 : 
00066             (_str != NULL && obj._str != NULL && !::strcmp(_str, obj._str)));
00067 }

bool osg::IDString::operator!= const IDString obj  )  const [inline, inherited]
 

Definition at line 70 of file OSGIDString.inl.

00071 {
00072     return ! (*this == obj);
00073 }

bool osg::IDString::operator< const IDString obj  )  const [inline, inherited]
 

Definition at line 76 of file OSGIDString.inl.

References osg::IDString::_str.

00077 {
00078     return (    _str != NULL && 
00079             obj._str != NULL && 
00080             (::strcmp(_str, obj._str) < 0));
00081 }

bool osg::IDString::operator> const IDString obj  )  const [inline, inherited]
 

Definition at line 84 of file OSGIDString.inl.

00085 {
00086         return ! (*this < obj) && ! (*this == obj);
00087 }

bool osg::IDString::operator>= const IDString obj  )  const [inline, inherited]
 

Definition at line 90 of file OSGIDString.inl.

00091 {
00092     return ! (*this < obj);
00093 }

bool osg::IDString::operator<= const IDString obj  )  const [inline, inherited]
 

Definition at line 96 of file OSGIDString.inl.

00097 {
00098     return (*this < obj) || (*this == obj);
00099 }


Member Data Documentation

Char8* osg::IDString::_str [protected, inherited]
 

Definition at line 145 of file OSGIDString.h.

Referenced by osg::IDString::getLength(), osg::IDString::IDString(), osg::IDString::isEmpty(), osg::IDString::operator<(), osg::IDString::operator=(), osg::IDString::operator==(), osg::IDString::set(), osg::IDString::setLength(), osg::IDString::str(), osg::IDString::tokenize(), osg::IDString::toLower(), osg::IDString::toUpper(), and osg::IDString::~IDString().

MemType osg::IDString::_memType [protected, inherited]
 

Definition at line 146 of file OSGIDString.h.

Referenced by osg::IDString::set(), osg::IDString::setLength(), and osg::IDString::~IDString().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:34 2005 for OpenSG by  doxygen 1.4.3