DATAKIT SDK  V2026.2
dtk_string.hpp
Go to the documentation of this file.
1 #ifdef A93938D6857511E1B78E58294824019B
2 # include "util/external/dtk_string_alt.hpp"
3 #else
4 
5 #ifndef __DTK_STRING_HPP__
6 #define __DTK_STRING_HPP__
7 
8 #ifdef _MSC_VER
9 # pragma warning(disable:4786)
10 # pragma warning(disable:4800)
11 #endif
12 
13 #include "def/define.h"
14 #include "util/util_stl_dtk.hpp"
15 #include <cstdio>
16 #include <string>
17 
18 
19 
20 #ifdef _MSC_VER
21 # if (_MSC_VER > 1200)
22 # define Dtk_defined__wchar_t
23 # endif
24 #endif
25 class Dtk_status;
26 #if ( defined(Dtk_defined__wchar_t) && defined(_NATIVE_WCHAR_T_DEFINED) )
27 //#pragma message("_NATIVE_WCHAR_T_DEFINED")
28 # define w_str _w_str_w
29 #else
30 # define w_str _w_str_us
31 #endif
32 
33 #define DTK_A Dtk_string(L"a")
34 #define DTK_AB Dtk_string(L"ab")
35 #define DTK_RB Dtk_string(L"rb")
36 #define DTK_RBP Dtk_string(L"rb+")
37 #define DTK_R Dtk_string(L"r")
38 #define DTK_W Dtk_string(L"w")
39 #define DTK_WP Dtk_string(L"w+")
40 #define DTK_WB Dtk_string(L"wb")
41 #define DTK_WBP Dtk_string(L"wb+")
42 #define DTK_RW Dtk_string(L"rw")
43 
44 //! \ingroup base_types
45 //! \class Dtk_string
46 //! \brief This is a high level string class.
47 //!
48 //! This class lets you use ASCII or UNICODE strings.
49 //! It also has some File fonctions
50 
51 
53 {
54 public:
55  typedef size_t Size_t;
56 protected:
57  //! \brief Internal representation of the string
59  //! \brief compatibility ASCII representation. WARNING this field is not always up to date.
60  mutable char * m_CStr;
61  //! \brief size of m_Str buffer
62  //This fields holds in memory the value of wcslen(m_Str). Caution : it may not be updated in case of user manipulation, if so, the Dtk_string is flagged as dirty (see isDirty()).
63  //Due to the use of the last byte to hold this flag, any Dtk_string of size > 2^8 will wrongly be considered dirty
64  mutable Size_t m_StrSize;
65  //! \brief size of m_CStr buffer
66  mutable Size_t m_CStrSize;
67 private:
68  //! \brief Init
69  void init();
70  void UpdateLen() const;
71 protected:
72  void _FillFromCharBuffer( const char* inBuffer, const Dtk_Size_t inSize = ( Dtk_Size_t )-1 );
73 
74 public:
75  //! \brief Default destructors
77  //! \brief Default constructor
79  //! \brief constructor from a char * (ASCII string)
80  //! \param s the ASCII string to convert
81  Dtk_string( const char *s );
82  Dtk_string( const char* s, const Dtk_Size_t& inCount );
83  //! \brief copy constructor
84  //! \param s the Dtk_string to copy
85 
86  Dtk_string( const Dtk_string & );
87 
88 #ifndef DTK_NO_CXX11_RVALUE_REFERENCES
89  //! \brief Move constructor
90  //! \param s the Dtk_string to move
91  Dtk_string( Dtk_string && s ) DTK_NOEXCEPT : m_Str( s.m_Str ), m_CStr( s.m_CStr ), m_StrSize( s.m_StrSize ), m_CStrSize( s.m_CStrSize )
92  {
93  s.m_Str = 0;
94  s.m_CStr = 0;
95  s.m_StrSize = 0;
96  s.m_CStrSize = 0;
97  }
98 
99  //! \brief Move assignment operator
100  //! \param s the Dtk_string to move
102  {
103  if( this != &s )
104  {
105  delete[] m_Str;
106  delete[] m_CStr;
107  m_Str = s.m_Str;
108  m_CStr = s.m_CStr;
109  m_StrSize = s.m_StrSize;
110  m_CStrSize = s.m_CStrSize;
111 
112  s.m_Str = 0;
113  s.m_CStr = 0;
114  s.m_StrSize = 0;
115  s.m_CStrSize = 0;
116  }
117 
118  return *this;
119  }
120 #endif
121  //Dtk_string(const int);
122  //! \brief constructor from a double
123  //! \param dbl_val the double value to convert
124  Dtk_string( const double dbl_val );
125  Dtk_string( const double dbl_val, Dtk_Int32 inWithMorePrecision );
126  //! \brief constructor from a float
127  //! \param float_val the float value to convert
128  Dtk_string( const float float_val );
129  void RawCopyFromASCII( const char * inStrToBeCopied, const Dtk_Size_t inCount = -1 );
130  /*************************************/
131  //! \brief Retrieve the ASCII conversion string.
132  //! \return the ASCII string
133  //! \warning You can't modify the returned string !!
134  //!
135  //! \b Sample:
136  //! \code
137  //! Dtk_string res;
138  //! char * tmp_char;
139  //! tmp_char = res.c_str(); //you can't modify the tmp_char value
140  //! \endcode
141  const char * c_str() const;
142 
143  //! \brief Split a Dtk_string into an array of Dtk_string giving a char array
144  //! \param inDelimiters the delimiters string. This string contains each characters used to split the string
145  //! \param outResults the result array
146  //!
147  //! \b Sample:
148  //! \code
149  //! Dtk_string StringToBeSplitted = L"String To Be-Splitted";
150  //! Dtk_string Delimiters = L" -";
151  //! Dtk_tab< Dtk_string > Result;
152  //! StringToBeSplitted.Split( Delimiters, Result);
153  //! //Now Result contains 4 elements
154  //! //Result.at(0) is equal to L"String"
155  //! //Result.at(1) is equal to L"To"
156  //! //Result.at(2) is equal to L"Be"
157  //! //Result.at(3) is equal to L"Splitted"
158  //!
159  //! \endcode
160  void Split( const Dtk_string& inDelimiters, Dtk_tab<Dtk_string>& outResults ) const;
161  void Split( Dtk_WChar_t * inDelimiters, Dtk_tab<Dtk_string>& outResults ) const;
162 
163  //! \brief Retrieve the UNICODE string
164  //! \return the UNICODE string
165  //! \warning You can't modify the returned string !!
166  //!
167  //! \b Sample:
168  //! \code
169  //! Dtk_string res;
170  //! wchar_t * tmp_char;
171  //! tmp_char = res.w_str(); //you can't modify the tmp_char value
172  //! \endcode
173 #if ( defined(Dtk_defined__wchar_t))
174  const unsigned short * _w_str_us() const;
175  const __wchar_t * _w_str_w() const;
176  //! \brief constructor from a wchar_t * (UNICODE string)
177  //! \param s the UNICODE string to convert
178  Dtk_string( const unsigned short *s );
179  //! \brief constructor from a wchar_t * (UNICODE string)
180  //! \param s the UNICODE string to convert
181  Dtk_string( const __wchar_t *s );
182  //! \brief copy the Dtk_string in a char * (UNICODE) string
183  //! \param str the buffer string
184  //!
185  //! \b Sample:
186  //! \code
187  //! Dtk_string s1;
188  //! wchar_t * tmp;
189  //! s1 = L"first string";
190  //! tmp = new wchar_t[s1.len() + 1];
191  //! s1.get_wchar(tmp); //Now tmp is L"first string"
192  //! \endcode
193  //! \warning the str string must be allocated before the method call
194  void get_wchar( unsigned short * str ) const;
195  //! \brief copy the Dtk_string in a char * (UNICODE) string
196  //! \param str the buffer string
197  //!
198  //! \b Sample:
199  //! \code
200  //! Dtk_string s1;
201  //! wchar_t * tmp;
202  //! s1 = L"first string";
203  //! tmp = new wchar_t[s1.len() + 1];
204  //! s1.get_wchar(tmp); //Now tmp is L"first string"
205  //! \endcode
206  //! \warning the str string must be allocated before the method call
207  void get_wchar( __wchar_t * str ) const;
208 
209  int cmp( const unsigned short *s2 ) const;
210  int cmp( const __wchar_t *s2 ) const;
211  int ncmp( const unsigned short *s2, const int count ) const;
212  int ncmp( const __wchar_t *s2, const int count ) const;
213  int icmp( const unsigned short *s2 ) const;
214  int icmp( const __wchar_t *s2 ) const;
215  int nicmp( const unsigned short *s2, const size_t size ) const;
216  int nicmp( const __wchar_t *s2, const size_t size ) const;
217 #else
218  const Dtk_WChar_t * w_str() const;
219  Dtk_string( const Dtk_WChar_t *s );
220  //! \brief copy the Dtk_string in a char * (UNICODE) string
221  //! \param str the buffer string
222  //!
223  //! \b Sample:
224  //! \code
225  //! Dtk_string s1;
226  //! wchar_t * tmp;
227  //! s1 = L"first string";
228  //! tmp = new wchar_t[s1.len() + 1];
229  //! s1.get_wchar(tmp); //Now tmp is L"first string"
230  //! \endcode
231  //! \warning the str string must be allocated before the method call
232  void get_wchar( Dtk_WChar_t * str ) const;
233  int cmp( const Dtk_WChar_t *s2 ) const;
234  int ncmp( const Dtk_WChar_t *s2, const int count ) const;
235  int icmp( const Dtk_WChar_t *s2 ) const;
236  int nicmp( const Dtk_WChar_t *s2, const size_t size ) const;
237 #endif
238 
239  //! \brief affectation operator from a Dtk_string
240  //! \param s the affected value
241  //!
242  //! \b Sample:
243  //! \code
244  //! Dtk_string res("this is a sample");
245  //! Dtk_string tmp;
246  //! tmp = res; //Now tmp is "this is a sample"
247  //! \endcode
249  //! \brief affectation operator from a char (ASCII) string
250  //! \param s the affected value
251  //!
252  //! \b Sample:
253  //! \code
254  //! Dtk_string tmp;
255  //! tmp = "this is a sample"; //Now tmp is "this is a sample"
256  //! \endcode
257  Dtk_string& operator = ( const char* s );
258 
259  //! \brief affectation operator from a float
260  //! \param fltval the affected value (a conversion is made)
261  //!
262  //! \b Sample:
263  //! \code
264  //! Dtk_string tmp;
265  //! tmp = (float)1.0; //Now tmp is "1.0"
266  //! \endcode
267  Dtk_string& operator = ( const float fltval );
268  //! \brief affectation operator from a double
269  //! \param dbl_val the affected value (a conversion is made)
270  //!
271  //! \b Sample:
272  //! \code
273  //! Dtk_string tmp;
274  //! tmp = (double)1.0; //Now tmp is "1.0"
275  //! \endcode
276  Dtk_string& operator = ( const double dbl_val );
277 
278  //! \brief access to a specified letter in the Dtk_string
279  //! \param i the position of the wanted letter
280  //! \return the letter
282  const Dtk_WChar_t& operator[] ( int i ) const;
283 
284  //! \deprecated
285  //SetAsDeprecated( "2021.4", "Use clear() method instead" )
286  void free_mem();
287  //! \brief File Utility : retrieve the file size
288  //! \return The file size if success 0 else
289  //!
290  //! \b Sample:
291  //! \code
292  //! Dtk_string s1;
293  //! Dtk_Size_t size;
294  //! s1 = L"C:\\dir\\dir2\\filename.extension";
295  //! size = s1.FileSize();
296  //! \endcode
298  Dtk_status ToDtkInt32( Dtk_Int32& outRes ) const;
300 
301  //! \brief Converts the Dtk_string to UTF8 string.
302  //! \return The UTF8 String allocated with 'new'. Please use 'delete []' to free it.
303  //!
304  //! \b Sample:
305  //! \code
306  //! Dtk_string tmp = L"30°"; //special ascii string.
307  //! char * UTF8Str = tmp.ToUTF8String(); //UTF8Str is ''
308  //! delete [] UTF8Str; UTF8Str = NULL;
309  //! \endcode
310  char * ToUTF8String() const;
311 
312  Dtk_string Substring( const Dtk_Size_t& inStartIndex, const Dtk_Size_t& inLength ) const;
313  //! \brief clear string data
314  //!
315  //! \b Sample:
316  //! \code
317  //! Dtk_string tmp = L"one_text";
318  //! tmp.clear(); //Now tmp is ""
319  //! \endcode
320  void clear();
321 
322  //! \brief affectation operator from a int
323  //! \param integer the affected value (a conversion is made)
324  //!
325  //! \b Sample:
326  //! \code
327  //! Dtk_string tmp;
328  //! tmp.convert_from_int(1); //Now tmp is "1"
329  //! \endcode
330  void convert_from_int( const int integer, int force_unsigned_int = 0 );
331  void ConvertFromUTF8String( const char * inUTF8String );
332 
333  /*utils functions*/
334  Dtk_bool is_NULL() const;
336  //! \brief Retrieve the length of the Dtk_string
337  //! \return the Dtk_string length
338  //!
339  //! \b Sample:
340  //! \code
341  //! Dtk_string res;
342  //! int length;
343  //! length = res.len();
344  //! \endcode
345  int len() const;
346 
347 
348  //! \brief copy the Dtk_string in a char * (ASCII) string
349  //! \param inoutStr the buffer string. If NULL the method only processes the resulting ASCII length - for buffer allocation -
350  //! \return The ASCII string length.
351  //!
352  //! \b Sample:
353  //! \code
354  //! Dtk_string s1;
355  //! char * tmp = NULL;
356  //! s1 = L"first string";
357  //! Dtk_Size_t Len = s1.get_char(tmp); //We process the resulting string length
358  //! tmp = new char[Len + 1];
359  //! s1.get_char(tmp); //Now tmp is "first string"
360  //! \endcode
361  //! \warning the str string must be allocated before the method call
362  //! \remarks there is a conversion from UNICODE to ASCII string
363  //! so some ugly characters may occur...
364  //SetAsDeprecated( "2021.4", "This method is insecure. Use get_char(char * inoutStr, const Dtk_Size_t inBufferSize ) method instead" )
365  Dtk_Size_t get_char( char * inoutStr ) const;
366  //! \brief concat the Dtk_string with the Dtk_string given in parameter
367  //! \param s2 the Dtk_string to concat
368  //!
369  //! \b Sample:
370  //! \code
371  //! Dtk_string s1,s2;
372  //! s1 = L"first string";
373  //! s2 = L"second string";
374  //! s1.cat(s2); //Now s1 is L"first stringsecond string"
375  //! \endcode
376  //! \remarks this method is similar to operator '+'
377  void cat( const Dtk_string &s2 );
378 
379  //! \brief Converts the Dtk_string to Upper case.
380  //!
381  //! \b Sample:
382  //! \code
383  //! Dtk_string s1 = L"My String";
384  //! s1.ToUpper();
385  //! //Now the s1 is L"MY STRING"
386  //! \endcode
387  void ToUpper();
388 
389  //! \brief Converts the Dtk_string to Lower case.
390  //!
391  //! \b Sample:
392  //! \code
393  //! Dtk_string s1 = L"My String";
394  //! s1.ToLower();
395  //! //Now the s1 is L"my string"
396  //! \endcode
397  void ToLower();
398 
399  //! \brief compare the Dtk_string with the string given in parameter
400  //! \param s2 : Dtk_string to be compared with
401  //! \return > 0 if this is greater than s2, 0 if they are identical, < 0 else
402  //!
403  //! \b Sample:
404  //! \code
405  //! Dtk_string s1,s2;
406  //! ...
407  //! if(s1.cmp(s2) != 0)
408  //! {
409  //! ...
410  //! }
411  //! \endcode
412  //! \remark this method is similar to '==', '<', '>', '>=', '<=', '!=' operators
413  int cmp( const Dtk_string &s2 ) const;
414  //! \brief compare the count first character of the Dtk_string with the string given in parameter
415  //! \param s2 : Dtk_string to be compared with
416  //! \param count : the number of characters to be compared
417  //! \return > 0 if this is greater than s2, 0 if they are identical, < 0 else
418  //!
419  //! \b Sample:
420  //! \code
421  //! Dtk_string s1,s2;
422  //! ...
423  //! if(s1.cmp(s2,3) != 0)
424  //! {
425  //! ...
426  //! }
427  //! \endcode
428  int ncmp( const Dtk_string &s2, const int count ) const;
429  //! \brief Perform a lowercase comparison of strings
430  //! \param s2 : Dtk_string to be compared with
431  //! \return > 0 if this is greater than s2, 0 if they are identical, < 0 else
432  //!
433  //! \b Sample:
434  //! \code
435  //! Dtk_string s1,s2;
436  //! ...
437  //! if(s1.cmp(s2,3) != 0)
438  //! {
439  //! ...
440  //! }
441  //! \endcode
442  int icmp( const Dtk_string &s2 ) const;
443  //! \brief Compare characters of two strings without regard to case.
444  //! \param s2 : Dtk_string to be compared with
445  //! \param size : the number of characters to be compared
446  //! \return > 0 if this is greater than s2, 0 if they are identical, < 0 else
447  //!
448  //! \b Sample:
449  //! \code
450  //! Dtk_string s1,s2;
451  //! ...
452  //! if(s1.cmp(s2,3) != 0)
453  //! {
454  //! ...
455  //! }
456  //! \endcode
457  int nicmp( const Dtk_string &s2, const size_t size ) const;
458  //! \brief copy the Dtk_string given in parameter in the Dtk_string
459  //! \param s2 the Dtk_string to be copied
460  //!
461  //! \b Sample:
462  //! \code
463  //! Dtk_string s1,s2;
464  //! s1 = L"first string";
465  //! s2 = L"second string";
466  //! s1.cpy(s2); //Now s1 is L"second string"
467  //! \endcode
468  //! \remarks this method is similar to operator '='
469  void cpy( Dtk_string s2 );
470  //! \brief copy a number of characters of the Dtk_string in an other Dtk_string
471  //! \param s2 the Dtk_string to be copied
472  //! \param size the number of character to be copied
473  //!
474  //! \b Sample:
475  //! \code
476  //! Dtk_string s1,s2;
477  //! s2 = L"first string";
478  //! s1.ncpy(s2,4); //Now s1 is L"firs"
479  //! \endcode
480  void ncpy( const Dtk_string & s2, size_t size );
481  //! \brief find the position of a substring into a Dtk_string
482  //! \param s1 the searched substring
483  //! \return the position of the first character of the substring if success -1 else
484  //!
485  //! \b Sample:
486  //! \code
487  //! Dtk_string s1,s2;
488  //! int pos;
489  //! s1 = L"first string";
490  //! s2 = L"str";
491  //! pos = s1.find_substring(s2); //Now pos is equal to 6
492  //! \endcode
493  int find_substring( const Dtk_string &s1 ) const;
494  //! \brief find the position of a character into a Dtk_string
495  //! \param car the searched character (UNICODE or ASCII form)
496  //! \return the position of the first occurrence of car if success -1 else
497  //!
498  //! \b Sample:
499  //! \code
500  //! Dtk_string s1;
501  //! int pos;
502  //! s1 = L"first string";
503  //! pos = s1.find_first(L's'); //Now pos is equal to 3
504  //! \endcode
505  int find_first( int character ) const;
506  //! \brief find the position of a character into a Dtk_string
507  //! \param car the searched character (UNICODE or ASCII form)
508  //! \return the position of the last occurrence of car if success -1 else
509  //!
510  //! \b Sample:
511  //! \code
512  //! Dtk_string s1;
513  //! int pos;
514  //! s1 = L"first string";
515  //! pos = s1.find_last(L's'); //Now pos is equal to 6
516  //! \endcode
517  int find_last( int character ) const;
518  //! \brief retrieve the left part of the Dtk_string from a position
519  //! \param pos : start position
520  //! \return the left part of the Dtk_string if success or a NULL Dtk_string else
521  //!
522  //! \b Sample:
523  //! \code
524  //! Dtk_string s1,s2;
525  //! s1 = L"first string";
526  //! s2 = s1.left(3); //Now s2 is equal to L"firs"
527  //! \endcode
528  //! \remark the pivot character is included in the resulted Dtk_string
529  Dtk_string left( int pos ) const;
530  //! \brief retrieve the right part of the Dtk_string from a position
531  //! \param pos : start position
532  //! \return the right part of the Dtk_string if success or a NULL Dtk_string else
533  //!
534  //! \b Sample:
535  //! \code
536  //! Dtk_string s1,s2;
537  //! s1 = L"first string";
538  //! s2 = s1.right(3); //Now s2 is equal to L"st string"
539  //! \endcode
540  //! \remark the pivot character is included in the resulted Dtk_string
541  Dtk_string right( int pos ) const;
542  //! \brief retrieve the left part of the Dtk_string from a position
543  //! \param pos : start position
544  //! \return the left part of the Dtk_string if success or a NULL Dtk_string else
545  //!
546  //! \b Sample:
547  //! \code
548  //! Dtk_string s1,s2;
549  //! s1 = L"first string";
550  //! s2 = s1.left_exclusive(3); //Now s2 is equal to L"fir"
551  //! \endcode
552  //! \remark the pivot character is NOT included in the resulted Dtk_string
553  Dtk_string left_exclusive( int pos ) const;
554  void LeftExclusive( const int& pos, Dtk_string& outRes ) const;
555  //! \brief retrieve the right part of the Dtk_string from a position
556  //! \param pos : start position
557  //! \return the right part of the Dtk_string if success or a NULL Dtk_string else
558  //!
559  //! \b Sample:
560  //! \code
561  //! Dtk_string s1,s2;
562  //! s1 = L"first string";
563  //! s2 = s1.right_exclusive(3); //Now s2 is equal to L"t string"
564  //! \endcode
565  //! \remark the pivot character is NOT included in the resulted Dtk_string
566  Dtk_string right_exclusive( int pos ) const;
567  void RightExclusive( const int& pos, Dtk_string& outRes ) const;
568 
569  //! \brief Removes all occurrences of a given char at the beginning - leading - or the end - trailing - into the Dtk_string
570  //! \param inCharToBeTrimmed the searched Dtk_WChar_t
571  //! \param inTrimLeadingCharacters DTK_TRUE If you want to trim leading characters. DTK_FALSE otherwise. DTK_TRUE by default.
572  //! \param inTrimTrailingCharacters DTK_TRUE If you want to trim leading characters. DTK_FALSE otherwise. DTK_TRUE by default.
573  //!
574  //! \b Sample:
575  //! \code
576  //! Dtk_string s1;
577  //! s1 = L" Test Test Test ";
578  //! s1.TrimCharacters( ' ', DTK_TRUE, DTK_FALSE ); //Trim only leading ' ' characters
579  //! //Now the string equals L"Test Test Test "
580  //! \endcode
581  void TrimCharacters( const Dtk_WChar_t inCharToBeTrimmed,
582  const Dtk_bool inTrimLeadingCharacters = DTK_TRUE,
583  const Dtk_bool inTrimTrailingCharacters = DTK_TRUE );
584  //! \brief Removes all occurrences of a given char at the beginning - leading - and the end - trailing - into the Dtk_string
585  //! \param inCharToBeTrimmed the searched Dtk_WChar_t
586  //!
587  //! \b Sample:
588  //! \code
589  //! Dtk_string s1;
590  //! s1 = L" Test Test Test ";
591  //! s1.TrimLeadingCharacters( ' ' );
592  //! //Now the string equals L"Test Test Test "
593  //! \endcode
594  inline void TrimLeadingCharacters( const Dtk_WChar_t inCharToBeTrimmed )
595  {
596  TrimCharacters( inCharToBeTrimmed, DTK_TRUE, DTK_FALSE );
597  }
598  //! \brief Removes all occurrences of a given char at the end - trailing - into the Dtk_string
599  //! \param inCharToBeTrimmed the searched Dtk_WChar_t
600  //!
601  //! \b Sample:
602  //! \code
603  //! Dtk_string s1;
604  //! s1 = L" Test Test Test ";
605  //! s1.TrimTrailingCharacters( ' ' );
606  //! //Now the string equals L" Test Test Test"
607  //! \endcode
608  inline void TrimTrailingCharacters( const Dtk_WChar_t inCharToBeTrimmed )
609  {
610  TrimCharacters( inCharToBeTrimmed, DTK_FALSE, DTK_TRUE );
611  }
612  //! \brief Removes all occurrences of a given char at the beginning - leading - and the end - trailing - into the Dtk_string
613  //! \param inCharToBeTrimmed the searched Dtk_WChar_t
614  //!
615  //! \b Sample:
616  //! \code
617  //! Dtk_string s1;
618  //! s1 = L" Test Test Test ";
619  //! s1.TrimLeadingAndTrailingCharacters( ' ' );
620  //! //Now the string equals L"Test Test Test"
621  //! \endcode
622  inline void TrimLeadingAndTrailingCharacters( const Dtk_WChar_t inCharToBeTrimmed )
623  {
624  TrimCharacters( inCharToBeTrimmed, DTK_TRUE, DTK_TRUE );
625  }
626  //! \brief Counts all the occurrences of a given substring into the Dtk_string
627  //! \param substring the searched substring
628  //! \return the occurrences number of the substring.
629  //!
630  //! \b Sample:
631  //! \code
632  //! Dtk_string s1;
633  //! Dtk_string s2;
634  //! int nb;
635  //! s1 = L"first string. Second string";
636  //! s2 = L"string";
637  //! nb = s1.count_substring_occurrences(s2); //Now nb is equal to 2
638  //! \endcode
639  int count_substring_occurrences( const Dtk_string &substring ) const;
640  //! \brief Counts all the occurrences of a given character into the Dtk_string
641  //! \param car the searched substring
642  //! \return the occurrences number of the car.
643  //!
644  //! \b Sample:
645  //! \code
646  //! Dtk_string s1;
647  //! int nb;
648  //! s1 = L"occurrences";
649  //! nb = s1.count_char_occurrences('c'); //Now nb is equal to 3
650  //! \endcode
651  int count_char_occurrences( const int car ) const;
652 
653  //! \brief File Utility: Splits Fullpath into drive/path/filename/extension
654  //! \param[out] drive: drive buffer or NULL if not wanted...
655  //! \param[out] path: path buffer or NULL if not wanted...
656  //! \param[out] filename: filename buffer or NULL if not wanted...
657  //! \param[out] extension: extension buffer or NULL if not wanted...
658  //! \return always 1
659  //!
660  //! \b Sample:
661  //! \code
662  //! Dtk_string s1;
663  //! Dtk_string drive,path,filename,ext;
664  //!
665  //! s1 = L"c:\\toto\\tata\\titi\\tutu.tete";
666  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
667  //! //drive = L"c:"
668  //! //path = L"\toto\tata\titi\"
669  //! //filename = L"tutu"
670  //! //ext = L"tete"
671  //!
672  //! s1 = L"/toto/tata/titi/tutu.tete ";
673  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
674  //! //drive = L""
675  //! //path = L"/toto/tata/titi/"
676  //! //filename = L"tutu"
677  //! //ext = L"tete"
678  //!
679  //! s1 = L"toto/tata/titi/tutu.tete";
680  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
681  //! //drive = L""
682  //! //path = L"toto/tata/titi/"
683  //! //filename = L"tutu"
684  //! //ext = L"tete"
685  //!
686  //! s1 = L"../tata/titi/tutu.tete";
687  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
688  //! //drive = L""
689  //! //path = L"../tata/titi/"
690  //! //filename = L"tutu"
691  //! //ext = L"tete"
692  //!
693  //! s1 = L"tutu";
694  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
695  //! //drive = L""
696  //! //path = L""
697  //! //filename = L"tutu"
698  //! //ext = L""
699  //!
700  //! s1 = L"titi/.tutu";
701  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
702  //! //drive = L""
703  //! //path = L"titi/"
704  //! //filename = L""
705  //! //ext = L"tutu"
706  //!
707  //! s1 = L".tutu.tete";
708  //! s1.traite_nom_fichier(&drive,&path,&filename,&ext);
709  //! //drive = L""
710  //! //path = L""
711  //! //filename = L".tutu"
712  //! //ext = L"tete"
713  //!
714  //! \endcode
715  //SetAsDeprecated( "2024.2", "" )
717  Dtk_string * drive,
718  Dtk_string * path,
720  Dtk_string * extension ) const;
721  //! \brief Replaces all occurrences of a character in a string with a new character.
722  //! \param old_char : character to be replaced
723  //! \param new_char : character to replace
724  //!
725  //! \b Sample:
726  //! \code
727  //! Dtk_string s1;
728  //! s1 = L"first string";
729  //! s1.replace(L's', L't'); // Now s1 is equal to L"firtt ttring"
730  //! \endcode
731  int replace( const int& old_char, const int& new_char );
732  //! \brief Removes all occurrences of a character in a string.
733  //! \param removed_char : character to be removed
734  //!
735  //! \b Sample:
736  //! \code
737  //! Dtk_string s1;
738  //! s1 = L"first string";
739  //! s1.removechar(L'r'); // Now s1 is equal to L"fist sting"
740  //! \endcode
741  int removechar( const int& removed_char );
742 
743  //! \brief File Utility : Retrieves the drive in Dtk_string form
744  //! \return the drive string
745  //!
746  //! \b Sample:
747  //! \code
748  //! Dtk_string s1,res;
749  //! s1 = L"C:\\dir\\dir2\\filename.extension";
750  //! res = s1.drive(); //result is L"C:"
751  //! \endcode
752  Dtk_string drive() const;
753  //! \brief File Utility : Retrieves the path in Dtk_string form
754  //! \return the path string
755  //!
756  //! \b Sample:
757  //! \code
758  //! Dtk_string s1,res;
759  //! s1 = L"C:\\dir\\dir2\\filename.extension";
760  //! res = s1.path(); //result is L"\dir\dir2\"
761  //! \endcode
762  Dtk_string path() const;
763  //! \brief File Utility : Retrieves the filename in Dtk_string form
764  //! \return the filename string
765  //!
766  //! \b Sample:
767  //! \code
768  //! Dtk_string s1,res;
769  //! s1 = L"C:\\dir\\dir2\\filename.extension";
770  //! res = s1.filename(); //result is L"filename"
771  //! \endcode
773  //! \brief File Utility : Retrieves the extension in Dtk_string form
774  //! \return the extension string
775  //!
776  //! \b Sample:
777  //! \code
778  //! Dtk_string s1,res;
779  //! s1 = L"C:\\dir\\dir2\\filename.extension";
780  //! res = s1.extension(); //result is L"extension"
781  //! \endcode
783  int test_extension( const Dtk_string &ext ) const;
784 
785  //! \brief File Utility : Retrieves the full path in Dtk_string form
786  //! \return the full path string
787  //!
788  //! \b Sample:
789  //! \code
790  //! Dtk_string s1,res;
791  //! s1 = L"C:\\dir\\dir2\\filename.extension";
792  //! s1.FullPath( res ); //res == L"C:/dir/dir2/"
793  //! \endcode
794  //! \remark the full path '\\' are converted into '/'.
795  void FullPath( Dtk_string& outFullPath ) const;
796 
797  //! \brief File Utility : Retrieves the filename extension in Dtk_string form
798  //! \return the filename extension string
799  //!
800  //! \b Sample:
801  //! \code
802  //! Dtk_string s1,res;
803  //! s1 = L"C:\\dir\\dir2\\filename.extension";
804  //! s1.FileNameExtension( res ); //res == L"filename.extension"
805  //! \endcode
806  void FileNameExtension( Dtk_string& outFileNameExtension ) const;
807 
808  //int test_extension(const char *ext);
809  //int test_extension(const wchar_t * ext);
810  //! \brief File Utility : Open a file with the given rights
811  //! \param droits the given rights (in ASCII, UNICODE or Dtk_string form
812  //! - you can use define such as 'DTK_A' or 'DTK_WP' for example - )
813  //! \return the FILE * pointer if success or NULL else
814  //!
815  //! \b Sample:
816  //! \code
817  //! Dtk_string s1;
818  //! FILE * res;
819  //! s1 = L"C:\\dir\\dir2\\filename.extension";
820  //! res = s1.ouvrir_fichier(DTK_WP);
821  //! if(res)
822  //! fclose(res); // We close the file
823  //! \endcode
824  FILE * ouvrir_fichier( const Dtk_string &droits ) const;
825 
826  //! \brief File Utility : Open a file with the given rights
827  //! \param inRights the given rights (in ASCII, UNICODE or Dtk_string form
828  //! - you can use define such as 'DTK_A' or 'DTK_WP' for example - )
829  //! \return the FILE * pointer if success or NULL else
830  //!
831  //! \b Sample:
832  //! \code
833  //! Dtk_string s1;
834  //! FILE * res;
835  //! s1 = L"C:\\dir\\dir2\\filename.extension";
836  //! res = s1.OpenFile(DTK_WP);
837  //! if(res)
838  //! fclose(res); // We close the file
839  //! \endcode
840  FILE * OpenFile( const Dtk_string &inRights ) const;
841 
842  //! \brief File Utility : Delete a file
843  //! \return 0 if success -1 else
844  //!
845  //! \b Sample:
846  //! \code
847  //! Dtk_string s1;
848  //! FILE * res;
849  //! s1 = L"C:\\dir\\dir2\\filename.extension";
850  //! res = s1.ouvrir_fichier(DTK_WP);
851  //! if(res)
852  //! {
853  //! fclose(res); // We close the file
854  //! s1.unlink(); // We delete the file
855  //! }
856  //! \endcode
857  int unlink() const;
858  //! \brief File Utility : Create a Directory
859  //! \return 0 if success -1 else
860  //!
861  //! \b Sample:
862  //! \code
863  //! Dtk_string s1;
864  //! FILE * res;
865  //! s1 = L"C:\\dir\\dir2\\";
866  //! res = s1.mkdir();
867  //! \endcode
868  int mkdir() const;
869  int rmdir() const;
870  //! \brief File Utility : tests if a file exists
871  //! \return true if file exists false else
872  //!
873  //! \b Sample:
874  //! \code
875  //! Dtk_string s1;
876  //! Dtk_bool res;
877  //! s1 = L"C:\\dir\\dir2\\filename.extension";
878  //! res = s1.existe_fichier();
879  //! if(res)
880  //! {
881  //! s1.unlink(); // We delete the file
882  //! }
883  //! \endcode
885  //! \deprecated Use FileSize() method instead
886  SetAsDeprecated( "2022.3", "Use FileSize() method instead" )
887  long taille_fichier() const;
888 
889  //! \brief File Utility : retrieve The OS Path Separator as char.
890  //! \return '\\' on Windows/Cygwin, '/' otherwise.
891  inline static const char PathSeparatorChar()
892  {
893 # if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
894  return '\\';
895 # else
896  return '/';
897 # endif
898  }
899  //! \brief File Utility : Retrieves The OS Path Separator as Dtk_WChar_t.
900  //! \return L'\\' on Windows/Cygwin, L'/' otherwise.
901  inline static const Dtk_WChar_t PathSeparatorWChar()
902  {
903 # if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
904  return L'\\';
905 # else
906  return L'/';
907 # endif
908  }
909  //! \brief File Utility : Retrieves The OS Path Separator as Dtk_string.
910  //! \return "\\" on Windows/Cygwin, "/" otherwise.
911  inline static const Dtk_string PathSeparatorString()
912  {
913 # if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
914  return L"\\";
915 # else
916  return "/";
917 # endif
918  }
919 
920  //! \brief File Utility : Fixes path separator consistency.
921  //! It lets you replace the '\' or '/' by the OS needed separator.
922  //! \remark It uses the PathSeparatorChar method to get the correct path separator.
923  //!
924  //! \b Sample:
925  //! \code
926  //! Dtk_string s1;
927  //! s1 = L"\\dir/dir2\\filename.extension";
928  //! s1.FixPathSeparator();
929  //! On Windows the path is now L"\\dir\\dir2\\filename.extension"
930  //! On Linux/MacOS the path is now L"/dir/dir2/filename.extension"
931  //! \endcode
933 
934  //! \brief concat two Dtk_string
935  //! \param s1 the first Dtk_string to concat
936  //! \param s2 the second Dtk_string to concat
937  //! \return the resulting Dtk_string
938  //!
939  //! \b Sample:
940  //! \code
941  //! Dtk_string s1,s2,res;
942  //! s1 = L"first string";
943  //! s2 = L"second string";
944  //! res = s1 + s2; //Now res is L"first stringsecond string"
945  //! \endcode
946  friend Dtk_string operator + ( const Dtk_string &s1, const Dtk_string &s2 );
947 
948  //! \brief concat an int to the Dtk_string (convert the int to Dtk_string)
949  //! \param integer the int to concat
950  //!
951  //! \b Sample:
952  //! \code
953  //! Dtk_string s1,res;
954  //! int val;
955  //! s1 = L"first string";
956  //! val = 2;
957  //! s1.add_int(val); //Now res is L"first string2"
958  //! \endcode
959  void add_int( const int integer, int force_unsigned_int = 0 );
960 
961  void Merge( const Dtk_string &s2 );
963 
964  //! \brief compare two Dtk_string
965  //! \param s1 the first Dtk_string to compare
966  //! \param s2 the second Dtk_string to compare
967  //! \return true if they are identical false else
968  //!
969  //! \b Sample:
970  //! \code
971  //! Dtk_string s1,s2;
972  //! ...
973  //! if(s1 == s2)
974  //! {
975  //! ...
976  //! }
977  //! \endcode
978  friend bool operator == ( const Dtk_string &s1, const Dtk_string &s2 );
979  //! \brief compare two Dtk_string
980  //! \param s1 the first Dtk_string to compare
981  //! \param s2 the second Dtk_string to compare
982  //! \return true if s1 is greater than s2 false else
983  //!
984  //! \b Sample:
985  //! \code
986  //! Dtk_string s1,s2;
987  //! ...
988  //! if(s1 > s2)
989  //! {
990  //! ...
991  //! }
992  //! \endcode
993  friend bool operator > ( const Dtk_string &s1, const Dtk_string &s2 );
994  //! \brief compare two Dtk_string
995  //! \param s1 the first Dtk_string to compare
996  //! \param s2 the second Dtk_string to compare
997  //! \return true if s1 is smaller than s2 false else
998  //!
999  //! \b Sample:
1000  //! \code
1001  //! Dtk_string s1,s2;
1002  //! ...
1003  //! if(s1 < s2)
1004  //! {
1005  //! ...
1006  //! }
1007  //! \endcode
1008  friend bool operator < ( const Dtk_string &s1, const Dtk_string &s2 );
1009  //! \brief compare two Dtk_string
1010  //! \param s1 the first Dtk_string to compare
1011  //! \param s2 the second Dtk_string to compare
1012  //! \return true if s1 is greater or equal than s2 false else
1013  //!
1014  //! \b Sample:
1015  //! \code
1016  //! Dtk_string s1,s2;
1017  //! ...
1018  //! if(s1 >= s2)
1019  //! {
1020  //! ...
1021  //! }
1022  //! \endcode
1023  friend bool operator >= ( const Dtk_string &s1, const Dtk_string &s2 );
1024  //! \brief compare two Dtk_string
1025  //! \param s1 the first Dtk_string to compare
1026  //! \param s2 the second Dtk_string to compare
1027  //! \return true if s1 is smaller or equal than s2 false else
1028  //!
1029  //! \b Sample:
1030  //! \code
1031  //! Dtk_string s1,s2;
1032  //! ...
1033  //! if(s1 <= s2)
1034  //! {
1035  //! ...
1036  //! }
1037  //! \endcode
1038  friend bool operator <= ( const Dtk_string &s1, const Dtk_string &s2 );
1039  //! \brief compare two Dtk_string
1040  //! \param s1 the first Dtk_string to compare
1041  //! \param s2 the second Dtk_string to compare
1042  //! \return true if s1 is different of s2 false else
1043  //!
1044  //! \b Sample:
1045  //! \code
1046  //! Dtk_string s1,s2;
1047  //! ...
1048  //! if(s1 != s2)
1049  //! {
1050  //! ...
1051  //! }
1052  //! \endcode
1053  friend bool operator != ( const Dtk_string &s1, const Dtk_string &s2 );
1054  friend std::ostream& operator<<( std::ostream&, const Dtk_string& );
1055 
1056 
1057 
1058 };
1059 
1061 {
1062  std::string ToUtf8( wchar_t const * );
1063  std::string ToUtf8( Dtk_string const & );
1064 
1065  Dtk_string FromUtf8( char const * );
1066 }
1067 
1068 
1069 #endif // __DTK_STRING_HPP__
1070 
1071 #endif // A93938D6857511E1B78E58294824019B
1072 
Dtk_string::ConvertFromUTF8String
void ConvertFromUTF8String(const char *inUTF8String)
Dtk_string::free_mem
void free_mem()
Dtk_string::rmdir
int rmdir() const
Dtk_string::Dtk_string
Dtk_string(const char *s)
constructor from a char * (ASCII string)
Dtk_string::operator==
friend bool operator==(const Dtk_string &s1, const Dtk_string &s2)
compare two Dtk_string
Dtk_string::cmp
int cmp(const Dtk_WChar_t *s2) const
Dtk_string::operator!=
friend bool operator!=(const Dtk_string &s1, const Dtk_string &s2)
compare two Dtk_string
Dtk_string::TrimTrailingCharacters
void TrimTrailingCharacters(const Dtk_WChar_t inCharToBeTrimmed)
Removes all occurrences of a given char at the end - trailing - into the Dtk_string.
Definition: dtk_string.hpp:608
Dtk_string::_FillFromCharBuffer
void _FillFromCharBuffer(const char *inBuffer, const Dtk_Size_t inSize=(Dtk_Size_t) -1)
Dtk_string::PathSeparatorChar
static const char PathSeparatorChar()
File Utility : retrieve The OS Path Separator as char.
Definition: dtk_string.hpp:891
Dtk_string::TrimCharacters
void TrimCharacters(const Dtk_WChar_t inCharToBeTrimmed, const Dtk_bool inTrimLeadingCharacters=DTK_TRUE, const Dtk_bool inTrimTrailingCharacters=DTK_TRUE)
Removes all occurrences of a given char at the beginning - leading - or the end - trailing - into the...
Dtk_string::ouvrir_fichier
FILE * ouvrir_fichier(const Dtk_string &droits) const
File Utility : Open a file with the given rights.
Dtk_string::TrimLeadingAndTrailingCharacters
void TrimLeadingAndTrailingCharacters(const Dtk_WChar_t inCharToBeTrimmed)
Removes all occurrences of a given char at the beginning - leading - and the end - trailing - into th...
Definition: dtk_string.hpp:622
Dtk_string::_w_str_us
const Dtk_WChar_t * _w_str_us() const
Retrieve the UNICODE string.
Dtk_string::count_substring_occurrences
int count_substring_occurrences(const Dtk_string &substring) const
Counts all the occurrences of a given substring into the Dtk_string.
DTK_TRUE
#define DTK_TRUE
Definition: define.h:719
Dtk_string::cat
void cat(const Dtk_string &s2)
concat the Dtk_string with the Dtk_string given in parameter
Dtk_string::count_char_occurrences
int count_char_occurrences(const int car) const
Counts all the occurrences of a given character into the Dtk_string.
Dtk_string::TrimLeadingCharacters
void TrimLeadingCharacters(const Dtk_WChar_t inCharToBeTrimmed)
Removes all occurrences of a given char at the beginning - leading - and the end - trailing - into th...
Definition: dtk_string.hpp:594
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:704
Dtk_WChar_t
wchar_t Dtk_WChar_t
Definition: define.h:703
Dtk_string::unlink
int unlink() const
File Utility : Delete a file.
Dtk_string::convert_from_int
void convert_from_int(const int integer, int force_unsigned_int=0)
affectation operator from a int
Dtk_string::path
Dtk_string path() const
File Utility : Retrieves the path in Dtk_string form.
Dtk_string::operator<<
friend std::ostream & operator<<(std::ostream &, const Dtk_string &)
Dtk_string::LeftExclusive
void LeftExclusive(const int &pos, Dtk_string &outRes) const
Dtk_string::ncpy
void ncpy(const Dtk_string &s2, size_t size)
copy a number of characters of the Dtk_string in an other Dtk_string
Dtk_status
Definition: dtk_status.hpp:16
Dtk_string::operator>=
friend bool operator>=(const Dtk_string &s1, const Dtk_string &s2)
compare two Dtk_string
DTK_FALSE
#define DTK_FALSE
Definition: define.h:720
Dtk_string::ncmp
int ncmp(const Dtk_WChar_t *s2, const int count) const
Dtk_bool
char Dtk_bool
Definition: define.h:717
Dtk_string::OpenFile
FILE * OpenFile(const Dtk_string &inRights) const
File Utility : Open a file with the given rights.
Dtk_string::operator+=
Dtk_string & operator+=(const Dtk_string &s2)
Dtk_string::ToUpper
void ToUpper()
Converts the Dtk_string to Upper case.
Dtk_string::right
Dtk_string right(int pos) const
retrieve the right part of the Dtk_string from a position
Dtk_Double64
double Dtk_Double64
Definition: define.h:691
Dtk_string::icmp
int icmp(const Dtk_WChar_t *s2) const
Dtk_string::find_substring
int find_substring(const Dtk_string &s1) const
find the position of a substring into a Dtk_string
Dtk_string::Split
void Split(const Dtk_string &inDelimiters, Dtk_tab< Dtk_string > &outResults) const
Split a Dtk_string into an array of Dtk_string giving a char array.
Dtk_string::existe_fichier
Dtk_bool existe_fichier() const
File Utility : tests if a file exists.
Dtk_string::PathSeparatorString
static const Dtk_string PathSeparatorString()
File Utility : Retrieves The OS Path Separator as Dtk_string.
Definition: dtk_string.hpp:911
Dtk_string::add_int
void add_int(const int integer, int force_unsigned_int=0)
concat an int to the Dtk_string (convert the int to Dtk_string)
Dtk_string::m_CStrSize
Size_t m_CStrSize
size of m_CStr buffer
Definition: dtk_string.hpp:66
Dtk_string::is_not_NULL
Dtk_bool is_not_NULL() const
Dtk_string::SetAsDeprecated
SetAsDeprecated("2022.3", "Use FileSize() method instead") long taille_fichier() const
Dtk_StringUtility::ToUtf8
std::string ToUtf8(wchar_t const *)
Dtk_string::Dtk_string
Dtk_string(Dtk_string &&s) DTK_NOEXCEPT
Move constructor.
Definition: dtk_string.hpp:91
Dtk_string::RightExclusive
void RightExclusive(const int &pos, Dtk_string &outRes) const
Dtk_string::replace
int replace(const int &old_char, const int &new_char)
Replaces all occurrences of a character in a string with a new character.
Dtk_string::filename
Dtk_string filename() const
File Utility : Retrieves the filename in Dtk_string form.
Dtk_string::operator<
friend bool operator<(const Dtk_string &s1, const Dtk_string &s2)
compare two Dtk_string
Dtk_string::ToDtkInt32
Dtk_status ToDtkInt32(Dtk_Int32 &outRes) const
Dtk_string::operator<=
friend bool operator<=(const Dtk_string &s1, const Dtk_string &s2)
compare two Dtk_string
Dtk_string::cmp
int cmp(const Dtk_string &s2) const
compare the Dtk_string with the string given in parameter
Dtk_string::ToUTF8String
char * ToUTF8String() const
Converts the Dtk_string to UTF8 string.
Dtk_string::FullPath
void FullPath(Dtk_string &outFullPath) const
File Utility : Retrieves the full path in Dtk_string form.
Dtk_string::Dtk_string
Dtk_string(const double dbl_val, Dtk_Int32 inWithMorePrecision)
Dtk_Int32
int32_t Dtk_Int32
Definition: define.h:679
Dtk_string::ToDtkDouble64
Dtk_status ToDtkDouble64(Dtk_Double64 &outRes) const
Dtk_string::operator=
Dtk_string & operator=(Dtk_string &&s) DTK_NOEXCEPT
Move assignment operator.
Definition: dtk_string.hpp:101
Dtk_string::Split
void Split(Dtk_WChar_t *inDelimiters, Dtk_tab< Dtk_string > &outResults) const
Dtk_string::cpy
void cpy(Dtk_string s2)
copy the Dtk_string given in parameter in the Dtk_string
Dtk_string::test_extension
int test_extension(const Dtk_string &ext) const
Dtk_string::get_char
Dtk_Size_t get_char(char *inoutStr) const
copy the Dtk_string in a char * (ASCII) string
Dtk_StringUtility
Definition: dtk_string.hpp:1061
Dtk_string::PathSeparatorWChar
static const Dtk_WChar_t PathSeparatorWChar()
File Utility : Retrieves The OS Path Separator as Dtk_WChar_t.
Definition: dtk_string.hpp:901
Dtk_string::get_wchar
void get_wchar(Dtk_WChar_t *str) const
copy the Dtk_string in a char * (UNICODE) string
Dtk_string::Dtk_string
Dtk_string(const Dtk_string &)
copy constructor
Dtk_string::operator[]
Dtk_WChar_t & operator[](int)
access to a specified letter in the Dtk_string
Dtk_string::traite_nom_fichier
int traite_nom_fichier(Dtk_string *drive, Dtk_string *path, Dtk_string *filename, Dtk_string *extension) const
File Utility: Splits Fullpath into drive/path/filename/extension.
Dtk_string::FileNameExtension
void FileNameExtension(Dtk_string &outFileNameExtension) const
File Utility : Retrieves the filename extension in Dtk_string form.
Dtk_string::is_NULL
Dtk_bool is_NULL() const
Dtk_string::Size_t
size_t Size_t
Definition: dtk_string.hpp:55
Dtk_string::left
Dtk_string left(int pos) const
retrieve the left part of the Dtk_string from a position
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
Dtk_string::nicmp
int nicmp(const Dtk_string &s2, const size_t size) const
Compare characters of two strings without regard to case.
Dtk_string::FileSize
Dtk_Size_t FileSize() const
File Utility : retrieve the file size.
Dtk_string::extension
Dtk_string extension() const
File Utility : Retrieves the extension in Dtk_string form.
Dtk_string::find_first
int find_first(int character) const
find the position of a character into a Dtk_string
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_string::clear
void clear()
clear string data
Dtk_string::left_exclusive
Dtk_string left_exclusive(int pos) const
retrieve the left part of the Dtk_string from a position
w_str
#define w_str
Definition: dtk_string.hpp:30
Dtk_string::Dtk_string
Dtk_string(const double dbl_val)
constructor from a double
Dtk_string::RawCopyFromASCII
void RawCopyFromASCII(const char *inStrToBeCopied, const Dtk_Size_t inCount=-1)
Dtk_string::operator+
friend Dtk_string operator+(const Dtk_string &s1, const Dtk_string &s2)
concat two Dtk_string
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
util_stl_dtk.hpp
Dtk_string::drive
Dtk_string drive() const
File Utility : Retrieves the drive in Dtk_string form.
define.h
Dtk_string::Dtk_string
Dtk_string(const char *s, const Dtk_Size_t &inCount)
Dtk_string::find_last
int find_last(int character) const
find the position of a character into a Dtk_string
Dtk_tab< Dtk_string >
Dtk_string::~Dtk_string
~Dtk_string()
Default destructors.
Dtk_string::ncmp
int ncmp(const Dtk_string &s2, const int count) const
compare the count first character of the Dtk_string with the string given in parameter
Dtk_string::nicmp
int nicmp(const Dtk_WChar_t *s2, const size_t size) const
Dtk_string::Substring
Dtk_string Substring(const Dtk_Size_t &inStartIndex, const Dtk_Size_t &inLength) const
Dtk_string::right_exclusive
Dtk_string right_exclusive(int pos) const
retrieve the right part of the Dtk_string from a position
Dtk_string::Merge
void Merge(const Dtk_string &s2)
Dtk_string::m_StrSize
Size_t m_StrSize
size of m_Str buffer
Definition: dtk_string.hpp:64
Dtk_StringUtility::FromUtf8
Dtk_string FromUtf8(char const *)
Dtk_string::len
int len() const
Retrieve the length of the Dtk_string.
Dtk_string::icmp
int icmp(const Dtk_string &s2) const
Perform a lowercase comparison of strings.
Dtk_string::m_Str
Dtk_WChar_t * m_Str
Internal representation of the string.
Definition: dtk_string.hpp:58
Dtk_string::Dtk_string
Dtk_string(const Dtk_WChar_t *s)
Dtk_string::Dtk_string
Dtk_string(const float float_val)
constructor from a float
Dtk_string::Dtk_string
Dtk_string()
Default constructor.
Dtk_string::operator>
friend bool operator>(const Dtk_string &s1, const Dtk_string &s2)
compare two Dtk_string
Dtk_string::ToLower
void ToLower()
Converts the Dtk_string to Lower case.
Dtk_string::m_CStr
char * m_CStr
compatibility ASCII representation. WARNING this field is not always up to date.
Definition: dtk_string.hpp:60
DTK_NOEXCEPT
#define DTK_NOEXCEPT
Definition: config.hpp:30
Dtk_string::removechar
int removechar(const int &removed_char)
Removes all occurrences of a character in a string.