cocos2d-x  3.0-alpha0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
String Class Reference

#include <CCString.h>

Inheritance diagram for String:
Object Clonable

Public Member Functions

 String ()
 String (const char *str)
 String (const std::string &str)
 String (const String &str)
virtual ~String ()
Stringoperator= (const String &other)
bool initWithFormat (const char *format,...) CC_FORMAT_PRINTF(2
 init a string with format, it's similar with the c function 'sprintf' More...
 
bool int intValue () const
 convert to int value More...
 
unsigned int uintValue () const
 convert to unsigned int value More...
 
local uintValue ()
 convert to unsigned int value More...
 
float floatValue () const
 convert to float value More...
 
double doubleValue () const
 convert to double value More...
 
bool boolValue () const
 convert to bool value More...
 
const char * getCString () const
 get the C string More...
 
local getCString ()
 get the C string More...
 
unsigned int length () const
 get the length of string More...
 
local length ()
 get the length of string More...
 
int compare (const char *) const
 compare to a c string More...
 
void append (const std::string &str)
 append additional characters at the end of its current value More...
 
void appendWithFormat (const char *format,...)
 append(w/ format) additional characters at the end of its current value More...
 
ArraycomponentsSeparatedByString (const char *delimiter)
 split a string More...
 
virtual bool isEqual (const Object *pObject)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)
virtual Stringclone () const
 returns a copy of the object More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual void update (float dt)
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
CC_DEPRECATED_ATTRIBUTE Objectcopy () const
 returns a copy of the object. More...
 
local copy ()
 returns a copy of the object. More...
 

Static Public Member Functions

static Stringcreate (const std::string &str)
 create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer. More...
 
local create ( local str)
 create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer. More...
 
static StringcreateWithFormat (const char *format,...) CC_FORMAT_PRINTF(1
 create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, if you want to change it, you should modify the kMaxStringLen macro in String.cpp file. More...
 
static String static StringcreateWithData (const unsigned char *pData, unsigned long nLen)
 create a string with binary data More...
 
static StringcreateWithContentsOfFile (const char *filename)
 create a string with a file, More...
 

Public Attributes

std::string _string
- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
var _reference
 count of references More...
 
local _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 
var _autoReleaseCount
 count of autorelease More...
 
local _autoReleaseCount
 count of autorelease More...
 

Constructor & Destructor Documentation

String ( )
String ( const char *  str)
String ( const std::string &  str)
String ( const String str)
virtual ~String ( )
virtual

Member Function Documentation

virtual void acceptVisitor ( DataVisitor visitor)
virtual

Reimplemented from Object.

void append ( const std::string &  str)

append additional characters at the end of its current value

void appendWithFormat ( const char *  format,
  ... 
)

append(w/ format) additional characters at the end of its current value

bool boolValue ( ) const

convert to bool value

local boolValue ( )

convert to bool value

virtual String* clone ( ) const
virtual

returns a copy of the object

Implements Clonable.

int compare ( const char *  ) const

compare to a c string

local compare ( local  )

compare to a c string

Array* componentsSeparatedByString ( const char *  delimiter)

split a string

static String* create ( const std::string &  str)
static

create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer.

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
local create ( local  str)
static

create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer.

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
static String*
createWithContentsOfFile
( const char *  filename)
static

create a string with a file,

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
local createWithContentsOfFile ( local  filename)
static

create a string with a file,

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
static String static String*
createWithData
( const unsigned char *  pData,
unsigned long  nLen 
)
static

create a string with binary data

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
local createWithData ( local  pData,
local  nLen 
)
static

create a string with binary data

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
static String* createWithFormat ( const char *  format,
  ... 
)
static

create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, if you want to change it, you should modify the kMaxStringLen macro in String.cpp file.

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
local createWithFormat ( local  format,
  ... 
)
static

create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, if you want to change it, you should modify the kMaxStringLen macro in String.cpp file.

Returns
A String pointer which is an autorelease object pointer, it means that you needn't do a release operation unless you retain it.
double doubleValue ( ) const

convert to double value

local doubleValue ( )

convert to double value

float floatValue ( ) const

convert to float value

local floatValue ( )

convert to float value

const char* getCString ( ) const

get the C string

local getCString ( )

get the C string

bool initWithFormat ( const char *  format,
  ... 
)

init a string with format, it's similar with the c function 'sprintf'

bool int intValue ( ) const

convert to int value

local intValue ( )

convert to int value

virtual bool isEqual ( const Object object)
virtual

Returns a boolean value that indicates whether this object and a given object are equal.

Parameters
objectThe object to be compared to this object.
Returns
True if this object and object are equal, otherwise false.

Reimplemented from Object.

var isEqual ( var  object)
virtual

Returns a boolean value that indicates whether this object and a given object are equal.

Parameters
objectThe object to be compared to this object.
Returns
True if this object and object are equal, otherwise false.

Reimplemented from Object.

local isEqual ( local  object)
virtual

Returns a boolean value that indicates whether this object and a given object are equal.

Parameters
objectThe object to be compared to this object.
Returns
True if this object and object are equal, otherwise false.

Reimplemented from Object.

unsigned int length ( ) const

get the length of string

local length ( )

get the length of string

String& operator= ( const String other)
String& operator= ( var  other)
String& operator= ( local  other)
unsigned int uintValue ( ) const

convert to unsigned int value

local uintValue ( )

convert to unsigned int value

Member Data Documentation

std::string _string

The documentation for this class was generated from the following file: