GlobalObjects
Lade ...
Suche ...
Keine Treffer
EuStdFunctions.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_EUSTDFUNC_H
2#define INC_EUSTDFUNC_H
3//-----------------------------------------------------------------------------
36//-----------------------------------------------------------------------------
37#include <EuToolTypes.h>
38#include "EuException.h"
39#include <iomanip> // std::setw
40#include <string>
41#include <vector>
42#include <set>
43#if defined (_MSC_VER) || defined(__MINGW32__)
44 #include <windows.h>
45 //#include <codecvt> // warum das?
46#endif
47#if defined(__MINGW32__) || defined (__GNUC__)
48 #include <cstring>
49#endif
50#include <ctime>
51//-----------------------------------------------------------------------------
52namespace eut
53{
54 //---------------------------------------------------------------------------
67 namespace StdStringFunctions
68 {
69 //-------------------------------------------------------------------------
93
94 /*
95 typedef unsigned int EuCoutColor;
96 const EuCoutColor EuFOREGROUND_BLACK = 0; //!< MS: xxxx 0000 Linux: \033[0;30;??m
97 const EuCoutColor EuFOREGROUND_BLUE = 1; //!< MS: xxxx 0001 Linux: \033[0;34;??m
98 const EuCoutColor EuFOREGROUND_GREEN = 2; //!< MS: xxxx 0010 Linux: \033[0;32;??m
99 const EuCoutColor EuFOREGROUND_LIGHTBLUE = 3; //!< MS: xxxx 0011 Linux: \033[0;36;??m
100 const EuCoutColor EuFOREGROUND_RED = 4; //!< MS: xxxx 0100 Linux: \033[0;31;??m
101 const EuCoutColor EuFOREGROUND_MAGENTA = 5; //!< MS: xxxx 0101 Linux: \033[0;35;??m
102 const EuCoutColor EuFOREGROUND_YELLOW = 6; //!< MS: xxxx 0110 Linux: \033[0;33;??m
103 const EuCoutColor EuFOREGROUND_LIGHTGRAY = 7; //!< MS: xxxx 0111 Linux: \033[0;39;??m
104 const EuCoutColor EuFOREGROUND_GRAY = 8; //!< MS: xxxx 1000 Linux: \033[0;37;??m
105 const EuCoutColor EuFOREGROUND_WHITE = 15; //!< MS: xxxx 1111 Linux: \033[0;39;??m
106
107 const EuCoutColor EuBACKGROUND_BLACK = 0; //!< MS: 0000 xxxx Linux: \033[0;??;40m
108 const EuCoutColor EuBACKGROUND_BLUE = 16; //!< MS: 0001 xxxx Linux: \033[0;??;44m
109 const EuCoutColor EuBACKGROUND_GREEN = 32; //!< MS: 0010 xxxx Linux: \033[0;??;42m
110 const EuCoutColor EuBACKGROUND_LIGHTBLUE = 48; //!< MS: 0011 xxxx Linux: \033[0;??;46m
111 const EuCoutColor EuBACKGROUND_RED = 64; //!< MS: 0100 xxxx Linux: \033[0;??;41m
112 const EuCoutColor EuBACKGROUND_MAGENTA = 80; //!< MS: 0101 xxxx Linux: \033[0;??;45m
113 const EuCoutColor EuBACKGROUND_YELLOW = 96; //!< MS: 0110 xxxx Linux: \033[0;??;43m
114 const EuCoutColor EuBACKGROUND_LIGHTGRAY = 112; //!< MS: 0111 xxxx Linux: \033[0;??;47m
115 const EuCoutColor EuBACKGROUND_GRAY = 128; //!< MS: 1000 xxxx Linux: \033[0;??;47m
116 const EuCoutColor EuBACKGROUND_WHITE = 240; //!< MS: 1111 xxxx Linux: \033[0;??;47m
117 */
118 //-------------------------------------------------------------------------
161 //-------------------------------------------------------------------------
163
176 __tool_export_dll std::string toLower( const std::string & rstr );
177 __tool_export_dll std::wstring toLower( const std::wstring & rstr );
179 //-------------------------------------------------------------------------
181
194 __tool_export_dll std::string toUpper( const std::string & rstr );
195 __tool_export_dll std::wstring toUpper( const std::wstring & rstr );
197 //-------------------------------------------------------------------------
217 template <typename T> std::string toHexstr( const T & rValue, std::size_t hex_len = sizeof(T) << 1 )
218 {
219 static const char * t_chDigits = "0123456789ABCDEF";
220 std::string t_sRetVal( hex_len,'0' );
221
222 for ( size_t i = 0, j = ( hex_len-1 )*4 ; i<hex_len; ++i,j-=4 )
223 {
224 t_sRetVal[i] = t_chDigits[(rValue>>j) & 0x0f];
225 }
226 return t_sRetVal;
227} //-------------------------------------------------------------------------
229
267 __tool_export_dll void trimString( std::string & rstr, char c = ' ', EnStrPos ePos = eBEFORE );
268 __tool_export_dll void trimString( std::wstring & rstr, wchar_t c = ' ', EnStrPos ePos = eBEFORE );
270 //-------------------------------------------------------------------------
284 __tool_export_dll bool isAnInteger( const std::string & rstr );
285 //-------------------------------------------------------------------------
305 __tool_export_dll void fillString( std::string & rstr,
306 char cFillItem,
307 std::size_t nNumber,
308 EnStrPos ePos );
309 //-------------------------------------------------------------------------
337 __tool_export_dll char * getFilledString( const char * pch,
338 char cFillItem,
339 std::size_t nNumber,
340 EnStrPos ePos );
341 //-------------------------------------------------------------------------
364 __tool_export_dll std::string getFilledString( const std::string & rstr,
365 char cFillItem,
366 std::size_t nNumber,
367 EnStrPos ePos );
368 //-------------------------------------------------------------------------
388 __tool_export_dll void tokenizeString( const std::string & rstrSource,
389 std::vector<std::string> & rTokensVector,
390 const std::string & rstrDelimiters = " " );
391 //-------------------------------------------------------------------------
411 __tool_export_dll void tokenizeString( const std::string & rstrSource,
412 std::vector<std::string> & rTokensVector,
413 const char & rcDelimiters = ' ' );
414 //-------------------------------------------------------------------------
432 __tool_export_dll void tokenizeString( const std::wstring & rwsSource,
433 std::vector<std::wstring> & rTokensVector,
434 wchar_t wcDelimiters = L' ' );
435 //-------------------------------------------------------------------------
437
457 __tool_export_dll bool insertIfNotAvailable( std::string & rsText,
458 std::size_t nPos,
459 const std::string & rsIns );
460 __tool_export_dll bool insertIfNotAvailable( std::wstring & rsText,
461 std::size_t nPos,
462 const std::wstring & rsIns );
464 //-------------------------------------------------------------------------
466
488 __tool_export_dll std::size_t replaceAll( std::string & rsText,
489 const std::string & rsFnd,
490 const std::string & rsRep );
491 __tool_export_dll std::size_t replaceAll( std::wstring & rsText,
492 const std::wstring & rsFnd,
493 const std::wstring & rsRep );
495 //-------------------------------------------------------------------------
518 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
519 const char pzOriginal,
520 const char pzNew );
521 //-------------------------------------------------------------------------
547 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
548 std::vector<std::size_t> & rPosVector,
549 const char pzOriginal,
550 const char pzNew );
551 //-------------------------------------------------------------------------
568 __tool_export_dll std::wstring string2wstring( const std::string & rsSourceString );
569 //-------------------------------------------------------------------------
587 __tool_export_dll std::string wstring2string( const std::wstring & rwsSourceString );
588 //-------------------------------------------------------------------------
590
659 __tool_export_dll bool compareWildcardString( const std::string & rsSearchString,
660 const std::string & rsString );
661 __tool_export_dll bool compareWildcardString( const std::wstring & rsSearchString,
662 const std::wstring & rsString );
664 //-------------------------------------------------------------------------
666
681 __tool_export_dll void colorConsoleCout( const std::string & rsCoutText,
682 EnCoutColor eForeGroundColor,
683 EnCoutColor eBackGroundColor );
684 __tool_export_dll void colorConsoleCout( const std::wstring & rsCoutText,
685 EnCoutColor eForeGroundColor,
686 EnCoutColor eBackGroundColor );
688 //-------------------------------------------------------------------------
689 #if defined(_MSC_VER) || defined(__MINGW32__)
708 EnCoutColor eBackGroundColor );
709 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
710 #elif defined(__GNUC__)
711 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
726 EnCoutColor eBackGroundColor );
727 #endif // defined(_MSC_VER) || defined(__MINGW32__) <> defined(__GNUC__)
728 //-------------------------------------------------------------------------
729 #if defined(_MSC_VER) || defined(__MINGW32__)
741 __tool_export_dll void resetColorConsoleCout( WORD wScreenBufferInfo );
742 #endif // defined(_MSC_VER) || defined(__MINGW32__)
743 //-------------------------------------------------------------------------
744 #if defined(__GNUC__)
755 #endif // defined(__GNUC__)
756 //-------------------------------------------------------------------------
757 }
758 //---------------------------------------------------------------------------
771 namespace TimeFunctions
772 {
773 //-------------------------------------------------------------------------
791 __tool_export_dll std::string getMonth( unsigned int uiMonth );
792 //-------------------------------------------------------------------------
818 __tool_export_dll std::string getMilitaryTime( const std::time_t & rTime );
819 //-------------------------------------------------------------------------
844 //-------------------------------------------------------------------------
862 __tool_export_dll std::string getTimeString( const std::time_t & rTime,
863 const std::string & rsFormat = "%Y.%m.%d - %X" );
864 //-------------------------------------------------------------------------
880 __tool_export_dll std::string getSystemTimeString( const std::string & rsFormat = "%Y.%m.%d - %X" );
881 //-------------------------------------------------------------------------
905 __tool_export_dll std::time_t getTime( unsigned int uiYear,
906 unsigned int uiMonth,
907 unsigned int uiDay,
908 unsigned int uiHour,
909 unsigned int uiMin,
910 unsigned int uiSec);
911 //-------------------------------------------------------------------------
912 }
913 //---------------------------------------------------------------------------
914} // namespace eut
915#endif
Header für ErrorNException
Für jede Bibliothek, hier 'EuTools' gibt es eine Typen-Datei.
#define __tool_export_dll
Definition EuToolTypes.h:63
__tool_export_dll std::size_t replaceAll(std::string &rsText, const std::string &rsFnd, const std::string &rsRep)
Tauscht in einem String alle gesuchten Teilstrings mit einem anderen übergebenen String aus.
__tool_export_dll std::wstring string2wstring(const std::string &rsSourceString)
__tool_export_dll void tokenizeString(const std::string &rstrSource, std::vector< std::string > &rTokensVector, const std::string &rstrDelimiters=" ")
__tool_export_dll void fillString(std::string &rstr, char cFillItem, std::size_t nNumber, EnStrPos ePos)
__tool_export_dll char * getFilledString(const char *pch, char cFillItem, std::size_t nNumber, EnStrPos ePos)
__tool_export_dll void colorConsoleCout(const std::string &rsCoutText, EnCoutColor eForeGroundColor, EnCoutColor eBackGroundColor)
Gibt auf der Konsole einen String farbig aus.
__tool_export_dll bool isAnInteger(const std::string &rstr)
__tool_export_dll bool compareWildcardString(const std::string &rsSearchString, const std::string &rsString)
Vergleicht zwei std::string's.
__tool_export_dll bool insertIfNotAvailable(std::string &rsText, std::size_t nPos, const std::string &rsIns)
Fügt eine Zeichenkette an übergebener Position ein, wenn noch nicht vorhanden.
EnStrPos
Definition EuStdFunctions.h:129
@ eBEFORE
Definition EuStdFunctions.h:139
@ eBOTH
Definition EuStdFunctions.h:159
@ eBEHIND
Definition EuStdFunctions.h:149
__tool_export_dll void trimString(std::string &rstr, char c=' ', EnStrPos ePos=eBEFORE)
Trim für std::string inspiriert durch:
__tool_export_dll std::string toUpper(const std::string &rstr)
Wandelt alle Kleinbuchstaben der übergebenen Zeichenkette in Großbuchstaben.
__tool_export_dll WORD setColorConsoleCout(EnCoutColor eForeGroundColor, EnCoutColor eBackGroundColor)
__tool_export_dll std::string toLower(const std::string &rstr)
Wandelt alle Großbuchstaben der übergebenen Zeichenkette in Kleinbuchstaben.
__tool_export_dll void resetColorConsoleCout(WORD wScreenBufferInfo)
std::string toHexstr(const T &rValue, std::size_t hex_len=sizeof(T)<< 1)
Definition EuStdFunctions.h:217
__tool_export_dll std::string wstring2string(const std::wstring &rwsSourceString)
EnCoutColor
Definition EuStdFunctions.h:80
@ eCOLOR_BLUE
Definition EuStdFunctions.h:83
@ eCOLOR_BLACK
Definition EuStdFunctions.h:82
@ eCOLOR_GRAY
Definition EuStdFunctions.h:90
@ eCOLOR_RED
Definition EuStdFunctions.h:86
@ eCOLOR_GREEN
Definition EuStdFunctions.h:84
@ eCOLOR_DEFAULT
Definition EuStdFunctions.h:81
@ eCOLOR_LIGHTBLUE
Definition EuStdFunctions.h:85
@ eCOLOR_WHITE
Definition EuStdFunctions.h:91
@ eCOLOR_MAGENTA
Definition EuStdFunctions.h:87
@ eCOLOR_YELLOW
Definition EuStdFunctions.h:88
@ eCOLOR_LIGHTGRAY
Definition EuStdFunctions.h:89
__tool_export_dll std::string getMonth(unsigned int uiMonth)
__tool_export_dll std::string getMilitarySystemTime()
__tool_export_dll std::string getMilitaryTime(const std::time_t &rTime)
__tool_export_dll std::time_t getTime(unsigned int uiYear, unsigned int uiMonth, unsigned int uiDay, unsigned int uiHour, unsigned int uiMin, unsigned int uiSec)
__tool_export_dll std::string getTimeString(const std::time_t &rTime, const std::string &rsFormat="%Y.%m.%d - %X")
__tool_export_dll std::string getSystemTimeString(const std::string &rsFormat="%Y.%m.%d - %X")
Definition IniFile.h:47