86 lines
2.8 KiB
C++
86 lines
2.8 KiB
C++
#ifndef _CSTRING_HPP_
|
|
#define _CSTRING_HPP_
|
|
|
|
/*** C++ STL Files ***/
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
/*** SDL Header Files ***/
|
|
#include <SDL.h>
|
|
|
|
/*** DLL Header File ***/
|
|
#include "dllExport.h"
|
|
|
|
/*#pragma warning (disable : 4231)*/
|
|
EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator<char>;
|
|
EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::basic_string<char>;
|
|
/*#pragma warning (default : 4231)*/
|
|
|
|
#define __cString__MAX_LEN 65535
|
|
|
|
namespace UtilityEngine {
|
|
class EXPORT_FROM_MYDLL cString
|
|
{
|
|
public:
|
|
cString(); /// default constructor
|
|
cString(const char* s);
|
|
cString(const cString& copy); /// copy constructor
|
|
~cString();
|
|
|
|
const char* alloc_str(size_t sz); /// smart alloc string
|
|
void clear(); /// frees the string
|
|
const char* c_str() const; /// getter
|
|
const char* copy_str(const char* copy); /// alloc & copy
|
|
|
|
/// utility methods
|
|
bool have_value() const;
|
|
size_t length() const;
|
|
size_t size() const;
|
|
cString& format(const char* format, ...);
|
|
cString& trim();
|
|
cString lower() const;
|
|
cString upper() const;
|
|
const char& first_char() const;
|
|
const char& last_char() const;
|
|
const std::vector<cString> split(const char match) const;
|
|
const std::vector<cString> split(const char* match) const;
|
|
const std::vector<cString> split(const char* match, int max_split) const;
|
|
long int char_find(const char& match) const;
|
|
const cString& char_repl(const char& match, const char& repl);
|
|
cString substr(size_t start, size_t length) const;
|
|
long int find(const cString& match);
|
|
const cString replace(const cString& match, const cString& repl);
|
|
|
|
const bool IsInt() const;
|
|
const long int ToInt() const;
|
|
|
|
/// operators
|
|
cString& operator = (const char* rhs); /// assignment operator
|
|
cString& operator = (const cString& rhs); /// assignment operator
|
|
cString& operator += (const char rhs);
|
|
cString& operator += (const char* rhs); /// concatenation operator
|
|
cString& operator += (const cString& rhs); /// concatenation operator
|
|
|
|
bool operator == (const char* rhs) const; /// comparisons
|
|
bool operator == (const cString& rhs) const;
|
|
bool operator != (const char* rhs) const;
|
|
bool operator != (const cString& rhs) const;
|
|
bool operator > (const cString& rhs) const;
|
|
bool operator < (const cString& rhs) const;
|
|
bool operator >= (const cString& rhs) const;
|
|
bool operator <= (const cString& rhs) const;
|
|
|
|
/// conversion operators
|
|
operator const char* () const; /// c-string type
|
|
operator std::string () const; /// c++ string class
|
|
|
|
private:
|
|
char* mp_str = nullptr;
|
|
size_t m_len = 0;
|
|
|
|
};/// END CLASS DEFINITION cString
|
|
}/// END NAMESPACE DEFINITION UtilityEngine
|
|
/// function overloads
|
|
UtilityEngine::cString operator + (const UtilityEngine::cString& lhs, const UtilityEngine::cString& rhs);
|
|
#endif/// END IFNDEF _CSTRING_HPP_
|