Norbert's Game Engine v200
Loading...
Searching...
No Matches
eString Class Reference

#include <String.hpp>

Inheritance diagram for eString:
eBase

Public Member Functions

 eString (const eString &vl)
 String constructor.
 
 eString (const char *vl)
 String constructor with c-string.
 
 eString (strg vl)
 String constructor with std::string.
 
 ~eString ()
 String deconstructor.
 
void Set (const char *vl)
 Set text.
 
void Add (const char *vl)
 Add to text.
 
void AddLine (const char *vl)
 Add to text in new line.
 
void Clear ()
 Clear text.
 
const char * Get ()
 Return text as c-string.
 
const strg & GetStrg () const
 Return text as std::string.
 
void Set (eString vl)
 Set text by string.
 
void Add (eString vl)
 Add to text by string.
 
void AddLine (eString vl)
 Add to text by string in new line.
 
bool Compare (eString s1)
 Compare to string.
 
bool Contains (eString s0)
 Token check.
 
uint64 Size ()
 Returns text size.
 
uint64 Lenght ()
 Returns text lenght.
 
const bool & IsEmpty () const
 Returns true if text is empty.
 
const bool Find (eString vl)
 Returns true if token was found.
 
void Replace (char th, char withMe)
 Replaces a character with another one.
 
void Replace (strg th, strg withMe)
 Replaces a std::string with an std::string.
 
void Replace (eString th, eString withMe)
 Replaces a string with a string.
 
eString operator+ (const char *in)
 
void operator+= (const char *in)
 
void operator+= (char in)
 
void operator= (char in)
 
eString operator+ (eString in)
 
void operator+= (eString in)
 
bool operator== (eString in)
 
char operator[] (uint in)
 
strg & Ref ()
 Reference to cpp string.
 
- Public Member Functions inherited from eBase
template<typename T >
T * Cast (eBase *obj)
 Cast class to base.
 

Static Public Member Functions

template<typename T >
static eString ToString (T vl)
 
template<typename T >
static T ToInt (eString &vl)
 
static real6 ToReal6 (eString &vl)
 
static real3 ToReal3 (eString &vl)
 

Detailed Description

Simple string class using standard library

Definition at line 13 of file String.hpp.

Constructor & Destructor Documentation

◆ eString() [1/4]

eString::eString ( )

Definition at line 8 of file String.cpp.

9{
10 mValue = "";
11}

◆ eString() [2/4]

eString::eString ( const eString & vl)

String constructor.

Definition at line 14 of file String.cpp.

15{
16 mValue.clear();
17 mValue = vl.mValue;
18}

◆ eString() [3/4]

eString::eString ( const char * vl)

String constructor with c-string.

Definition at line 21 of file String.cpp.

22{
23 mValue = strg(vl);
24}

◆ eString() [4/4]

eString::eString ( strg vl)

String constructor with std::string.

Definition at line 27 of file String.cpp.

28{
29 mValue = vl;
30}

◆ ~eString()

eString::~eString ( )

String deconstructor.

Definition at line 33 of file String.cpp.

34{
35 mValue.clear();
36}

Member Function Documentation

◆ Add() [1/2]

void eString::Add ( const char * vl)

Add to text.

Definition at line 46 of file String.cpp.

47{
48 mValue += strg(vl);
49}

◆ Add() [2/2]

void eString::Add ( eString vl)

Add to text by string.

Definition at line 108 of file String.cpp.

109{
110 mValue += strg(vl.Get());
111}
const char * Get()
Return text as c-string.
Definition String.cpp:64

◆ AddLine() [1/2]

void eString::AddLine ( const char * vl)

Add to text in new line.

Definition at line 52 of file String.cpp.

53{
54 mValue += "\n" + strg(vl);
55}

◆ AddLine() [2/2]

void eString::AddLine ( eString vl)

Add to text by string in new line.

Definition at line 114 of file String.cpp.

115{
116 mValue += "\n" + strg(vl.Get());
117}

◆ Clear()

void eString::Clear ( )

Clear text.

Definition at line 58 of file String.cpp.

59{
60 mValue.clear();
61}

◆ Compare()

bool eString::Compare ( eString s1)

Compare to string.

Definition at line 76 of file String.cpp.

77{
78 return (mValue == s1.GetStrg());
79}
const strg & GetStrg() const
Return text as std::string.
Definition String.cpp:70

◆ Contains()

bool eString::Contains ( eString s0)

Token check.

Definition at line 82 of file String.cpp.

83{
84 strg c0(s0.Get());
85 return (mValue.find(c0) != strg::npos);
86}

◆ Find()

const bool eString::Find ( eString vl)

Returns true if token was found.

Definition at line 126 of file String.cpp.

127{
128 return (mValue.find(vl.GetStrg()) != strg::npos);
129}

◆ Get()

const char * eString::Get ( )

Return text as c-string.

Definition at line 64 of file String.cpp.

