| 8 | 
           cycrow | 
           1 | 
           #pragma once
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           #include <string>
  | 
        
        
            | 
            | 
           4 | 
           #include "../spkdll.h"
  | 
        
        
            | 
            | 
           5 | 
              | 
        
        
           | 50 | 
           cycrow | 
           6 | 
           enum {
  | 
        
        
            | 
            | 
           7 | 
           	COMPARE_SAME		= 0,
  | 
        
        
            | 
            | 
           8 | 
           	COMPARE_NEWER		= 1,
  | 
        
        
            | 
            | 
           9 | 
           	COMPARE_OLDER		= -1,
  | 
        
        
            | 
            | 
           10 | 
           };
  | 
        
        
            | 
            | 
           11 | 
              | 
        
        
           | 121 | 
           cycrow | 
           12 | 
           #pragma warning( push )
  | 
        
        
            | 
            | 
           13 | 
           #pragma warning( disable : 4251)
  | 
        
        
            | 
            | 
           14 | 
              | 
        
        
           | 8 | 
           cycrow | 
           15 | 
           namespace Utils {
  | 
        
        
            | 
            | 
           16 | 
           /**
  | 
        
        
            | 
            | 
           17 | 
            * String wrapper class
  | 
        
        
            | 
            | 
           18 | 
            */
  | 
        
        
            | 
            | 
           19 | 
           class SPKEXPORT String : public std::string
  | 
        
        
            | 
            | 
           20 | 
           {
  | 
        
        
            | 
            | 
           21 | 
           public:
  | 
        
        
            | 
            | 
           22 | 
           	// constructors
  | 
        
        
            | 
            | 
           23 | 
           	String(void);
  | 
        
        
            | 
            | 
           24 | 
           	String(const char *str);
  | 
        
        
            | 
            | 
           25 | 
           	String(const unsigned char *str);
  | 
        
        
            | 
            | 
           26 | 
           	String(const std::string &str);
  | 
        
        
           | 14 | 
           cycrow | 
           27 | 
           	String(const char c);
  | 
        
        
           | 8 | 
           cycrow | 
           28 | 
           	String(const unsigned char c);
  | 
        
        
            | 
            | 
           29 | 
           	String(const String &str);
  | 
        
        
            | 
            | 
           30 | 
           	String(long l);
  | 
        
        
            | 
            | 
           31 | 
           	String(unsigned long l);
  | 
        
        
            | 
            | 
           32 | 
           	String(float f);
  | 
        
        
            | 
            | 
           33 | 
           	String(double f);
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           	virtual ~String(void);
  | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
           	// conversion functions
  | 
        
        
            | 
            | 
           38 | 
           	void fromLong(long l);
  | 
        
        
           | 126 | 
           cycrow | 
           39 | 
           	const String &fromFloat(float f, int dp = -1);
  | 
        
        
           | 8 | 
           cycrow | 
           40 | 
           	void fromDouble(double f);
  | 
        
        
           | 130 | 
           cycrow | 
           41 | 
           	const String &fromDouble(double f, int dp);
  | 
        
        
           | 8 | 
           cycrow | 
           42 | 
           	const String &format(const char *sFormat, ...);
  | 
        
        
           | 130 | 
           cycrow | 
           43 | 
           	const String args(const String *args, int max) const;
  | 
        
        
           | 104 | 
           cycrow | 
           44 | 
           	const String &arg(const String &s1);
  | 
        
        
            | 
            | 
           45 | 
           	const String &arg(const String &s1, const String &s2);
  | 
        
        
            | 
            | 
           46 | 
           	const String &arg(const String &s1, const String &s2, const String &s3);
  | 
        
        
            | 
            | 
           47 | 
           	const String &arg(const String &s1, const String &s2, const String &s3, const String &s4);
  | 
        
        
            | 
            | 
           48 | 
           	const String &arg(const String &s1, const String &s2, const String &s3, const String &s4, const String &s5);
  | 
        
        
           | 8 | 
           cycrow | 
           49 | 
              | 
        
        
           | 50 | 
           cycrow | 
           50 | 
           	static String PadNumber(long iNum, int iAmount);
  | 
        
        
            | 
            | 
           51 | 
           	static String Number(long l) { return String(l); }
  | 
        
        
            | 
            | 
           52 | 
           	static String Format(const char *sFormat, ...);
  | 
        
        
           | 85 | 
           cycrow | 
           53 | 
           	static String Null();
  | 
        
        
           | 109 | 
           cycrow | 
           54 | 
           	static String FromFloat(float f, int dp = -1);
  | 
        
        
           | 50 | 
           cycrow | 
           55 | 
              | 
        
        
           | 94 | 
           cycrow | 
           56 | 
           	bool toBool() const;
  | 
        
        
           | 8 | 
           cycrow | 
           57 | 
           	long toLong() const;
  | 
        
        
           | 121 | 
           cycrow | 
           58 | 
           	int toInt() const;
  | 
        
        
           | 8 | 
           cycrow | 
           59 | 
           	double toDouble() const;
  | 
        
        
            | 
            | 
           60 | 
           	float toFloat() const;
  | 
        
        
            | 
            | 
           61 | 
              | 
        
        
            | 
            | 
           62 | 
           	// casting operators
  | 
        
        
            | 
            | 
           63 | 
           	inline operator const char *() const			{ return (const char *)this->c_str(); }
  | 
        
        
            | 
            | 
           64 | 
           	inline operator char *() const					{ return (char *)this->c_str(); }
  | 
        
        
            | 
            | 
           65 | 
           	inline operator const unsigned char *() const	{ return (const unsigned char *)this->c_str(); }
  | 
        
        
            | 
            | 
           66 | 
           	inline operator unsigned char *() const			{ return (unsigned char *)this->c_str(); }
  | 
        
        
            | 
            | 
           67 | 
           	inline operator const std::string &() const		{ return (const std::string &)*this; }
  | 
        
        
           | 10 | 
           cycrow | 
           68 | 
           	inline operator const int () const				{ return this->toLong(); }
  | 
        
        
           | 8 | 
           cycrow | 
           69 | 
           	inline operator const long () const				{ return this->toLong(); }
  | 
        
        
            | 
            | 
           70 | 
           	inline operator const double () const			{ return this->toDouble(); }
  | 
        
        
            | 
            | 
           71 | 
           	inline operator const float () const			{ return this->toFloat(); }
  | 
        
        
           | 101 | 
           cycrow | 
           72 | 
           	inline operator const bool () const				{ return (this->empty() ? false : ((this->toLong()) ? true : false)); }
  | 
        
        
           | 8 | 
           cycrow | 
           73 | 
              | 
        
        
            | 
            | 
           74 | 
           	// assignment operators
  | 
        
        
            | 
            | 
           75 | 
           	const String &operator= ( const String &str );
  | 
        
        
            | 
            | 
           76 | 
           	const String &operator= ( const std::string &str );
  | 
        
        
            | 
            | 
           77 | 
           	const String &operator= ( const char *str );
  | 
        
        
            | 
            | 
           78 | 
           	const String &operator= ( const unsigned char *str );
  | 
        
        
            | 
            | 
           79 | 
           	const String &operator= ( unsigned char c );
  | 
        
        
            | 
            | 
           80 | 
           	const String &operator= ( char c );
  | 
        
        
            | 
            | 
           81 | 
           	const String &operator= ( long l );
  | 
        
        
            | 
            | 
           82 | 
           	const String &operator= ( unsigned long l );
  | 
        
        
            | 
            | 
           83 | 
           	const String &operator= ( float l );
  | 
        
        
            | 
            | 
           84 | 
           	const String &operator= ( double l );
  | 
        
        
            | 
            | 
           85 | 
              | 
        
        
            | 
            | 
           86 | 
           	// subscript operators
  | 
        
        
            | 
            | 
           87 | 
           	const unsigned char operator[] ( int num ) const;
  | 
        
        
            | 
            | 
           88 | 
           	unsigned char &operator[] ( int num );
  | 
        
        
            | 
            | 
           89 | 
              | 
        
        
            | 
            | 
           90 | 
           	// addition operators
  | 
        
        
            | 
            | 
           91 | 
           	String operator+ ( const char *str ) const;
  | 
        
        
            | 
            | 
           92 | 
           	String operator+ ( const unsigned char *str ) const;
  | 
        
        
            | 
            | 
           93 | 
           	String operator+ ( const std::string &str ) const;
  | 
        
        
            | 
            | 
           94 | 
           	String operator+ ( const String &str ) const;
  | 
        
        
            | 
            | 
           95 | 
           	String operator+ ( const char c ) const;
  | 
        
        
            | 
            | 
           96 | 
           	String operator+ ( const unsigned char c ) const;
  | 
        
        
            | 
            | 
           97 | 
           	String operator+ ( const long l ) const;
  | 
        
        
            | 
            | 
           98 | 
           	String operator+ ( const unsigned long l ) const;
  | 
        
        
            | 
            | 
           99 | 
           	String operator+ ( const float f ) const;
  | 
        
        
            | 
            | 
           100 | 
           	String operator+ ( const double f ) const;
  | 
        
        
            | 
            | 
           101 | 
              | 
        
        
            | 
            | 
           102 | 
           	// compound operators
  | 
        
        
            | 
            | 
           103 | 
           	const String &operator+= ( const char *str );
  | 
        
        
            | 
            | 
           104 | 
           	const String &operator+= ( const unsigned char *str );
  | 
        
        
            | 
            | 
           105 | 
           	const String &operator+= ( const std::string &str );
  | 
        
        
            | 
            | 
           106 | 
           	const String &operator+= ( const String &str );
  | 
        
        
            | 
            | 
           107 | 
           	const String &operator+= ( const char c );
  | 
        
        
            | 
            | 
           108 | 
           	const String &operator+= ( const unsigned char c );
  | 
        
        
            | 
            | 
           109 | 
           	const String &operator+= ( const long l );
  | 
        
        
            | 
            | 
           110 | 
           	const String &operator+= ( const unsigned long l );
  | 
        
        
            | 
            | 
           111 | 
           	const String &operator+= ( const float f );
  | 
        
        
            | 
            | 
           112 | 
           	const String &operator+= ( const double f );
  | 
        
        
            | 
            | 
           113 | 
              | 
        
        
            | 
            | 
           114 | 
           	// comparison operators
  | 
        
        
            | 
            | 
           115 | 
           	bool operator== ( const char *str ) const;
  | 
        
        
            | 
            | 
           116 | 
           	bool operator== ( const unsigned char *str ) const;
  | 
        
        
            | 
            | 
           117 | 
           	bool operator== ( const std::string &str ) const;
  | 
        
        
            | 
            | 
           118 | 
           	bool operator== ( const String &str ) const;
  | 
        
        
            | 
            | 
           119 | 
              | 
        
        
            | 
            | 
           120 | 
           	bool operator!= ( const char *str ) const;
  | 
        
        
            | 
            | 
           121 | 
           	bool operator!= ( const unsigned char *str ) const;
  | 
        
        
            | 
            | 
           122 | 
           	bool operator!= ( const std::string &str ) const;
  | 
        
        
            | 
            | 
           123 | 
           	bool operator!= ( const String &str ) const;
  | 
        
        
            | 
            | 
           124 | 
              | 
        
        
           | 101 | 
           cycrow | 
           125 | 
           	bool operator !() const;
  | 
        
        
            | 
            | 
           126 | 
              | 
        
        
           | 8 | 
           cycrow | 
           127 | 
           	bool Compare(const String &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           128 | 
           	bool Compare(const unsigned char *str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           129 | 
           	bool Compare(const char *str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           130 | 
              | 
        
        
           | 39 | 
           cycrow | 
           131 | 
           	// file handling
  | 
        
        
           | 8 | 
           cycrow | 
           132 | 
           	unsigned char *readToEndOfLine(unsigned char *data);
  | 
        
        
            | 
            | 
           133 | 
           	char *readToEndOfLine(char *data);
  | 
        
        
           | 39 | 
           cycrow | 
           134 | 
           	const String &readToEndOfLine(FILE *id, int *line, bool upper);
  | 
        
        
           | 8 | 
           cycrow | 
           135 | 
              | 
        
        
            | 
            | 
           136 | 
           	// tokens
  | 
        
        
            | 
            | 
           137 | 
           	int countToken(const char *token) const;
  | 
        
        
            | 
            | 
           138 | 
           	String token(const char *token, int tok) const;
  | 
        
        
            | 
            | 
           139 | 
           	String tokens(const char *token, int from, int to = 0) const;
  | 
        
        
           | 10 | 
           cycrow | 
           140 | 
           	String *tokenise(const char *token, int *max) const;
  | 
        
        
           | 39 | 
           cycrow | 
           141 | 
           	String replaceToken(const char *token, int from, const String &replace) const;
  | 
        
        
           | 160 | 
           cycrow | 
           142 | 
           	String remToken(const char* token, int from) const;
  | 
        
        
            | 
            | 
           143 | 
           	String remTokens(const char* token, int from, int to = -1) const;
  | 
        
        
           | 39 | 
           cycrow | 
           144 | 
           	String word(int word) const;
  | 
        
        
            | 
            | 
           145 | 
           	String words(int from, int to = 0) const;
  | 
        
        
           | 126 | 
           cycrow | 
           146 | 
           	String addToken(const char *token, const Utils::String &str) const;
  | 
        
        
           | 14 | 
           cycrow | 
           147 | 
              | 
        
        
           | 39 | 
           cycrow | 
           148 | 
           	// find/replacement
  | 
        
        
            | 
            | 
           149 | 
           	int findPos(const String &find, int iStartPos = 0) const;
  | 
        
        
           | 8 | 
           cycrow | 
           150 | 
           	String findReplace(const String &find, const String &replace ) const;
  | 
        
        
           | 39 | 
           cycrow | 
           151 | 
           	String remove(char c) const;
  | 
        
        
            | 
            | 
           152 | 
           	const String &removeChar(char c);
  | 
        
        
           | 69 | 
           cycrow | 
           153 | 
           	const String &removeChar(const char *cs);
  | 
        
        
           | 48 | 
           cycrow | 
           154 | 
           	String findRemove(const String &find) const;
  | 
        
        
            | 
            | 
           155 | 
           	String stripHtml() const;
  | 
        
        
           | 58 | 
           cycrow | 
           156 | 
           	String removeIf(int iChar, char c) const;
  | 
        
        
           | 8 | 
           cycrow | 
           157 | 
              | 
        
        
           | 127 | 
           cycrow | 
           158 | 
           	bool containsAny(const String &str, bool bCaseSensative = false) const;
  | 
        
        
           | 126 | 
           cycrow | 
           159 | 
           	bool contains(const String &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           160 | 
           	bool contains(char c, bool bCaseSensative = false) const;
  | 
        
        
           | 8 | 
           cycrow | 
           161 | 
           	bool isin(const String &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           162 | 
           	bool isin(char c, bool bCaseSensative = false) const;
  | 
        
        
           | 50 | 
           cycrow | 
           163 | 
           	int compareVersion(const Utils::String &v) const;
  | 
        
        
           | 127 | 
           cycrow | 
           164 | 
           	bool match(const Utils::String &pattern) const;
  | 
        
        
           | 8 | 
           cycrow | 
           165 | 
              | 
        
        
           | 39 | 
           cycrow | 
           166 | 
           	// sub string
  | 
        
        
           | 8 | 
           cycrow | 
           167 | 
           	String left(long num) const;
  | 
        
        
            | 
            | 
           168 | 
           	String right(int num) const;
  | 
        
        
           | 39 | 
           cycrow | 
           169 | 
           	String mid(int start, int end) const;
  | 
        
        
           | 56 | 
           cycrow | 
           170 | 
           	String between(const String &before, const String &after) const;
  | 
        
        
           | 8 | 
           cycrow | 
           171 | 
              | 
        
        
           | 13 | 
           cycrow | 
           172 | 
           	bool isNumber(bool integer = false) const;
  | 
        
        
            | 
            | 
           173 | 
           	bool isCharNumber(int c) const;
  | 
        
        
           | 14 | 
           cycrow | 
           174 | 
           	const String &removeFirstSpace();
  | 
        
        
           | 39 | 
           cycrow | 
           175 | 
           	const String &removeEndSpace();
  | 
        
        
           | 34 | 
           cycrow | 
           176 | 
           	const String &truncate(int iNum);
  | 
        
        
           | 50 | 
           cycrow | 
           177 | 
           	const String &padNumber(int iNum);
  | 
        
        
            | 
            | 
           178 | 
           	const String &pad(int iAmoumt, char cWith);
  | 
        
        
           | 13 | 
           cycrow | 
           179 | 
              | 
        
        
           | 43 | 
           cycrow | 
           180 | 
           	String lower() const;
  | 
        
        
            | 
            | 
           181 | 
           	String upper() const;
  | 
        
        
            | 
            | 
           182 | 
           	const String &toLower();
  | 
        
        
            | 
            | 
           183 | 
           	const String &toUpper();
  | 
        
        
            | 
            | 
           184 | 
              | 
        
        
           | 81 | 
           cycrow | 
           185 | 
           	const String &toFilename();
  | 
        
        
            | 
            | 
           186 | 
           	String asFilename() const;
  | 
        
        
            | 
            | 
           187 | 
              | 
        
        
           | 8 | 
           cycrow | 
           188 | 
           private:
  | 
        
        
           | 13 | 
           cycrow | 
           189 | 
           	bool _isCharNumber(char c) const;
  | 
        
        
           | 86 | 
           cycrow | 
           190 | 
           	Utils::String::size_type _token_nextPos(const char *token, Utils::String::size_type curPos) const;
  | 
        
        
           | 8 | 
           cycrow | 
           191 | 
           };
  | 
        
        
            | 
            | 
           192 | 
              | 
        
        
           | 104 | 
           cycrow | 
           193 | 
           SPKEXPORT String operator+(const char *str1, const String &str2);
  | 
        
        
           | 121 | 
           cycrow | 
           194 | 
              | 
        
        
            | 
            | 
           195 | 
           #pragma warning( pop )
  | 
        
        
            | 
            | 
           196 | 
              | 
        
        
           | 8 | 
           cycrow | 
           197 | 
           }
  |