FAST.Framework  1.0.0
FString.h
1 /******************************************************************************
2 **
3 ** FAST.Framework
4 **
5 ** Created: 2023-10-11
6 ** Author: Boris Fast
7 ** Mail: support@fast-framework.com
8 **
9 ******************************************************************************/
10 
11 #ifndef FSTRING_H
12 #define FSTRING_H
13 
14 using namespace std;
15 
16 #include "FObject.h"
17 
21 class FString : public FObject
22 {
23  public:
24  FString(const FString& string);
25  FString(const FChar& character);
26  FString(const char* string);
27  FString(const char& character);
28  FString();
29  virtual ~FString();
30 
31  UInt Length() const;
32 
33  FString Left(UInt length) const;
34  FString Right(UInt length) const;
35  FString Mid(UInt position, UInt length) const;
36 
37  FString Trim() const;
38  FString TrimLeft() const;
39  FString TrimRight() const;
40 
41  Boolean StartsWith(const char* string) const;
42  Boolean EndsWith(const char* string) const;
43 
44  Int Find(const char* string) const;
45  Int Find(UInt position, const char* string) const;
46  Boolean Exists(const char* string) const;
47 
48  FString Remove(UInt position) const;
49  FString Insert(UInt position, const char* string) const;
50 
51  Boolean IsEmpty() const;
52  Boolean IsNull() const;
53  Boolean IsNullOrEmpty() const;
54 
55  FString ToLower() const;
56  FString ToUpper() const;
57  Double ToDouble() const;
58  Float ToFloat() const;
59  Int ToInt() const;
60  Long ToLong() const;
61 
62  FList<FString> Split(const char* delimeter = " ") const;
63 
64  inline const char* Data() const { return this->buffer; }
66  char operator [](UInt position) const;
67 
68  void operator =(const FString& string);
69  void operator =(const char* string);
70  void operator =(const FChar& character);
71  void operator =(const char& character);
72 
73  Boolean operator ==(const FString& string) const;
74  Boolean operator ==(const char* string) const;
75  Boolean operator !=(const FString& string) const;
76  Boolean operator !=(const char* string) const;
77 
78  friend const FString operator +(const FString& first,
79  const FString& second);
80  friend const FString operator +(const FString& first,
81  const FChar& second);
82  friend const FString operator +(const FString& first,
83  const char* second);
84  friend const FString operator +(const FString& first,
85  const char& second);
86 
87  FString& operator +=(const FString& string);
88  FString& operator +=(const FChar& character);
89  FString& operator +=(const char* string);
90  FString& operator +=(const char& character);
91 
92  static Boolean IsEmpty(const FString& string);
93  static Boolean IsEmpty(const char* string);
94  static Boolean IsNull(const FString& string);
95  static Boolean IsNull(const char* string);
96  static Boolean IsNullOrEmpty(const FString& string);
97  static Boolean IsNullOrEmpty(const char* string);
98 
99  static Float ToFloat(const char* string);
100  static Double ToDouble(const char* string);
101  static Int ToInt(const char* string);
102  static Long ToLong(const char* string);
103 
104  static const FString Format(const char* format, ...);
105 
106  inline static const FString Empty() { return FString(""); }
107 
108  const type_info& GetType() override;
109  FString GetName() const override;
110 
111  private:
112  char *buffer;
113  size_t length;
114 };
115 
116 #endif // FSTRING_H
Definition: FChar.h:22
Definition: FList.h:26
Definition: FObject.h:50
Definition: FString.h:22
static const FString Empty()
Returns a empty string.
Definition: FString.h:106
const char * Data() const
Definition: FString.h:64