2013-05-18 17:44:15 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* String.h *
|
|
|
|
* *
|
|
|
|
* XFX String definition file *
|
|
|
|
* Copyright (c) XFX Team. All Rights Reserved *
|
|
|
|
*****************************************************************************/
|
2013-05-05 18:18:41 +02:00
|
|
|
#ifndef _SYSTEM_STRING_
|
|
|
|
#define _SYSTEM_STRING_
|
|
|
|
|
|
|
|
#include "Enums.h"
|
|
|
|
#include "Interfaces.h"
|
|
|
|
#include "Object.h"
|
2013-05-18 17:44:15 +02:00
|
|
|
#include "Types.h"
|
2013-05-05 18:18:41 +02:00
|
|
|
|
|
|
|
namespace System
|
|
|
|
{
|
2013-07-12 21:30:13 +02:00
|
|
|
/**
|
|
|
|
* Represents text as a series of ASCII characters.
|
|
|
|
*/
|
2013-05-05 18:18:41 +02:00
|
|
|
class String : public IComparable<String>, public IEquatable<String>, public Object
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
char* internalString;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const int Length;
|
|
|
|
static const String Empty;
|
|
|
|
|
|
|
|
String();
|
|
|
|
String(char c, int count);
|
|
|
|
String(char value[], int startIndex, int length); //Note: can also be used as String(char *value, int startIndex, int length);
|
|
|
|
String(const String &obj); // Copy constructor
|
|
|
|
String(const char* obj);
|
|
|
|
virtual ~String();
|
|
|
|
|
|
|
|
String Clone() const;
|
|
|
|
static int Compare(const String strA, const String strB);
|
|
|
|
int CompareTo(const String other) const;
|
|
|
|
static String Concat(const String values[], const int stringCount);
|
|
|
|
static char* Concat(char* values[]);
|
|
|
|
static char* Concat(char* str1, char* str2, char* str3, char* str4);
|
|
|
|
static String Concat(String str1, String str2, String str3, String str4);
|
|
|
|
bool Contains(char* value) const;
|
|
|
|
bool EndsWith(const String value) const;
|
|
|
|
bool Equals(Object const * const obj) const;
|
|
|
|
bool Equals(const String obj) const;
|
|
|
|
bool Equals(const String& str1, const String& str2);
|
2013-05-18 17:44:15 +02:00
|
|
|
static const char* Format(const char* format, ...) FORMAT(printf, 1, 2);
|
2013-05-05 18:18:41 +02:00
|
|
|
int GetHashCode() const;
|
2013-07-12 21:30:13 +02:00
|
|
|
static const Type& GetType();
|
2013-05-05 18:18:41 +02:00
|
|
|
int IndexOf(char value) const;
|
|
|
|
int IndexOf(char value, int startIndex) const;
|
|
|
|
int IndexOf(char value, int startIndex, int count) const;
|
|
|
|
int IndexOfAny(char anyOf[], int charCount) const;
|
|
|
|
int IndexOfAny(char anyOf[], int charCount, int startIndex) const;
|
|
|
|
int IndexOfAny(char anyOf[], int charCount, int startIndex, int count) const;
|
|
|
|
static bool IsNullOrEmpty(const String& value);
|
|
|
|
static bool IsNullOrEmpty(const char* value);
|
|
|
|
static String Join(String separator, String value[]);
|
|
|
|
static String Join(String separator, String value[], int startIndex, int count);
|
|
|
|
String PadLeft(int totalWidth);
|
|
|
|
String PadLeft(int totalWidth, char paddingChar);
|
|
|
|
String PadRight(int totalWidth);
|
|
|
|
String PadRight(int totalWidth, char paddingChar);
|
|
|
|
String Replace(char oldChar, char newChar);
|
|
|
|
String Replace(char* oldValue, char* newValue);
|
|
|
|
char** Split(const String& separator, int count, StringSplitOptions_t options) const;
|
|
|
|
char** Split(const String& separator, StringSplitOptions_t options) const;
|
|
|
|
char** Split(char separator[], int count, StringSplitOptions_t options) const;
|
|
|
|
char** Split(char separator[], StringSplitOptions_t options) const;
|
|
|
|
char** Split(char separator[], int count) const;
|
|
|
|
char** Split(char separator[]) const;
|
|
|
|
bool StartsWith(const String value) const;
|
|
|
|
char* SubString(int startIndex) const;
|
|
|
|
String SubString(int startIndex, int length) const;
|
|
|
|
char* ToCharArray(int startIndex, int length) const;
|
|
|
|
char* ToCharArray() const;
|
|
|
|
String ToLower() const;
|
|
|
|
static const char* ToLower(const char* str);
|
2013-07-11 20:00:07 +02:00
|
|
|
const String ToString() const;
|
2013-05-05 18:18:41 +02:00
|
|
|
String ToUpper() const;
|
|
|
|
static const char* ToUpper(const char* str);
|
|
|
|
|
|
|
|
operator const char*() const;
|
|
|
|
bool operator!=(const String& right) const;
|
|
|
|
bool operator!=(const char* right) const;
|
|
|
|
bool operator==(const String& right) const;
|
|
|
|
bool operator==(const char* right) const;
|
|
|
|
String& operator=(const String& right);
|
|
|
|
String operator+(const char* right) const;
|
|
|
|
String operator+=(const String& right);
|
|
|
|
String operator+=(const char* right);
|
|
|
|
String operator+(const String& right) const;
|
2014-07-22 17:02:45 +02:00
|
|
|
const char& operator[](const int index) const;
|
2013-05-05 18:18:41 +02:00
|
|
|
};
|
|
|
|
|
2013-07-11 20:00:07 +02:00
|
|
|
inline const String operator +(const char * left, const String& right)
|
2013-06-02 14:32:43 +02:00
|
|
|
{
|
|
|
|
return String(left) + right;
|
|
|
|
}
|
|
|
|
|
2013-05-05 18:18:41 +02:00
|
|
|
typedef String string;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //_SYSTEM_STRING_
|