-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadvstring.cpp
More file actions
829 lines (807 loc) · 19.4 KB
/
advstring.cpp
File metadata and controls
829 lines (807 loc) · 19.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
/*
* advstring
*
* Author: Prasaath Viki
* Email: prasaathviki@gmail.com
* Description: advstring is a string class with advance options.
* Place: Chennai.
* Version: 2.0.7
* Date: Tuesday, May 20, 2014.
*/
#include "advstring.h"
std::string advstring::IntToString(int nValue)
{
std::stringstream ss;
ss << nValue;
return ss.str();
}
std::string advstring::FloatToString(float nValue)
{
std::stringstream ss;
ss << nValue;
return ss.str();
}
std::string advstring::DoubleToString(double nValue)
{
std::ostringstream out;
out << std::fixed << nValue;
return out.str();
}
int advstring::StringToInt(std::string sValue)
{
int nValue(0);
std::stringstream ss(sValue);
ss >> nValue;
return nValue;
}
float advstring::StringToFloat(std::string sValue)
{
float nValue(0.0);
std::stringstream ss(sValue);
ss >> nValue;
return nValue;
}
double advstring::StringToDouble(std::string sValue)
{
double nValue(0.0);
std::stringstream ss(sValue);
ss >> nValue;
return nValue;
}
std::string advstring::GetDateTime(std::string sFormatValue)
{
std::string sRetString;
time_t rawtime;
struct tm * timeinfo;
int nBufferSize(80),inc(1);
char *pchBuffer = NULL;
time (&rawtime);
timeinfo = localtime (&rawtime);
size_t sizRem(0);
do
{
if(inc != 1) delete [] pchBuffer;
pchBuffer = new char[nBufferSize*inc];
sizRem = strftime(pchBuffer,nBufferSize*inc,sFormatValue.c_str(),timeinfo);
inc++;
}while(sizRem < 1);
sRetString = pchBuffer;
delete [] pchBuffer;
return sRetString;
}
advstring::advstring()
{
this->m_sValue = "";
}
advstring::advstring(std::string sValue)
{
this->m_sValue = sValue;
}
advstring::advstring(int nValue)
{
this->m_sValue = IntToString(nValue);
}
advstring::advstring(float nValue)
{
this->m_sValue = FloatToString(nValue);
}
advstring::advstring(double nValue)
{
this->m_sValue = DoubleToString(nValue);
}
advstring::advstring(const char *pcchValue)
{
this->m_sValue = pcchValue;
}
std::string advstring::GetClass()
{
return "advstring";
}
void advstring::DispString()
{
cout<<this->m_sValue.c_str();
}
void advstring::DispStringEndl()
{
cout<<this->m_sValue.c_str()<<endl;
}
void advstring::operator = (std::string sValue)
{
this->m_sValue = sValue;
}
void advstring::operator = (advstring asValue)
{
this->m_sValue = asValue.m_sValue;
}
void advstring::operator = (const char *pcchValue)
{
this->m_sValue = pcchValue;
}
advstring operator+( advstring asValue, const advstring& asValue2)
{
return advstring(asValue.m_sValue + asValue2.m_sValue);
}
advstring operator+( const char* pcchValue ,const advstring& asValue2)
{
return advstring(pcchValue + asValue2.m_sValue);
}
advstring operator+( int nValue, const advstring& asValue2)
{
return advstring(advstring::IntToString(nValue) + asValue2.m_sValue);
}
advstring operator+( float nValue ,const advstring& asValue2)
{
return advstring(advstring::FloatToString(nValue) + asValue2.m_sValue);
}
advstring operator+( double nValue ,const advstring& asValue2)
{
return advstring(advstring::DoubleToString(nValue) + asValue2.m_sValue);
}
advstring advstring::operator + (const char *pcchValue)
{
return (advstring(this->m_sValue + pcchValue));
}
advstring advstring::operator + (int nValue)
{
return (advstring(this->m_sValue + IntToString(nValue)));
}
advstring advstring::operator + (float nValue)
{
return (advstring(this->m_sValue + FloatToString(nValue)));
}
advstring advstring::operator + (double nValue)
{
return (advstring(this->m_sValue + DoubleToString(nValue)));
}
void advstring::operator += (const char *pcchValue)
{
this->m_sValue += pcchValue;
}
void advstring::operator += (advstring asValue)
{
this->m_sValue = this->m_sValue + asValue.m_sValue;
}
void advstring::operator += (int nValue)
{
this->m_sValue = this->m_sValue + IntToString(nValue);
}
void advstring::operator += (float nValue)
{
this->m_sValue = this->m_sValue + FloatToString(nValue);
}
void advstring::operator += (double nValue)
{
this->m_sValue = this->m_sValue + DoubleToString(nValue);
}
bool advstring::operator == (advstring asValue)
{
if(this->m_sValue == asValue.m_sValue)
return true;
else
return false;
}
bool advstring::operator == (int nValue)
{
if(this->m_sValue == IntToString(nValue))
return true;
else
return false;
}
bool advstring::operator == (float nValue)
{
if(this->m_sValue == FloatToString(nValue))
return true;
else
return false;
}
bool advstring::operator == (double nValue)
{
if(this->m_sValue == DoubleToString(nValue))
return true;
else
return false;
}
bool advstring::operator == (const char* pcchValue)
{
if(this->m_sValue == pcchValue)
return true;
else
return false;
}
bool advstring::operator != (advstring asValue)
{
if(this->m_sValue != asValue.m_sValue)
return true;
else
return false;
}
bool advstring::operator != (int nValue)
{
if(this->m_sValue != IntToString(nValue))
return true;
else
return false;
}
bool advstring::operator != (float nValue)
{
if(this->m_sValue != FloatToString(nValue))
return true;
else
return false;
}
bool advstring::operator != (double nValue)
{
if(this->m_sValue != DoubleToString(nValue))
return true;
else
return false;
}
bool advstring::operator != (const char* pcchValue)
{
if(this->m_sValue != pcchValue)
return true;
else
return false;
}
advstring::operator int()
{
return StringToInt(this->m_sValue);
}
advstring::operator float()
{
return StringToFloat(this->m_sValue);
}
advstring::operator double()
{
return StringToDouble(this->m_sValue);
}
advstring::operator const char*()
{
return this->m_sValue.c_str();
}
advstring::operator char*()
{
// Please delete the chNewValue after usage. if not deleted it may cause memory leak.
char * chNewValue = new char[this->m_sValue.size() + 1];
std::copy(this->m_sValue.begin(), this->m_sValue.end(), chNewValue);
chNewValue[this->m_sValue.size()] = '\0';
return chNewValue;
}
int advstring::ToInt()
{
return StringToInt(this->m_sValue);
}
float advstring::ToFloat()
{
return StringToFloat(this->m_sValue);
}
double advstring::ToDouble()
{
return StringToDouble(this->m_sValue);
}
std::string advstring::ToStdString()
{
return this->m_sValue;
}
const char* advstring::GetBuffer()
{
return this->m_sValue.c_str();
}
char* advstring::GetNewBuffer()
{
// Please delete the chNewValue after usage. if chNewValue not deleted it may cause memory leak.
char * chNewValue = new char[this->m_sValue.size() + 1];
std::copy(this->m_sValue.begin(), this->m_sValue.end(), chNewValue);
chNewValue[this->m_sValue.size()] = '\0';
return chNewValue;
}
void advstring::Empty()
{
this->m_sValue.clear();
}
int advstring::GetLength()
{
return this->m_sValue.size();
}
int advstring::MaxSize()
{
return this->m_sValue.capacity();
}
bool advstring::IsEmpty()
{
return this->m_sValue.empty();
}
char advstring::GetAt(int nIndex)
{
assert(0 <= nIndex && nIndex <= (int)this->m_sValue.size());
return this->m_sValue[nIndex];
}
void advstring::SetAt(int nIndex,char chValue)
{
assert(0 <= nIndex && nIndex < (int)this->m_sValue.size());
this->m_sValue[nIndex] = chValue;
}
int advstring::Insert(int nIndex,char chValue)
{
int nLength = this->m_sValue.size();
if (nIndex < 0)
nIndex = 0;
if( nIndex > nLength)
nIndex = nLength;
this->m_sValue.insert(nIndex,1,chValue);
return this->m_sValue.size();
}
int advstring::Insert(int nIndex,advstring asValue)
{
int nLength = this->m_sValue.size();
if (nIndex < 0)
nIndex = 0;
if( nIndex > nLength)
nIndex = nLength;
this->m_sValue.insert(nIndex,asValue.m_sValue.c_str(),(int)asValue.m_sValue.size());
return this->m_sValue.size();
}
int advstring::Replace(char chOldValue,char chNewValue)
{
int nReplaceCount(0);
if(chOldValue == chNewValue)
return nReplaceCount;
int sSize = this->m_sValue.size();
for(int x = 0;x< sSize;x++)
{
char chCurChar = this->m_sValue[x];
if(chCurChar == chOldValue)
{
this->m_sValue[x] = chNewValue;
nReplaceCount++;
}
}
return nReplaceCount;
}
int advstring::Replace(advstring asOldValue,advstring asNewValue)
{
int nReplaceCount(0);
if(asOldValue.m_sValue.empty())
return 0;
size_t start_pos = 0;
while((start_pos = this->m_sValue.find(asOldValue.m_sValue, start_pos)) != std::string::npos)
{
this->m_sValue.replace(start_pos, asOldValue.m_sValue.length(), asNewValue.m_sValue);
start_pos += asNewValue.m_sValue.length();
nReplaceCount++;
}
return nReplaceCount;
}
void advstring::Remove(char chRemValue)
{
int sSize = this->m_sValue.size();
for(int x = 0;x< sSize;x++)
{
char chCurChar = this->m_sValue[x];
if(chCurChar == chRemValue)
{
this->m_sValue.erase(x,1);
x--;
sSize--;
}
}
}
int advstring::Find(char chFindValue,int nIndex)
{
int nFindedPlace(-1);
int sSize = this->m_sValue.size();
assert (0 <= nIndex);
for(int x = nIndex;x< sSize;x++)
{
char chCurChar = this->m_sValue[x];
if(chCurChar == chFindValue)
{
nFindedPlace = x;
break;
}
}
return nFindedPlace;
}
int advstring::Find(advstring asFindValue,int nIndex)
{
assert (0 <= nIndex);
return this->m_sValue.find(asFindValue.m_sValue.c_str(),nIndex,asFindValue.m_sValue.size());;
}
int advstring::ReverseFind(char chFindValue)
{
int nFindedPlace(-1);
int sSize = this->m_sValue.size();
for(int x = sSize-1;x >= 0;x--)
{
char chCurChar = this->m_sValue[x];
if(chCurChar == chFindValue)
{
nFindedPlace = x;
break;
}
}
return nFindedPlace;
}
int advstring::ReverseFind(advstring asFindValue)
{
return this->m_sValue.rfind(asFindValue.m_sValue);
}
advstring advstring::Mid(int nIndex, int nCount)
{
advstring tmp = "";
if (nIndex < 0)
nIndex = 0;
if (nCount < 0)
nCount = 0;
int nLength = this->m_sValue.size();
if((nIndex+ nCount) > nLength)
{
nCount = nLength - nIndex;
}
if( nIndex > nLength)
{
nCount = 0;
}
if(nCount != 0)
{
tmp = this->m_sValue.substr(nIndex, nCount);
}
return tmp;
}
int advstring::Compare(advstring asCompValue)
{
return this->m_sValue.compare(asCompValue.m_sValue);
}
void advstring::Format(const char* pcchValue, ...)
{
va_list args;
va_start (args, pcchValue);
int size = vsnprintf(NULL, 0, pcchValue, args);
this->m_sValue.resize(size);
vsnprintf ((char*)this->m_sValue.c_str(),size+1,pcchValue, args);
va_end (args);
}
void advstring::ReleaseBuffer()
{
this->m_sValue.resize(0);
}
advstring advstring::Left(int nIndex)
{
// nCount is in XCHARs
if (nIndex < 0)
nIndex = 0;
int nLength = this->m_sValue.size();
if( nIndex >= nLength )
{
return( *this );
}
else
{
return advstring(this->m_sValue.substr(0,nIndex));
}
}
advstring advstring::Right(int nIndex )
{
if (nIndex < 0)
nIndex = 0;
int nLength = this->m_sValue.size();
if( nIndex >= nLength )
{
return( *this );
}
else
{
return advstring(this->m_sValue.substr(nLength-nIndex,nIndex));
}
}
void advstring::Append(advstring asAppString)
{
this->m_sValue = this->m_sValue + asAppString.m_sValue;
}
void advstring::AppendChar(char chApp)
{
int nLength = this->m_sValue.size();
this->m_sValue.insert(nLength,1,chApp);
}
int advstring::FileWrite(advstring asFpath)
{
FILE *fKeyFile;
fKeyFile = fopen(asFpath.GetBuffer(), "w");
if(fKeyFile != NULL)
{
fprintf(fKeyFile, "%s", this->m_sValue.c_str());
fclose(fKeyFile);
return 1;
}
else
{
return -1;
}
}
int advstring::FileAppend(advstring asFpath)
{
FILE *fKeyFile;
fKeyFile = fopen(asFpath.GetBuffer(), "a");
if(fKeyFile != NULL)
{
fprintf(fKeyFile, "%s", this->m_sValue.c_str());
fclose(fKeyFile);
return 1;
}
else
{
return -1;
}
}
int advstring::FileAppendWithDateTime(advstring asFpath)
{
std::string sWriString = GetDateTime("[%Y/%m/%d %H:%M:%S] ") + this->m_sValue + "\n";
FILE *fKeyFile;
fKeyFile = fopen(asFpath.GetBuffer(), "a");
if(fKeyFile != NULL)
{
fprintf(fKeyFile, "%s", sWriString.c_str());
fclose(fKeyFile);
return 1;
}
else
{
return -1;
}
}
int advstring::FileRead(advstring asFpath)
{
FILE *OldKeyFile;
if((OldKeyFile = fopen(asFpath.GetBuffer(), "r")) != NULL)
{
fseek(OldKeyFile, 0, SEEK_END);
size_t size = ftell(OldKeyFile);
this->m_sValue.resize(size);
rewind(OldKeyFile);
fread((char*)this->m_sValue.c_str(), sizeof(char), this->m_sValue.size(), OldKeyFile);
fclose(OldKeyFile);
return 1;
}
else
{
this->m_sValue = "";
return -1;
}
}
int advstring::SetCurDateTime()
{
this->m_sValue = GetDateTime("%Y/%m/%d %H:%M:%S");
return 1;
}
int advstring::SetCurTime()
{
this->m_sValue = GetDateTime("%H:%M:%S");
return 1;
}
int advstring::SetCurDateTimeStamp()
{
this->m_sValue = GetDateTime("%Y%m%d%H%M%S");
return 1;
}
int advstring::AppCurDateTime()
{
this->m_sValue += GetDateTime("%Y/%m/%d %H:%M:%S");
return 1;
}
int advstring::AppCurTime()
{
this->m_sValue += GetDateTime("%H:%M:%S");
return 1;
}
int advstring::AppCurDateTimeStamp()
{
this->m_sValue += GetDateTime("%Y%m%d%H%M%S");
return 1;
}
void advstring::AppendFormat(const char* pcchValue, ...)
{
std::string sFormatedString;
va_list args;
va_start (args, pcchValue);
int size = vsnprintf(NULL, 0, pcchValue, args);
sFormatedString.resize(size);
vsnprintf ((char*)sFormatedString.c_str(),size+1,pcchValue, args);
va_end (args);
this->m_sValue += sFormatedString;
}
void advstring::FormatV(const char* pcchValue,va_list args)
{
int size = vsnprintf(NULL, 0, pcchValue, args);
this->m_sValue.resize(size);
vsnprintf ((char*)this->m_sValue.c_str(),size+1,pcchValue, args);
}
void advstring::AppendFormatV(const char* pcchValue,va_list args)
{
std::string sFormatValue;
int size = vsnprintf(NULL, 0, pcchValue, args);
sFormatValue.resize(size);
vsnprintf ((char*)sFormatValue.c_str(),size+1,pcchValue, args);
this->m_sValue += sFormatValue;
}
advstring advstring::MakeReverse()
{
std::reverse(this->m_sValue.begin(),this->m_sValue.end());
return this->m_sValue;
}
advstring advstring::MakeLower()
{
std::transform(this->m_sValue.begin(), this->m_sValue.end(), this->m_sValue.begin(), ::tolower);
return this->m_sValue;
}
advstring advstring::MakeUpper()
{
std::transform(this->m_sValue.begin(), this->m_sValue.end(), this->m_sValue.begin(), ::toupper);
return this->m_sValue;
}
int advstring::CompareNoCase(advstring asCompValue)
{
std::string sCurLower = this->m_sValue;
std::transform(sCurLower.begin(),sCurLower.end(), sCurLower.begin(), ::tolower);
std::transform(asCompValue.m_sValue.begin(),asCompValue.m_sValue.end(), asCompValue.m_sValue.begin(), ::tolower);
return sCurLower.compare(asCompValue.m_sValue);
}
int advstring::IsLower()
{
std::string sCurLower = this->m_sValue;
std::transform(sCurLower.begin(),sCurLower.end(), sCurLower.begin(), ::tolower);
return sCurLower.compare(this->m_sValue);
}
int advstring::IsUpper()
{
std::string sCurLower = this->m_sValue;
std::transform(sCurLower.begin(),sCurLower.end(), sCurLower.begin(), ::toupper);
return sCurLower.compare(this->m_sValue);
}
void advstring::Swap(advstring &asSwap)
{
advstring asTemp = asSwap;
asSwap.m_sValue = this->m_sValue;
this->m_sValue = asTemp.m_sValue;
}
advstring advstring::GetCurDateTime()
{
return advstring(GetDateTime("%Y/%m/%d %H:%M:%S"));
}
advstring advstring::GetCurTime()
{
return advstring(GetDateTime("%H:%M:%S"));
}
advstring advstring::GetCurDateTimeStamp()
{
return advstring(GetDateTime("%Y%m%d%H%M%S"));
}
advstring advstring::GetCurDate()
{
return advstring(GetDateTime("%Y/%m/%d"));
}
int advstring::SetCurDate()
{
this->m_sValue = GetDateTime("%Y/%m/%d");
return 1;
}
int advstring::AppCurDate()
{
this->m_sValue += GetDateTime("%Y/%m/%d");
return 1;
}
advstring advstring::GetXOREncryptedData(advstring asKey)
{
int nKeyLen = asKey.GetLength(),nDataSize = this->m_sValue.size();
std::string sOutPut;
sOutPut.resize(nDataSize);
for (int i = 0; i < nDataSize; i++)
sOutPut[i] = this->m_sValue[i] ^ asKey.m_sValue[i % nKeyLen];
return advstring(sOutPut);
}
advstring advstring::GetXORDecryptedData(advstring asKey)
{
int nKeyLen = asKey.GetLength(),nDataSize = this->m_sValue.size();
std::string sOutPut;
sOutPut.resize(nDataSize);
for (int i = 0; i < nDataSize; i++)
sOutPut[i] = this->m_sValue[i] ^ asKey.m_sValue[i % nKeyLen];
return advstring(sOutPut);
}
int advstring::SetXOREncryptedData(advstring asKey)
{
int nKeyLen = asKey.GetLength(),nDataSize = this->m_sValue.size();
for (int i = 0; i < nDataSize; i++)
this->m_sValue[i] = this->m_sValue[i] ^ asKey.m_sValue[i % nKeyLen];
return 1;
}
int advstring::SetXORDecryptedData(advstring asKey)
{
int nKeyLen = asKey.GetLength(),nDataSize = this->m_sValue.size();
for (int i = 0; i < nDataSize; i++)
this->m_sValue[i] = this->m_sValue[i] ^ asKey.m_sValue[i % nKeyLen];
return 1;
}
int advstring::AppXOREncryptedData(advstring asKey)
{
int nKeyLen = asKey.GetLength(),nDataSize = this->m_sValue.size();
std::string sOutPut;
sOutPut.resize(nDataSize);
for (int i = 0; i < nDataSize; i++)
sOutPut[i] = this->m_sValue[i] ^ asKey.m_sValue[i % nKeyLen];
this->m_sValue += sOutPut;
return 1;
}
int advstring::AppXORDecryptedData(advstring asKey)
{
int nKeyLen = asKey.GetLength(),nDataSize = this->m_sValue.size();
std::string sOutPut;
sOutPut.resize(nDataSize);
for (int i = 0; i < nDataSize; i++)
sOutPut[i] = this->m_sValue[i] ^ asKey.m_sValue[i % nKeyLen];
this->m_sValue += sOutPut;
return 1;
}
std::string* advstring::GetData()
{
return &this->m_sValue;
}
advstring advstring::Trim()
{
size_t startpos = this->m_sValue.find_first_not_of(" \n\r\t");
if(startpos != std::string::npos) this->m_sValue = this->m_sValue.substr(startpos);
size_t endpos = this->m_sValue.find_last_not_of(" \n\r\t");
if(endpos != std::string::npos) this->m_sValue = this->m_sValue.substr(0,endpos+1);
return advstring(this->m_sValue);
}
advstring advstring::TrimLeft()
{
size_t startpos = this->m_sValue.find_first_not_of(" \n\r\t");
if(startpos != std::string::npos) this->m_sValue = this->m_sValue.substr(startpos);
return advstring(this->m_sValue);
}
advstring advstring::TrimRight()
{
size_t endpos = this->m_sValue.find_last_not_of(" \n\r\t");
if(endpos != std::string::npos) this->m_sValue = this->m_sValue.substr(0,endpos+1);
return advstring(this->m_sValue);
}
advstring advstring::Trim(char chTrim)
{
size_t startpos = this->m_sValue.find_first_not_of(chTrim);
if(startpos != std::string::npos) this->m_sValue = this->m_sValue.substr(startpos);
size_t endpos = this->m_sValue.find_last_not_of(chTrim);
if(endpos != std::string::npos) this->m_sValue = this->m_sValue.substr(0,endpos+1);
return advstring(this->m_sValue);
}
advstring advstring::TrimLeft(char chTrim)
{
size_t startpos = this->m_sValue.find_first_not_of(chTrim);
if(startpos != std::string::npos) this->m_sValue = this->m_sValue.substr(startpos);
return advstring(this->m_sValue);
}
advstring advstring::TrimRight(char chTrim)
{
size_t endpos = this->m_sValue.find_last_not_of(chTrim);
if(endpos != std::string::npos) this->m_sValue = this->m_sValue.substr(0,endpos+1);
return advstring(this->m_sValue);
}
advstring advstring::Trim(advstring asTrim)
{
size_t startpos = this->m_sValue.find_first_not_of(asTrim.m_sValue);
if(startpos != std::string::npos) this->m_sValue = this->m_sValue.substr(startpos);
size_t endpos = this->m_sValue.find_last_not_of(asTrim.m_sValue);
if(endpos != std::string::npos) this->m_sValue = this->m_sValue.substr(0,endpos+1);
return advstring(this->m_sValue);
}
advstring advstring::TrimLeft(advstring asTrim)
{
size_t startpos = this->m_sValue.find_first_not_of(asTrim.m_sValue);
if(startpos != std::string::npos) this->m_sValue = this->m_sValue.substr(startpos);
return advstring(this->m_sValue);
}
advstring advstring::TrimRight(advstring asTrim)
{
size_t endpos = this->m_sValue.find_last_not_of(asTrim.m_sValue);
if(endpos != std::string::npos) this->m_sValue = this->m_sValue.substr(0,endpos+1);
return advstring(this->m_sValue);
}