65{
66 return mValue.c_str();
67}

◆ GetStrg()

const strg & eString::GetStrg ( ) const

Return text as std::string.

Definition at line 70 of file String.cpp.

71{
72 return mValue;
73}

◆ IsEmpty()

const bool & eString::IsEmpty ( ) const

Returns true if text is empty.

Definition at line 120 of file String.cpp.

121{
122 return mValue.empty();
123}

◆ Lenght()

uint64 eString::Lenght ( )

Returns text lenght.

Definition at line 95 of file String.cpp.

96{
97 return mValue.length();
98}

◆ operator+() [1/2]

eString eString::operator+ ( const char * in)
inline

Definition at line 71 of file String.hpp.

72 {
73 eString rtVl = eString(this->Get());
74 rtVl.Add(in);
75 return rtVl;
76 }
void Add(const char *vl)
Add to text.
Definition String.cpp:46

◆ operator+() [2/2]

eString eString::operator+ ( eString in)
inline

Definition at line 93 of file String.hpp.

94 {
95 eString rtVl = eString(this->Get());
96 rtVl.Add(in);
97 return rtVl;
98 }

◆ operator+=() [1/3]

void eString::operator+= ( char in)
inline

Definition at line 83 of file String.hpp.

84 {
85 mValue += in;
86 }

◆ operator+=() [2/3]

void eString::operator+= ( const char * in)
inline

Definition at line 78 of file String.hpp.

79 {
80 Add(in);
81 }

◆ operator+=() [3/3]

void eString::operator+= ( eString in)
inline

Definition at line 100 of file String.hpp.

101 {
102 Add(in);
103 }

◆ operator=()

void eString::operator= ( char in)
inline

Definition at line 88 of file String.hpp.

89 {
90 mValue = in;
91 }

◆ operator==()

bool eString::operator== ( eString in)
inline

Definition at line 105 of file String.hpp.

106 {
107 return (mValue == in.mValue);
108 }

◆ operator[]()

char eString::operator[] ( uint in)
inline

Definition at line 110 of file String.hpp.

111 {
112 return mValue[in];
113 }

◆ Ref()

strg & eString::Ref ( )

Reference to cpp string.

Definition at line 168 of file String.cpp.

169{
170 return mValue;
171}

◆ Replace() [1/3]

void eString::Replace ( char th,
char withMe )

Replaces a character with another one.

Definition at line 132 of file String.cpp.

133{
134 std::replace_if(mValue.begin(), mValue.end(), [th](char c) { return c == th; }, withMe);
135}

◆ Replace() [2/3]

void eString::Replace ( eString th,
eString withMe )

Replaces a string with a string.

Definition at line 162 of file String.cpp.

163{
164 Replace(th.GetStrg(), withMe.GetStrg());
165}
void Replace(char th, char withMe)
Replaces a character with another one.
Definition String.cpp:132

◆ Replace() [3/3]

void eString::Replace ( strg th,
strg withMe )

Replaces a std::string with an std::string.

Definition at line 138 of file String.cpp.

139{
140 if (th.empty()) return;
141 strg rtVl = "";
142 std::istringstream iss(mValue);
143 strg line;
144 while (std::getline(iss, line, '\n'))
145 {
146 std::istringstream iss2(line);
147 strg token;
148 while (iss2 >> token)
149 {
150 if (token == th) rtVl += withMe;
151 else rtVl += token;
152 rtVl += " ";
153 }
154
155 rtVl += "\n";
156 }
157 mValue.clear();
158 mValue = rtVl;
159}

◆ Set() [1/2]

void eString::Set ( const char * vl)

Set text.

Definition at line 39 of file String.cpp.

40{
41 mValue.clear();
42 mValue = strg(vl);
43}

◆ Set() [2/2]

void eString::Set ( eString vl)

Set text by string.

Definition at line 101 of file String.cpp.

102{
103 mValue.clear();
104 mValue = strg(vl.Get());
105}

◆ Size()

uint64 eString::Size ( )

Returns text size.

Definition at line 89 of file String.cpp.

90{
91 return mValue.size();
92}

◆ ToInt()

template<typename T >
static T eString::ToInt ( eString & vl)
inlinestatic

Definition at line 54 of file String.hpp.

55 {
56 return ::atoi(vl.Get());
57 }

◆ ToReal3()

static real3 eString::ToReal3 ( eString & vl)
inlinestatic

Definition at line 66 of file String.hpp.

67 {
68 return static_cast<real3>(::atof(vl.Get()));
69 }

◆ ToReal6()

static real6 eString::ToReal6 ( eString & vl)
inlinestatic

Definition at line 60 of file String.hpp.

61 {
62 return ::atof(vl.Get());
63 }

◆ ToString()

template<typename T >
static eString eString::ToString ( T vl)
inlinestatic

Definition at line 47 of file String.hpp.

48 {
49 return eString(std::to_string(vl));
50 }

The documentation for this class was generated from the following files: