00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __OPP_STRING_H
00019 #define __OPP_STRING_H
00020
00021 #include <ostream>
00022 #include "defs.h"
00023 #include "util.h"
00024
00036 class SIM_API opp_string
00037 {
00038 private:
00039 char *str;
00040
00041 public:
00045 opp_string() {str = 0;}
00046
00050 opp_string(const char *s) {str = opp_strdup(s);}
00051
00055 opp_string(const opp_string& s) {str = opp_strdup(s.str);}
00056
00060 ~opp_string() {delete[] str;}
00061
00065 const char *c_str() const {return str ? str : "";}
00066
00070 bool empty() const {return !str || !str[0];}
00071
00077 char *buffer() {return str;}
00078
00082 char *reserve(unsigned size)
00083 {delete[] str;str=new char[size];return str;}
00084
00089 const char *operator=(const char *s)
00090 {delete[] str;str=opp_strdup(s);return str;}
00091
00095 opp_string& operator=(const opp_string& s)
00096 {delete[] str;str=opp_strdup(s.str);return *this;}
00097
00098 };
00099
00100 inline std::ostream& operator<<(std::ostream& out, const opp_string& s)
00101 {
00102 out << s.c_str(); return out;
00103 }
00104
00105 #endif
00106
00107