| 8 | 
           cycrow | 
           1 | 
           #pragma once
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           #include <string>
  | 
        
        
            | 
            | 
           4 | 
           #include "../spkdll.h"
  | 
        
        
            | 
            | 
           5 | 
              | 
        
        
            | 
            | 
           6 | 
           namespace Utils {
  | 
        
        
            | 
            | 
           7 | 
           /**
  | 
        
        
            | 
            | 
           8 | 
            * String wrapper class
  | 
        
        
            | 
            | 
           9 | 
            */
  | 
        
        
            | 
            | 
           10 | 
           class SPKEXPORT String : public std::string
  | 
        
        
            | 
            | 
           11 | 
           {
  | 
        
        
            | 
            | 
           12 | 
           public:
  | 
        
        
            | 
            | 
           13 | 
           	// constructors
  | 
        
        
            | 
            | 
           14 | 
           	String(void);
  | 
        
        
            | 
            | 
           15 | 
           	String(const char *str);
  | 
        
        
            | 
            | 
           16 | 
           	String(const unsigned char *str);
  | 
        
        
            | 
            | 
           17 | 
           	String(const std::string &str);
  | 
        
        
            | 
            | 
           18 | 
           	String(const unsigned char c);
  | 
        
        
            | 
            | 
           19 | 
           	String(const String &str);
  | 
        
        
            | 
            | 
           20 | 
           	String(long l);
  | 
        
        
            | 
            | 
           21 | 
           	String(unsigned long l);
  | 
        
        
            | 
            | 
           22 | 
           	String(float f);
  | 
        
        
            | 
            | 
           23 | 
           	String(double f);
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           	virtual ~String(void);
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           	// conversion functions
  | 
        
        
            | 
            | 
           28 | 
           	void fromLong(long l);
  | 
        
        
            | 
            | 
           29 | 
           	void fromFloat(float f);
  | 
        
        
            | 
            | 
           30 | 
           	void fromFloat(float f, int dp);
  | 
        
        
            | 
            | 
           31 | 
           	void fromDouble(double f);
  | 
        
        
            | 
            | 
           32 | 
           	void fromDouble(double f, int dp);
  | 
        
        
            | 
            | 
           33 | 
           	const String &format(const char *sFormat, ...);
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           	static String fromFormat(const char *sFormat, ...);
  | 
        
        
            | 
            | 
           36 | 
           	long toLong() const;
  | 
        
        
            | 
            | 
           37 | 
           	double toDouble() const;
  | 
        
        
            | 
            | 
           38 | 
           	float toFloat() const;
  | 
        
        
            | 
            | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
           	// casting operators
  | 
        
        
            | 
            | 
           41 | 
           	inline operator const char *() const			{ return (const char *)this->c_str(); }
  | 
        
        
            | 
            | 
           42 | 
           	inline operator char *() const					{ return (char *)this->c_str(); }
  | 
        
        
            | 
            | 
           43 | 
           	inline operator const unsigned char *() const	{ return (const unsigned char *)this->c_str(); }
  | 
        
        
            | 
            | 
           44 | 
           	inline operator unsigned char *() const			{ return (unsigned char *)this->c_str(); }
  | 
        
        
            | 
            | 
           45 | 
           	inline operator const std::string &() const		{ return (const std::string &)*this; }
  | 
        
        
            | 
            | 
           46 | 
           	inline operator const long () const				{ return this->toLong(); }
  | 
        
        
            | 
            | 
           47 | 
           	inline operator const double () const			{ return this->toDouble(); }
  | 
        
        
            | 
            | 
           48 | 
           	inline operator const float () const			{ return this->toFloat(); }
  | 
        
        
            | 
            | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
           	// assignment operators
  | 
        
        
            | 
            | 
           51 | 
           	const String &operator= ( const String &str );
  | 
        
        
            | 
            | 
           52 | 
           	const String &operator= ( const std::string &str );
  | 
        
        
            | 
            | 
           53 | 
           	const String &operator= ( const char *str );
  | 
        
        
            | 
            | 
           54 | 
           	const String &operator= ( const unsigned char *str );
  | 
        
        
            | 
            | 
           55 | 
           	const String &operator= ( unsigned char c );
  | 
        
        
            | 
            | 
           56 | 
           	const String &operator= ( char c );
  | 
        
        
            | 
            | 
           57 | 
           	const String &operator= ( long l );
  | 
        
        
            | 
            | 
           58 | 
           	const String &operator= ( unsigned long l );
  | 
        
        
            | 
            | 
           59 | 
           	const String &operator= ( float l );
  | 
        
        
            | 
            | 
           60 | 
           	const String &operator= ( double l );
  | 
        
        
            | 
            | 
           61 | 
              | 
        
        
            | 
            | 
           62 | 
           	// subscript operators
  | 
        
        
            | 
            | 
           63 | 
           	const unsigned char operator[] ( int num ) const;
  | 
        
        
            | 
            | 
           64 | 
           	unsigned char &operator[] ( int num );
  | 
        
        
            | 
            | 
           65 | 
              | 
        
        
            | 
            | 
           66 | 
           	// addition operators
  | 
        
        
            | 
            | 
           67 | 
           	String operator+ ( const char *str ) const;
  | 
        
        
            | 
            | 
           68 | 
           	String operator+ ( const unsigned char *str ) const;
  | 
        
        
            | 
            | 
           69 | 
           	String operator+ ( const std::string &str ) const;
  | 
        
        
            | 
            | 
           70 | 
           	String operator+ ( const String &str ) const;
  | 
        
        
            | 
            | 
           71 | 
           	String operator+ ( const char c ) const;
  | 
        
        
            | 
            | 
           72 | 
           	String operator+ ( const unsigned char c ) const;
  | 
        
        
            | 
            | 
           73 | 
           	String operator+ ( const long l ) const;
  | 
        
        
            | 
            | 
           74 | 
           	String operator+ ( const unsigned long l ) const;
  | 
        
        
            | 
            | 
           75 | 
           	String operator+ ( const float f ) const;
  | 
        
        
            | 
            | 
           76 | 
           	String operator+ ( const double f ) const;
  | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
           	// compound operators
  | 
        
        
            | 
            | 
           79 | 
           	const String &operator+= ( const char *str );
  | 
        
        
            | 
            | 
           80 | 
           	const String &operator+= ( const unsigned char *str );
  | 
        
        
            | 
            | 
           81 | 
           	const String &operator+= ( const std::string &str );
  | 
        
        
            | 
            | 
           82 | 
           	const String &operator+= ( const String &str );
  | 
        
        
            | 
            | 
           83 | 
           	const String &operator+= ( const char c );
  | 
        
        
            | 
            | 
           84 | 
           	const String &operator+= ( const unsigned char c );
  | 
        
        
            | 
            | 
           85 | 
           	const String &operator+= ( const long l );
  | 
        
        
            | 
            | 
           86 | 
           	const String &operator+= ( const unsigned long l );
  | 
        
        
            | 
            | 
           87 | 
           	const String &operator+= ( const float f );
  | 
        
        
            | 
            | 
           88 | 
           	const String &operator+= ( const double f );
  | 
        
        
            | 
            | 
           89 | 
              | 
        
        
            | 
            | 
           90 | 
           	// comparison operators
  | 
        
        
            | 
            | 
           91 | 
           	bool operator== ( const char *str ) const;
  | 
        
        
            | 
            | 
           92 | 
           	bool operator== ( const unsigned char *str ) const;
  | 
        
        
            | 
            | 
           93 | 
           	bool operator== ( const std::string &str ) const;
  | 
        
        
            | 
            | 
           94 | 
           	bool operator== ( const String &str ) const;
  | 
        
        
            | 
            | 
           95 | 
              | 
        
        
            | 
            | 
           96 | 
           	bool operator!= ( const char *str ) const;
  | 
        
        
            | 
            | 
           97 | 
           	bool operator!= ( const unsigned char *str ) const;
  | 
        
        
            | 
            | 
           98 | 
           	bool operator!= ( const std::string &str ) const;
  | 
        
        
            | 
            | 
           99 | 
           	bool operator!= ( const String &str ) const;
  | 
        
        
            | 
            | 
           100 | 
              | 
        
        
            | 
            | 
           101 | 
           	bool Compare(const String &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           102 | 
           	bool Compare(const unsigned char *str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           103 | 
           	bool Compare(const char *str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           104 | 
              | 
        
        
            | 
            | 
           105 | 
           	unsigned char *readToEndOfLine(unsigned char *data);
  | 
        
        
            | 
            | 
           106 | 
           	char *readToEndOfLine(char *data);
  | 
        
        
            | 
            | 
           107 | 
              | 
        
        
            | 
            | 
           108 | 
           	// tokens
  | 
        
        
            | 
            | 
           109 | 
           	int countToken(const char *token) const;
  | 
        
        
            | 
            | 
           110 | 
           	String token(const char *token, int tok) const;
  | 
        
        
            | 
            | 
           111 | 
           	String tokens(const char *token, int from, int to = 0) const;
  | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
           	String findReplace(const String &find, const String &replace ) const;
  | 
        
        
            | 
            | 
           114 | 
              | 
        
        
            | 
            | 
           115 | 
           	bool isin(const String &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           116 | 
           	bool isin(char c, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           117 | 
              | 
        
        
            | 
            | 
           118 | 
           	String left(long num) const;
  | 
        
        
            | 
            | 
           119 | 
           	String right(int num) const;
  | 
        
        
            | 
            | 
           120 | 
              | 
        
        
            | 
            | 
           121 | 
           private:
  | 
        
        
            | 
            | 
           122 | 
           	std::string::size_type _token_nextPos(const char *token, std::string::size_type curPos) const;
  | 
        
        
            | 
            | 
           123 | 
           };
  | 
        
        
            | 
            | 
           124 | 
              | 
        
        
            | 
            | 
           125 | 
           String operator+(const char *str1, const String &str2);
  | 
        
        
            | 
            | 
           126 | 
           }
  |