Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

sstring.cpp

Go to the documentation of this file.
00001 // +-------------------------------------------------------------------------+
00002 // |               I__n__t__e__L__i__b           0.6.10 development          |
00003 // | Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2000-2007. |
00004 // |                                                                         |
00005 // | This is free software. The library part is available under              |
00006 // |                               GNU LESSER GENERAL PUBLIC LICENSE v.2.1.  |
00007 // | GNU LGPL v2.1 is found in docs/gnu_gpl2.txt,  or at  http://www.gnu.org |
00008 // |     Please see also docs/readme.txt and visit http://www.intelib.org    |
00009 // |                                                                         |
00010 // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! |
00011 // +-------------------------------------------------------------------------+
00012 
00013 
00014 
00015 
00016 #include <string.h>
00017 #include "iexcept.hpp"
00018 #include "sstring.hpp"
00019 
00021 // SString
00022 
00023 #if 0
00024 SString::SString(const SReference &ref)
00025     : SReference(ref)
00026 {
00027     if(!ref.GetPtr() || 
00028         !ref->TermType().IsSubtypeOf(SExpressionString::TypeId)) 
00029     {
00030         throw IntelibX_not_a_string(ref);
00031     }
00032 }
00033 SString& SString::operator=(const SString &s)
00034 {
00035     this->SReference::operator=(s);
00036     return *this;
00037 }
00038 #endif
00039 
00040 SString& SString::operator=(const char *s)
00041 {
00042     this->SReference::operator=(SReference(s));
00043     //this->SReference::operator=(new SExpressionString(s));
00044     return *this;
00045 }
00046 
00047 SString SString::operator+(const SString &other) const
00048 {
00049     return SString(new SExpressionString(c_str(), other.c_str()));
00050 }
00051 
00052 void SString::operator+=(const SString &other)
00053 {
00054     this->operator=(new SExpressionString(c_str(), other.c_str()));
00055 }
00056 
00057 SString SString::operator+(const char *s) const
00058 {
00059     return SString(new SExpressionString(c_str(), s));
00060 }
00061 
00062 void SString::operator+=(const char *s)
00063 {
00064     this->operator=(new SExpressionString(c_str(), s));
00065 }
00066 
00067 void SString::operator+=(const char c)
00068 {
00069     char buf[2]; 
00070     buf[0] = c; buf[1] = 0;
00071     this->operator=(new SExpressionString(c_str(), buf));
00072 }
00073 
00074 const char* SString::c_str() const
00075 {
00076     return (static_cast<const SExpressionString*>(GetPtr()))->GetValue();
00077 }
00078 
00079 bool SString::operator==(const SString &other) const
00080 {
00081     return 0 == strcmp(c_str(), other.c_str());
00082 }
00083 
00084 bool SString::operator!=(const SString &other) const
00085 {
00086     return !(*this == other);
00087 }
00088 
00089 unsigned int SString::length() const
00090 {
00091     return strlen(c_str());
00092 }

Generated on Tue Dec 18 00:39:46 2007 for InteLib by  doxygen 1.4.1