GlobalObjects
Lade ...
Suche ...
Keine Treffer
EuStdFunctions.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_EUSTDFUNC_H
2#define INC_EUSTDFUNC_H
3//-----------------------------------------------------------------------------
68//-----------------------------------------------------------------------------
69#include <EuToolTypes.h>
70#include "EuException.h"
71#include <iomanip> // std::setw
72#include <string>
73#include <vector>
74#include <set>
75#if defined (_MSC_VER) || defined(__MINGW32__)
76 #include <windows.h>
77 //#include <codecvt> // warum das?
78#endif
79#if defined(__MINGW32__) || defined (__GNUC__) || defined(__BORLANDC__)
80 #include <cstring>
81#endif
82#include <ctime>
83//-----------------------------------------------------------------------------
84namespace eut
85{
86 //---------------------------------------------------------------------------
100 {
101 //-------------------------------------------------------------------------
125
126 /*
127 typedef unsigned int EuCoutColor;
128 const EuCoutColor EuFOREGROUND_BLACK = 0; //!< MS: xxxx 0000 Linux: \033[0;30;??m
129 const EuCoutColor EuFOREGROUND_BLUE = 1; //!< MS: xxxx 0001 Linux: \033[0;34;??m
130 const EuCoutColor EuFOREGROUND_GREEN = 2; //!< MS: xxxx 0010 Linux: \033[0;32;??m
131 const EuCoutColor EuFOREGROUND_LIGHTBLUE = 3; //!< MS: xxxx 0011 Linux: \033[0;36;??m
132 const EuCoutColor EuFOREGROUND_RED = 4; //!< MS: xxxx 0100 Linux: \033[0;31;??m
133 const EuCoutColor EuFOREGROUND_MAGENTA = 5; //!< MS: xxxx 0101 Linux: \033[0;35;??m
134 const EuCoutColor EuFOREGROUND_YELLOW = 6; //!< MS: xxxx 0110 Linux: \033[0;33;??m
135 const EuCoutColor EuFOREGROUND_LIGHTGRAY = 7; //!< MS: xxxx 0111 Linux: \033[0;39;??m
136 const EuCoutColor EuFOREGROUND_GRAY = 8; //!< MS: xxxx 1000 Linux: \033[0;37;??m
137 const EuCoutColor EuFOREGROUND_WHITE = 15; //!< MS: xxxx 1111 Linux: \033[0;39;??m
138
139 const EuCoutColor EuBACKGROUND_BLACK = 0; //!< MS: 0000 xxxx Linux: \033[0;??;40m
140 const EuCoutColor EuBACKGROUND_BLUE = 16; //!< MS: 0001 xxxx Linux: \033[0;??;44m
141 const EuCoutColor EuBACKGROUND_GREEN = 32; //!< MS: 0010 xxxx Linux: \033[0;??;42m
142 const EuCoutColor EuBACKGROUND_LIGHTBLUE = 48; //!< MS: 0011 xxxx Linux: \033[0;??;46m
143 const EuCoutColor EuBACKGROUND_RED = 64; //!< MS: 0100 xxxx Linux: \033[0;??;41m
144 const EuCoutColor EuBACKGROUND_MAGENTA = 80; //!< MS: 0101 xxxx Linux: \033[0;??;45m
145 const EuCoutColor EuBACKGROUND_YELLOW = 96; //!< MS: 0110 xxxx Linux: \033[0;??;43m
146 const EuCoutColor EuBACKGROUND_LIGHTGRAY = 112; //!< MS: 0111 xxxx Linux: \033[0;??;47m
147 const EuCoutColor EuBACKGROUND_GRAY = 128; //!< MS: 1000 xxxx Linux: \033[0;??;47m
148 const EuCoutColor EuBACKGROUND_WHITE = 240; //!< MS: 1111 xxxx Linux: \033[0;??;47m
149 */
150 //-------------------------------------------------------------------------
193 //-------------------------------------------------------------------------
195
208 __tool_export_dll std::string toLower( const std::string & rstr );
209 __tool_export_dll std::wstring toLower( const std::wstring & rstr );
211 //-------------------------------------------------------------------------
213
226 __tool_export_dll std::string toUpper( const std::string & rstr );
227 __tool_export_dll std::wstring toUpper( const std::wstring & rstr );
229 //-------------------------------------------------------------------------
249 template <typename T> std::string toHexstr( const T & rValue, std::size_t hex_len = sizeof(T) << 1 )
250 {
251 static const char * t_chDigits = "0123456789ABCDEF";
252 std::string t_sRetVal( hex_len,'0' );
253
254 for ( size_t i = 0, j = ( hex_len-1 )*4 ; i<hex_len; ++i,j-=4 )
255 {
256 t_sRetVal[i] = t_chDigits[(rValue>>j) & 0x0f];
257 }
258 return t_sRetVal;
259} //-------------------------------------------------------------------------
260
261
299 __tool_export_dll void trimString( std::string & rstr, char c = ' ', EnStrPos ePos = eBEFORE );
300 __tool_export_dll void trimString( std::wstring & rstr, wchar_t c = ' ', EnStrPos ePos = eBEFORE );
302 //-------------------------------------------------------------------------
316 __tool_export_dll bool isAnInteger( const std::string & rstr );
317 //-------------------------------------------------------------------------
337 __tool_export_dll void fillString( std::string & rstr,
338 char cFillItem,
339 std::size_t nNumber,
340 EnStrPos ePos );
341 //-------------------------------------------------------------------------
369 __tool_export_dll char * getFilledString( const char * pch,
370 char cFillItem,
371 std::size_t nNumber,
372 EnStrPos ePos );
373 //-------------------------------------------------------------------------
396 __tool_export_dll std::string getFilledString( const std::string & rstr,
397 char cFillItem,
398 std::size_t nNumber,
399 EnStrPos ePos );
400 //-------------------------------------------------------------------------
424 __tool_export_dll void tokenizeString( const std::string & rstrSource,
425 std::vector<std::string> & rTokensVector,
426 const std::string & rstrDelimiters,
427 bool bWithoutEmptyStrings = false );
428 //-------------------------------------------------------------------------
452 __tool_export_dll void tokenizeString( const std::string & rstrSource,
453 std::vector<std::string> & rTokensVector,
454 const char & rcDelimiters,
455 bool bWithoutEmptyStrings = false );
456 //-------------------------------------------------------------------------
478 __tool_export_dll void tokenizeString( const std::wstring & rwsSource,
479 std::vector<std::wstring> & rTokensVector,
480 wchar_t wcDelimiters,
481 bool bWithoutEmptyStrings = false );
482 //-------------------------------------------------------------------------
484
504 __tool_export_dll bool insertIfNotAvailable( std::string & rsText,
505 std::size_t nPos,
506 const std::string & rsIns );
507 __tool_export_dll bool insertIfNotAvailable( std::wstring & rsText,
508 std::size_t nPos,
509 const std::wstring & rsIns );
511 //-------------------------------------------------------------------------
513
535 __tool_export_dll std::size_t replaceAll( std::string & rsText,
536 const std::string & rsFnd,
537 const std::string & rsRep );
538 __tool_export_dll std::size_t replaceAll( std::wstring & rsText,
539 const std::wstring & rsFnd,
540 const std::wstring & rsRep );
542 //-------------------------------------------------------------------------
565 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
566 const char pzOriginal,
567 const char pzNew );
568 //-------------------------------------------------------------------------
594 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
595 std::vector<std::size_t> & rPosVector,
596 const char pzOriginal,
597 const char pzNew );
598 //-------------------------------------------------------------------------
615 __tool_export_dll std::wstring string2wstring( const std::string & rsSourceString );
616 //-------------------------------------------------------------------------
634 __tool_export_dll std::string wstring2string( const std::wstring & rwsSourceString );
635 //-------------------------------------------------------------------------
637
706 __tool_export_dll bool compareWildcardString( const std::string & rsSearchString,
707 const std::string & rsString );
708 __tool_export_dll bool compareWildcardString( const std::wstring & rsSearchString,
709 const std::wstring & rsString );
711 //-------------------------------------------------------------------------
713
728 __tool_export_dll void colorConsoleCout( const std::string & rsCoutText,
729 EnCoutColor eForeGroundColor,
730 EnCoutColor eBackGroundColor );
731 __tool_export_dll void colorConsoleCout( const std::wstring & rsCoutText,
732 EnCoutColor eForeGroundColor,
733 EnCoutColor eBackGroundColor );
735 //-------------------------------------------------------------------------
736 #if defined(_MSC_VER) || defined(__MINGW32__)
755 EnCoutColor eBackGroundColor );
756 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
757 #elif defined(__GNUC__) || defined(__BORLANDC__)
758 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
773 EnCoutColor eBackGroundColor );
774 #endif // defined(_MSC_VER) || defined(__MINGW32__) <> defined(__GNUC__) || defined(__BORLANDC__)
775 //-------------------------------------------------------------------------
776 #if defined(_MSC_VER) || defined(__MINGW32__)
788 __tool_export_dll void resetColorConsoleCout( WORD wScreenBufferInfo );
789 #endif // defined(_MSC_VER) || defined(__MINGW32__)
790 //-------------------------------------------------------------------------
791 #if defined(__GNUC__) || defined(__BORLANDC__)
802 #endif // defined(__GNUC__) || defined(__BORLANDC__)
803 //-------------------------------------------------------------------------
804 }
805 //---------------------------------------------------------------------------
819 {
820 //-------------------------------------------------------------------------
838 __tool_export_dll std::string getMonth( unsigned int uiMonth );
839 //-------------------------------------------------------------------------
865 __tool_export_dll std::string getMilitaryTime( const std::time_t & rTime );
866 //-------------------------------------------------------------------------
891 //-------------------------------------------------------------------------
909 __tool_export_dll std::string getTimeString( const std::time_t & rTime,
910 const std::string & rsFormat = "%Y.%m.%d - %X" );
911 //-------------------------------------------------------------------------
927 __tool_export_dll std::string getSystemTimeString( const std::string & rsFormat = "%Y.%m.%d - %X" );
928 //-------------------------------------------------------------------------
952 __tool_export_dll std::time_t getTime( unsigned int uiYear,
953 unsigned int uiMonth,
954 unsigned int uiDay,
955 unsigned int uiHour,
956 unsigned int uiMin,
957 unsigned int uiSec);
958 //-------------------------------------------------------------------------
959 }
960 //---------------------------------------------------------------------------
961} // namespace eut
962#endif
Header für ErrorNException
Für jede Bibliothek, hier 'EuTools' gibt es eine Typen-Datei.
#define __tool_export_dll
Definition EuToolTypes.h:94
Hilfsfunktionen für die Verarbeitung von Strings.
Definition EuStdFunctions.h:100
__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 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 void tokenizeString(const std::string &rstrSource, std::vector< std::string > &rTokensVector, const std::string &rstrDelimiters, bool bWithoutEmptyStrings=false)
__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:161
@ eBEFORE
Definition EuStdFunctions.h:171
@ eBOTH
Definition EuStdFunctions.h:191
@ eBEHIND
Definition EuStdFunctions.h:181
__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:249
__tool_export_dll std::string wstring2string(const std::wstring &rwsSourceString)
EnCoutColor
Definition EuStdFunctions.h:112
@ eCOLOR_BLUE
Definition EuStdFunctions.h:115
@ eCOLOR_BLACK
Definition EuStdFunctions.h:114
@ eCOLOR_GRAY
Definition EuStdFunctions.h:122
@ eCOLOR_RED
Definition EuStdFunctions.h:118
@ eCOLOR_GREEN
Definition EuStdFunctions.h:116
@ eCOLOR_DEFAULT
Definition EuStdFunctions.h:113
@ eCOLOR_LIGHTBLUE
Definition EuStdFunctions.h:117
@ eCOLOR_WHITE
Definition EuStdFunctions.h:123
@ eCOLOR_MAGENTA
Definition EuStdFunctions.h:119
@ eCOLOR_YELLOW
Definition EuStdFunctions.h:120
@ eCOLOR_LIGHTGRAY
Definition EuStdFunctions.h:121
Hilfsfunktionen für die Verarbeitung von Zeit.
Definition EuStdFunctions.h:819
__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:79