VR-Link API Documentation for HLA Evolved
vlString.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 *********************************************************************/
00008 #pragma once
00009 
00010 #include "vlMachineTypes.h"
00011 #include <vector>
00012 #include <iosfwd>
00013 
00014 #ifdef DtUSE_UTILITIES_NAMESPACE
00015 namespace DtUSE_UTILITIES_NAMESPACE
00016 {
00017 #endif
00018 
00019 
00020 
00021 
00026    class DT_DLL_VLUTIL DtString
00027    {
00028       friend DT_DLL_VLUTIL std::ostream& operator<<(std::ostream& os, const DtString& str);
00029       friend DT_DLL_VLUTIL std::istream& operator>>(std::istream& is, DtString& str);
00030    public:
00031 
00033       DtString();
00034 
00036       DtString(const char* str);
00037 
00039       DtString(const char* str,int length);
00040 
00046 
00047       DtString(double val);
00048       DtString(int val);
00049       DtString(long val);
00050       DtString(char val);
00051       DtString(unsigned int val);
00052       DtString(unsigned long val);
00054 
00055 
00057       virtual ~DtString();
00058 
00060       DtString(const DtString& orig);
00061 
00063 
00064       DtString& operator=(const DtString& orig);
00065       DtString& operator=(const char* orig);
00067 
00069       virtual operator const char*() const;
00070 
00072       DtString* clone() const;
00073 
00075 
00076       friend DT_DLL_VLUTIL bool operator==(const DtString& str1, const DtString& str2);
00077       friend DT_DLL_VLUTIL bool operator<(const DtString& str1, const DtString& str2);
00078       friend DT_DLL_VLUTIL bool operator<=(const DtString& str1, const DtString& str2);
00079       friend DT_DLL_VLUTIL bool operator>(const DtString& str1, const DtString& str2);
00080       friend DT_DLL_VLUTIL bool operator>=(const DtString& str1, const DtString& str2);
00081       friend DT_DLL_VLUTIL bool operator!=(const DtString& str1, const DtString& str2);
00082       virtual bool operator==(const char* str) const;
00083       virtual bool operator<(const char* str) const;
00084       virtual bool operator<=(const char* str) const;
00085       virtual bool operator>(const char* str) const;
00086       virtual bool operator>=(const char* str) const;
00087       virtual bool operator!=(const char* str) const;
00089 
00092 
00093       virtual bool caseCompare(const DtString& str) const;
00094       virtual bool caseCompare(const char* str) const;
00096 
00098 
00099       friend DT_DLL_VLUTIL DtString operator+(const DtString& str1, const DtString& str2);
00100       friend DT_DLL_VLUTIL DtString operator+(const char* str1, const DtString& str2);
00101       virtual DtString operator+(const char* str) const;
00102       virtual DtString& operator+=(const char* str);
00103       virtual DtString& operator+=(const DtString& str);
00105 
00107 
00108       virtual const char& operator[](int index) const;
00109       virtual char& operator[](int index);
00111 
00118 
00119       virtual bool snipFront(const char ch, bool toLastCh = false);
00120       virtual bool snipBack(const char ch, bool fromFirstCh = false);
00122 
00124 
00125       virtual bool chompFront();
00126       virtual bool chompBack();
00128 
00129 
00132       virtual void tokenize(const char delimiter, std::vector<DtString>& tokens) const;
00133 
00137       virtual int toInt(bool* ok = 0) const;
00138 
00142       virtual unsigned int toUInt(bool* ok = 0) const;
00143 
00147       virtual float toFloat(bool* ok = 0) const;
00148 
00152       virtual double toDouble(bool* ok = 0) const;
00153 
00157       virtual bool toBoolean(bool* ok = 0) const;
00158 
00160       virtual void toUpper();
00161 
00163       virtual void toLower();
00164 
00168       virtual int findChar(const char ch);
00169 
00173       virtual int findLastChar(const char ch);
00174 
00178       virtual int findString(const DtString& string) const;
00179 
00183       virtual int findLastString(const DtString& string);
00184 
00185       bool snipFrontToLast(const char ch) { return snipFront(ch, true); }
00186       bool snipBackToFirst(const char ch) { return snipBack(ch, true); }
00187 
00189       virtual int count(const char ch) const;
00190 
00193       virtual int length() const;
00194 
00196       virtual int size() const;
00197 
00200       const char* string() const;
00201 
00203       const char* c_str() const;
00204 
00206       bool isEmpty() const;
00207 
00208    public:
00209 
00211       static const DtString& nullString();
00212 
00213    protected:
00214 
00219       void clear();
00220 
00223       void setString(const char* str);
00224 
00225    protected:
00226 
00227       enum { theDefaultBufferSize = 64 };
00228       char myDefaultBuffer[theDefaultBufferSize]; 
00229       char* myString; 
00230 
00231       bool myStringAlloced; 
00232       unsigned int myBufSize;   
00233 
00234       static const int theMaxInsertionStringSize;
00235    };
00236 
00237    inline bool DtString::isEmpty() const
00238    {
00239       return (myString[0] == '\0');
00240    }
00241 
00242 #ifdef DtUSE_UTILITIES_NAMESPACE
00243 } 
00244 #endif
00245 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)