00001
#ifndef ESTRING_H
00002
#define ESTRING_H
00003
00004
#include "common.h"
00005
#include "EStringPool.h"
00006
00007
00008
BOREALIS_NAMESPACE_BEGIN
00009
00010
00016 class EString
00017 {
00018
public:
00020 EString() : _data(
"" ), _length( 0 ) {}
00021
00025 EString(
const char *data,
unsigned int length ) :
00026 _data( data ), _length( length ) {}
00027
00031 explicit EString(
const string &str ) :
00032 _data( str.
data() ), _length( str.
length() ) {}
00033
00035 const char *
data() {
return( _data ); }
00036
00038 unsigned int length() {
return( _length ); }
00039
00042 string
as_string()
const
00043
{
return( _length ? string(_data, _length) : string()); }
00044
00049
int compare(
const EString &other );
00050
00055
EString concat(
const EString &other,
EStringPool &pool );
00056
00060
static EString save(
const string &str,
EStringPool &pool );
00061
00065
EString save(
EStringPool &pool );
00066
00068
char operator[] (
unsigned int index )
const;
00069
00071 bool operator == (
const EString &other )
00072 {
return(
compare( other ) == 0); }
00073
00075 bool operator != (
const EString &other )
00076 {
return(
compare( other ) != 0 ); }
00077
00080 bool operator < (
const EString &other )
00081 {
return(
compare( other ) < 0 ); }
00082
00085 bool operator > (
const EString &other )
00086 {
return(
compare( other ) > 0 ); }
00087
00090 bool operator <= (
const EString &other )
00091 {
return(
compare( other ) <= 0 ); }
00092
00095 bool operator >= (
const EString &other )
00096 {
return(
compare( other ) >= 0 ); }
00097
00101
static EString coerce(
bool b,
EStringPool &pool );
00102
00106
static EString coerce( int32 i,
EStringPool &pool );
00107
00111
static EString coerce( int64 i,
EStringPool &pool );
00112
00116
static EString coerce( single f,
EStringPool &pool );
00117
00121
static EString coerce(
double f,
EStringPool &pool );
00122
00123
private:
00124
const char *_data;
00125
unsigned int _length;
00126 };
00127
00128
BOREALIS_NAMESPACE_END
00129
#endif // ESTRING_H