16 #ifndef __OMNETPP_OPP_STRING_H 17 #define __OMNETPP_OPP_STRING_H 22 #include "simkerneldefs.h" 58 opp_string(
const char *s,
int n) {buf =
new char[n+1]; strncpy(buf, s?s:
"", n); buf[n] =
'\0';}
78 const char *
c_str()
const {
return buf ? buf :
"";}
83 std::string
str()
const {
return buf ? buf :
"";}
88 bool empty()
const {
return !buf || !buf[0];}
100 int size()
const {
return buf ? strlen(buf) : 0;}
105 char *
reserve(
unsigned size) {
delete[] buf;buf=
new char[size];
return buf;}
170 inline std::ostream& operator<<(std::ostream& out,
const opp_string& s)
172 out << s.
c_str();
return out;
Lightweight string class, used internally in some parts of OMNeT++.
Definition: opp_string.h:39
opp_string()
Definition: opp_string.h:48
opp_string(const std::string &s)
Definition: opp_string.h:63
const char * operator=(const char *s)
Definition: opp_string.h:111
opp_string & operator+=(const std::string &s)
Definition: opp_string.h:151
std::string str() const
Definition: opp_string.h:83
opp_string & operator=(const std::string &s)
Definition: opp_string.h:121
opp_string(const char *s)
Definition: opp_string.h:53
opp_string(const char *s, int n)
Definition: opp_string.h:58
char * opp_strdup(const char *)
Duplicates the string, using new char[]. For nullptr and empty strings it returns nullptr...
Definition: simutil.h:290
opp_string & operator=(const opp_string &s)
Definition: opp_string.h:116
int size() const
Definition: opp_string.h:100
bool operator<(const opp_string &s) const
Definition: opp_string.h:126
Lightweight string-to-string map, used internally in some parts of OMNeT++.
Definition: opp_string.h:200
opp_string operator+(const char *s)
Definition: opp_string.h:156
char * buffer()
Definition: opp_string.h:95
bool operator!=(const opp_string &s) const
Definition: opp_string.h:136
opp_string(const opp_string &s)
Definition: opp_string.h:68
opp_string & operator+=(const opp_string &s)
Definition: opp_string.h:146
char * reserve(unsigned size)
Definition: opp_string.h:105
opp_string operator+(const std::string &s)
Definition: opp_string.h:166
const char * c_str() const
Definition: opp_string.h:78
bool operator==(const opp_string &s) const
Definition: opp_string.h:131
Definition: cabstracthistogram.h:21
opp_string operator+(const opp_string &s)
Definition: opp_string.h:161
int opp_strcmp(const char *, const char *)
Same as the standard strcmp() function, except that nullptr is treated exactly as an empty string (""...
Definition: simutil.h:307
opp_string & operator+=(const char *s)
Definition: opp_string.h:141
Lightweight string vector, used internally in some parts of OMNeT++.
Definition: opp_string.h:184
bool empty() const
Definition: opp_string.h:88
~opp_string()
Definition: opp_string.h:73