2012-02-14 19:31:25 +01:00
|
|
|
/**
|
|
|
|
*******************************************************************************
|
|
|
|
* @file etk/String.h
|
|
|
|
* @brief Ewol Tool Kit : normal sting management... (header)
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @date 26/01/2011
|
|
|
|
* @par Project
|
|
|
|
* Ewol TK
|
|
|
|
*
|
|
|
|
* @par Copyright
|
|
|
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY.
|
|
|
|
*
|
|
|
|
* Licence summary :
|
|
|
|
* You can modify and redistribute the sources code and binaries.
|
|
|
|
* You can send me the bug-fix
|
|
|
|
*
|
|
|
|
* Term of the licence in in the file licence.txt.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ETK_USTRING_H__
|
|
|
|
#define __ETK_USTRING_H__
|
|
|
|
|
|
|
|
#include <etk/Stream.h>
|
2012-08-14 16:12:03 +02:00
|
|
|
#include <etk/Vector.h>
|
2012-02-14 19:31:25 +01:00
|
|
|
|
|
|
|
namespace etk
|
|
|
|
{
|
|
|
|
class UString
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructeurs
|
|
|
|
UString(void);
|
|
|
|
UString(const uniChar_t* inputData, int32_t len = -1);
|
|
|
|
UString(const char* inputData, int32_t len = -1);
|
|
|
|
void Set(const uniChar_t* inputData, int32_t len=-1);
|
|
|
|
void Set(const char* inputData, int32_t len=-1);
|
|
|
|
// basic convertion integer en string
|
2012-02-16 14:02:36 +01:00
|
|
|
UString(char inputData);
|
2012-02-14 19:31:25 +01:00
|
|
|
UString(int inputData);
|
|
|
|
UString(unsigned int inputData);
|
2012-04-15 21:36:07 +02:00
|
|
|
UString(float inputData);
|
|
|
|
UString(double inputData);
|
2012-02-14 19:31:25 +01:00
|
|
|
UString(const etk::UString &etkS);
|
2012-05-11 17:35:48 +02:00
|
|
|
//UString(const uniChar_t inputData);
|
2012-02-14 19:31:25 +01:00
|
|
|
// destructor :
|
|
|
|
~UString(void);
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* = assigment
|
|
|
|
*****************************************************/
|
|
|
|
const etk::UString& operator= (const etk::UString &etkS );
|
2012-08-14 16:12:03 +02:00
|
|
|
const etk::UString& operator= (etk::Vector<char> inputData);
|
|
|
|
const etk::UString& operator= (etk::Vector<int8_t> inputData);
|
|
|
|
const etk::UString& operator= (etk::Vector<uniChar_t> inputData);
|
2012-02-14 19:31:25 +01:00
|
|
|
/*****************************************************
|
|
|
|
* == operator
|
|
|
|
*****************************************************/
|
|
|
|
bool operator== (const etk::UString& etkS) const;
|
|
|
|
/*****************************************************
|
|
|
|
* != operator
|
|
|
|
*****************************************************/
|
|
|
|
bool operator!= (const etk::UString& etkS) const;
|
2012-02-15 23:08:34 +01:00
|
|
|
/*****************************************************
|
2012-02-16 10:07:47 +01:00
|
|
|
* > < >= <= operator
|
2012-02-15 23:08:34 +01:00
|
|
|
*****************************************************/
|
2012-02-16 10:07:47 +01:00
|
|
|
bool operator> (const etk::UString& etkS) const;
|
|
|
|
bool operator>= (const etk::UString& etkS) const;
|
|
|
|
bool operator< (const etk::UString& etkS) const;
|
|
|
|
bool operator<= (const etk::UString& etkS) const;
|
2012-02-14 19:31:25 +01:00
|
|
|
/*****************************************************
|
|
|
|
* += operator
|
|
|
|
*****************************************************/
|
|
|
|
const etk::UString& operator+= (const etk::UString &etkS);
|
|
|
|
/*****************************************************
|
|
|
|
* + operator
|
|
|
|
*****************************************************/
|
|
|
|
etk::UString operator+ (const etk::UString &etkS);
|
|
|
|
/*****************************************************
|
2012-02-15 16:24:06 +01:00
|
|
|
* << operator
|
|
|
|
*****************************************************/
|
|
|
|
/*
|
|
|
|
const etk::UString& operator <<= (const char input);
|
|
|
|
const etk::UString& operator <<= (const int input);
|
|
|
|
const etk::UString& operator <<= (const unsigned int input);
|
|
|
|
*/
|
|
|
|
/*****************************************************
|
|
|
|
* >> operator
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* Cout << operator
|
2012-02-14 19:31:25 +01:00
|
|
|
*****************************************************/
|
|
|
|
friend etk::CCout& operator <<( etk::CCout &os,const etk::UString &obj);
|
2012-02-15 16:24:06 +01:00
|
|
|
/*****************************************************
|
|
|
|
* [] operator
|
|
|
|
*****************************************************/
|
|
|
|
const uniChar_t& operator[] (int32_t pos) const {
|
|
|
|
return m_data[pos];
|
|
|
|
}
|
|
|
|
uniChar_t& operator[] (int32_t pos) {
|
|
|
|
return m_data[pos];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* toolbox
|
|
|
|
*****************************************************/
|
|
|
|
// Start With ...
|
|
|
|
bool StartWith(const etk::UString& data);
|
|
|
|
// End With ...
|
|
|
|
bool EndWith(const etk::UString& data);
|
|
|
|
// Find element
|
|
|
|
int32_t FindForward(const char data, int32_t startPos=0);
|
|
|
|
int32_t FindForward(const uniChar_t data, int32_t startPos=0);
|
2012-08-14 16:12:03 +02:00
|
|
|
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF);
|
|
|
|
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF);
|
2012-02-15 16:24:06 +01:00
|
|
|
|
2012-02-14 19:31:25 +01:00
|
|
|
bool IsEmpty(void) const;
|
|
|
|
int32_t Size(void) const;
|
2012-02-15 16:24:06 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* Generic modification function
|
|
|
|
*****************************************************/
|
2012-02-14 19:31:25 +01:00
|
|
|
void Add(int32_t currentID, const char* inputData);
|
|
|
|
void Add(int32_t currentID, const uniChar_t* inputData);
|
2012-05-11 17:35:48 +02:00
|
|
|
void Add(int32_t currentID, const uniChar_t inputData);
|
2012-02-14 19:31:25 +01:00
|
|
|
void Remove(int32_t currentID, int32_t len);
|
|
|
|
void Clear(void);
|
2012-02-15 16:24:06 +01:00
|
|
|
|
2012-08-14 16:12:03 +02:00
|
|
|
etk::Vector<uniChar_t> GetVector(void);
|
|
|
|
uniChar_t * pointer(void) { return &m_data[0]; };
|
2012-02-15 16:24:06 +01:00
|
|
|
// generate temporary allocation (auto unallocated...)
|
2012-08-14 16:12:03 +02:00
|
|
|
char * c_str(void);
|
2012-02-15 16:24:06 +01:00
|
|
|
|
2012-02-14 19:31:25 +01:00
|
|
|
// Sting operation :
|
|
|
|
etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF);
|
|
|
|
|
|
|
|
private :
|
2012-08-14 16:12:03 +02:00
|
|
|
etk::Vector<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
|
|
|
|
etk::Vector<char> m_dataUtf8; //!< Tmp data for the Utf8Data() function
|
2012-02-14 19:31:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
etk::CCout& operator <<(etk::CCout &os, const etk::UString &obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t strlen(const uniChar_t * data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|