GlobalObjects
Lade ...
Suche ...
Keine Treffer
EuStdFunctions.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_EUSTDFUNC_H
2#define INC_EUSTDFUNC_H
3//-----------------------------------------------------------------------------
51//-----------------------------------------------------------------------------
52#include <EuToolTypes.h>
53#include "EuException.h"
54#include <iomanip> // std::setw
55#include <string>
56#include <vector>
57#include <set>
58#if defined (_MSC_VER) || defined(__MINGW32__)
59 #include <windows.h>
60 //#include <codecvt> // warum das?
61#endif
62#if defined(__MINGW32__) || defined (__GNUC__) || defined(__BORLANDC__)
63 #include <cstring>
64#endif
65#include <ctime>
66//-----------------------------------------------------------------------------
67namespace eut
68{
69 //---------------------------------------------------------------------------
82 namespace StdStringFunctions
83 {
84 //-------------------------------------------------------------------------
108
109 /*
110 typedef unsigned int EuCoutColor;
111 const EuCoutColor EuFOREGROUND_BLACK = 0; //!< MS: xxxx 0000 Linux: \033[0;30;??m
112 const EuCoutColor EuFOREGROUND_BLUE = 1; //!< MS: xxxx 0001 Linux: \033[0;34;??m
113 const EuCoutColor EuFOREGROUND_GREEN = 2; //!< MS: xxxx 0010 Linux: \033[0;32;??m
114 const EuCoutColor EuFOREGROUND_LIGHTBLUE = 3; //!< MS: xxxx 0011 Linux: \033[0;36;??m
115 const EuCoutColor EuFOREGROUND_RED = 4; //!< MS: xxxx 0100 Linux: \033[0;31;??m
116 const EuCoutColor EuFOREGROUND_MAGENTA = 5; //!< MS: xxxx 0101 Linux: \033[0;35;??m
117 const EuCoutColor EuFOREGROUND_YELLOW = 6; //!< MS: xxxx 0110 Linux: \033[0;33;??m
118 const EuCoutColor EuFOREGROUND_LIGHTGRAY = 7; //!< MS: xxxx 0111 Linux: \033[0;39;??m
119 const EuCoutColor EuFOREGROUND_GRAY = 8; //!< MS: xxxx 1000 Linux: \033[0;37;??m
120 const EuCoutColor EuFOREGROUND_WHITE = 15; //!< MS: xxxx 1111 Linux: \033[0;39;??m
121
122 const EuCoutColor EuBACKGROUND_BLACK = 0; //!< MS: 0000 xxxx Linux: \033[0;??;40m
123 const EuCoutColor EuBACKGROUND_BLUE = 16; //!< MS: 0001 xxxx Linux: \033[0;??;44m
124 const EuCoutColor EuBACKGROUND_GREEN = 32; //!< MS: 0010 xxxx Linux: \033[0;??;42m
125 const EuCoutColor EuBACKGROUND_LIGHTBLUE = 48; //!< MS: 0011 xxxx Linux: \033[0;??;46m
126 const EuCoutColor EuBACKGROUND_RED = 64; //!< MS: 0100 xxxx Linux: \033[0;??;41m
127 const EuCoutColor EuBACKGROUND_MAGENTA = 80; //!< MS: 0101 xxxx Linux: \033[0;??;45m
128 const EuCoutColor EuBACKGROUND_YELLOW = 96; //!< MS: 0110 xxxx Linux: \033[0;??;43m
129 const EuCoutColor EuBACKGROUND_LIGHTGRAY = 112; //!< MS: 0111 xxxx Linux: \033[0;??;47m
130 const EuCoutColor EuBACKGROUND_GRAY = 128; //!< MS: 1000 xxxx Linux: \033[0;??;47m
131 const EuCoutColor EuBACKGROUND_WHITE = 240; //!< MS: 1111 xxxx Linux: \033[0;??;47m
132 */
133 //-------------------------------------------------------------------------
176 //-------------------------------------------------------------------------
178
191 __tool_export_dll std::string toLower( const std::string & rstr );
192 __tool_export_dll std::wstring toLower( const std::wstring & rstr );
194 //-------------------------------------------------------------------------
196
209 __tool_export_dll std::string toUpper( const std::string & rstr );
210 __tool_export_dll std::wstring toUpper( const std::wstring & rstr );
212 //-------------------------------------------------------------------------
232 template <typename T> std::string toHexstr( const T & rValue, std::size_t hex_len = sizeof(T) << 1 )
233 {
234 static const char * t_chDigits = "0123456789ABCDEF";
235 std::string t_sRetVal( hex_len,'0' );
236
237 for ( size_t i = 0, j = ( hex_len-1 )*4 ; i<hex_len; ++i,j-=4 )
238 {
239 t_sRetVal[i] = t_chDigits[(rValue>>j) & 0x0f];
240 }
241 return t_sRetVal;
242} //-------------------------------------------------------------------------
244
282 __tool_export_dll void trimString( std::string & rstr, char c = ' ', EnStrPos ePos = eBEFORE );
283 __tool_export_dll void trimString( std::wstring & rstr, wchar_t c = ' ', EnStrPos ePos = eBEFORE );
285 //-------------------------------------------------------------------------
299 __tool_export_dll bool isAnInteger( const std::string & rstr );
300 //-------------------------------------------------------------------------
320 __tool_export_dll void fillString( std::string & rstr,
321 char cFillItem,
322 std::size_t nNumber,
323 EnStrPos ePos );
324 //-------------------------------------------------------------------------
352 __tool_export_dll char * getFilledString( const char * pch,
353 char cFillItem,
354 std::size_t nNumber,
355 EnStrPos ePos );
356 //-------------------------------------------------------------------------
379 __tool_export_dll std::string getFilledString( const std::string & rstr,
380 char cFillItem,
381 std::size_t nNumber,
382 EnStrPos ePos );
383 //-------------------------------------------------------------------------
403 __tool_export_dll void tokenizeString( const std::string & rstrSource,
404 std::vector<std::string> & rTokensVector,
405 const std::string & rstrDelimiters = " " );
406 //-------------------------------------------------------------------------
426 __tool_export_dll void tokenizeString( const std::string & rstrSource,
427 std::vector<std::string> & rTokensVector,
428 const char & rcDelimiters = ' ' );
429 //-------------------------------------------------------------------------
447 __tool_export_dll void tokenizeString( const std::wstring & rwsSource,
448 std::vector<std::wstring> & rTokensVector,
449 wchar_t wcDelimiters = L' ' );
450 //-------------------------------------------------------------------------
452
472 __tool_export_dll bool insertIfNotAvailable( std::string & rsText,
473 std::size_t nPos,
474 const std::string & rsIns );
475 __tool_export_dll bool insertIfNotAvailable( std::wstring & rsText,
476 std::size_t nPos,
477 const std::wstring & rsIns );
479 //-------------------------------------------------------------------------
481
503 __tool_export_dll std::size_t replaceAll( std::string & rsText,
504 const std::string & rsFnd,
505 const std::string & rsRep );
506 __tool_export_dll std::size_t replaceAll( std::wstring & rsText,
507 const std::wstring & rsFnd,
508 const std::wstring & rsRep );
510 //-------------------------------------------------------------------------
533 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
534 const char pzOriginal,
535 const char pzNew );
536 //-------------------------------------------------------------------------
562 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
563 std::vector<std::size_t> & rPosVector,
564 const char pzOriginal,
565 const char pzNew );
566 //-------------------------------------------------------------------------
583 __tool_export_dll std::wstring string2wstring( const std::string & rsSourceString );
584 //-------------------------------------------------------------------------
602 __tool_export_dll std::string wstring2string( const std::wstring & rwsSourceString );
603 //-------------------------------------------------------------------------
605
674 __tool_export_dll bool compareWildcardString( const std::string & rsSearchString,
675 const std::string & rsString );
676 __tool_export_dll bool compareWildcardString( const std::wstring & rsSearchString,
677 const std::wstring & rsString );
679 //-------------------------------------------------------------------------
681
696 __tool_export_dll void colorConsoleCout( const std::string & rsCoutText,
697 EnCoutColor eForeGroundColor,
698 EnCoutColor eBackGroundColor );
699 __tool_export_dll void colorConsoleCout( const std::wstring & rsCoutText,
700 EnCoutColor eForeGroundColor,
701 EnCoutColor eBackGroundColor );
703 //-------------------------------------------------------------------------
704 #if defined(_MSC_VER) || defined(__MINGW32__)
723 EnCoutColor eBackGroundColor );
724 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
725 #elif defined(__GNUC__) || defined(__BORLANDC__)
726 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
741 EnCoutColor eBackGroundColor );
742 #endif // defined(_MSC_VER) || defined(__MINGW32__) <> defined(__GNUC__) || defined(__BORLANDC__)
743 //-------------------------------------------------------------------------
744 #if defined(_MSC_VER) || defined(__MINGW32__)
756 __tool_export_dll void resetColorConsoleCout( WORD wScreenBufferInfo );
757 #endif // defined(_MSC_VER) || defined(__MINGW32__)
758 //-------------------------------------------------------------------------
759 #if defined(__GNUC__) || defined(__BORLANDC__)
770 #endif // defined(__GNUC__) || defined(__BORLANDC__)
771 //-------------------------------------------------------------------------
772 }
773 //---------------------------------------------------------------------------
786 namespace TimeFunctions
787 {
788 //-------------------------------------------------------------------------
806 __tool_export_dll std::string getMonth( unsigned int uiMonth );
807 //-------------------------------------------------------------------------
833 __tool_export_dll std::string getMilitaryTime( const std::time_t & rTime );
834 //-------------------------------------------------------------------------
859 //-------------------------------------------------------------------------
877 __tool_export_dll std::string getTimeString( const std::time_t & rTime,
878 const std::string & rsFormat = "%Y.%m.%d - %X" );
879 //-------------------------------------------------------------------------
895 __tool_export_dll std::string getSystemTimeString( const std::string & rsFormat = "%Y.%m.%d - %X" );
896 //-------------------------------------------------------------------------
920 __tool_export_dll std::time_t getTime( unsigned int uiYear,
921 unsigned int uiMonth,
922 unsigned int uiDay,
923 unsigned int uiHour,
924 unsigned int uiMin,
925 unsigned int uiSec);
926 //-------------------------------------------------------------------------
927 }
928 //---------------------------------------------------------------------------
929} // namespace eut
930#endif
Header für ErrorNException
Für jede Bibliothek, hier 'EuTools' gibt es eine Typen-Datei.
#define __tool_export_dll
Definition EuToolTypes.h:77
__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:144
@ eBEFORE
Definition EuStdFunctions.h:154
@ eBOTH
Definition EuStdFunctions.h:174
@ eBEHIND
Definition EuStdFunctions.h:164
__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:232
__tool_export_dll std::string wstring2string(const std::wstring &rwsSourceString)
EnCoutColor
Definition EuStdFunctions.h:95
@ eCOLOR_BLUE
Definition EuStdFunctions.h:98
@ eCOLOR_BLACK
Definition EuStdFunctions.h:97
@ eCOLOR_GRAY
Definition EuStdFunctions.h:105
@ eCOLOR_RED
Definition EuStdFunctions.h:101
@ eCOLOR_GREEN
Definition EuStdFunctions.h:99
@ eCOLOR_DEFAULT
Definition EuStdFunctions.h:96
@ eCOLOR_LIGHTBLUE
Definition EuStdFunctions.h:100
@ eCOLOR_WHITE
Definition EuStdFunctions.h:106
@ eCOLOR_MAGENTA
Definition EuStdFunctions.h:102
@ eCOLOR_YELLOW
Definition EuStdFunctions.h:103
@ eCOLOR_LIGHTGRAY
Definition EuStdFunctions.h:104
__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:62