sprint 1-alpha
sprint/container/shared_string.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 *   sprint::shared_string
00003 *
00004 *   Copyright (C) 2005-2011 Paolo Medici <www.pmx.it>
00005 *
00006 *  This library is free software; you can redistribute it and/or
00007 *  modify it under the terms of the GNU Lesser General Public
00008 *  License as published by the Free Software Foundation; either
00009 *  version 2.1 of the License, or (at your option) any later version.
00010 *
00011 *  This library is distributed in the hope that it will be useful,
00012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 *  Lesser General Public License for more details.
00015 *
00016 *  You should have received a copy of the GNU Lesser General Public
00017 *  License along with this library; if not, write to the Free Software
00018 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 *
00020 *******************************************************************************/
00021 
00026 #ifndef _SPRINT_SHARED_STRING_H
00027 #define _SPRINT_SHARED_STRING_H
00028 
00029 #include <sprint/container/shared_vector.h>
00030 
00031 namespace sprint {
00032 
00040 class shared_string: public shared_vector<char> {
00041    
00042     public:
00043   
00044     shared_string() { }
00045     shared_string(unsigned int capacity) : shared_vector(capacity) { }
00046     shared_string(const char *str);
00047     shared_string(const shared_string &src) : shared_vector<char>(src) { }
00048     
00049     ~shared_string() { }
00050         
00051     void insert(const char *str);
00052     void insert(const shared_string &src);
00053 
00054     shared_string & operator =(const char *str);
00055     shared_string & operator =(const shared_string &src);
00056     
00057     shared_string & operator += (const char *str);
00058     shared_string & operator += (const shared_string &src);    
00059     
00061     const char *c_str() const { return m_data; }
00062 
00064     unsigned int lenght() const { return this->size()-1; }
00065 
00067     unsigned int capacity() const { return this->capacity(); }          
00068 };
00069 
00070 }
00071 
00072 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines