Home | Hierarchy | Members | Alphabetical | Related Pages |
00001 #ifndef XDKWRL_SFSTRING_H 00002 #define XDKWRL_SFSTRING_H 00003 00004 #include <xdkwrl/fieldtypes.h> 00005 #include <iostream> 00006 #include <string> 00007 00008 namespace wrl 00009 { 00010 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00011 // Interface of SFString 00012 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00013 /*! \ingroup fieldtypes 00014 * 00015 * Represents a string value. Below is included the documentation for this 00016 * field type from the ISO standard. 00017 * \htmlinclude sfstring.html 00018 */ 00019 class SFString 00020 { 00021 public: 00022 inline SFString(); 00023 inline SFString(const char* c); 00024 inline SFString(const std::string& s); 00025 inline SFString& operator=(const char* b); 00026 inline SFString& operator=(const std::string& b); 00027 inline SFString& operator=(const SFString& b); 00028 inline operator const char*() const; 00029 inline operator std::string() const; 00030 static inline const char* typeName(); 00031 static inline FieldTypeId typeId(); 00032 inline bool operator==(const SFString& s) const; 00033 friend std::ostream& operator<<(std::ostream& s,const SFString& f); 00034 protected: 00035 private: 00036 std::string value_; 00037 }; 00038 //************************************************************ 00039 // Implementation of SFString 00040 //************************************************************ 00041 inline 00042 SFString::SFString() 00043 : value_() 00044 { 00045 } 00046 inline 00047 SFString::SFString(const char* c) 00048 : value_(c) 00049 { 00050 } 00051 inline 00052 SFString::SFString(const std::string& s) 00053 : value_(s) 00054 { 00055 } 00056 inline SFString& 00057 SFString::operator=(const char* b) 00058 { 00059 value_ = b; 00060 return *this; 00061 } 00062 inline SFString& 00063 SFString::operator=(const std::string& b) 00064 { 00065 value_ = b; 00066 return *this; 00067 } 00068 inline SFString& 00069 SFString::operator=(const SFString& b) 00070 { 00071 value_ = b.value_; 00072 return *this; 00073 } 00074 inline 00075 SFString::operator const char*() const 00076 { 00077 return value_.c_str(); 00078 } 00079 inline 00080 SFString::operator std::string() const 00081 { 00082 return value_; 00083 } 00084 inline const char* 00085 SFString::typeName() 00086 { 00087 return "SFString"; 00088 } 00089 inline FieldTypeId 00090 SFString::typeId() 00091 { 00092 return sfString; 00093 } 00094 inline bool 00095 SFString::operator==(const SFString& s) const 00096 { 00097 return value_ == s.value_; 00098 } 00099 inline std::ostream& operator<<(std::ostream& s,const SFString& f) 00100 { 00101 s<<'"'; 00102 for (std::string::const_iterator iter = f.value_.begin(); 00103 iter != f.value_.end();++iter) 00104 { 00105 if (*iter == '"') 00106 { 00107 s<<"\\\""; 00108 } 00109 else 00110 { 00111 s<<*iter; 00112 } 00113 } 00114 return s<<'"'; 00115 } 00116 }; 00117 00118 #endif // XDKWRL_SFSTRING_H
Generated on 28 Jun 2006 with
![]() |
|