GlobalObjects
Loading...
Searching...
No Matches
EuStdFunctions.h
Go to the documentation of this file.
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 //---------------------------------------------------------------------------
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} //-------------------------------------------------------------------------
243
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 //-------------------------------------------------------------------------
407 __tool_export_dll void tokenizeString( const std::string & rstrSource,
408 std::vector<std::string> & rTokensVector,
409 const std::string & rstrDelimiters,
410 bool bWithoutEmptyStrings = false );
411 //-------------------------------------------------------------------------
435 __tool_export_dll void tokenizeString( const std::string & rstrSource,
436 std::vector<std::string> & rTokensVector,
437 const char & rcDelimiters,
438 bool bWithoutEmptyStrings = false );
439 //-------------------------------------------------------------------------
461 __tool_export_dll void tokenizeString( const std::wstring & rwsSource,
462 std::vector<std::wstring> & rTokensVector,
463 wchar_t wcDelimiters,
464 bool bWithoutEmptyStrings = false );
465 //-------------------------------------------------------------------------
467
487 __tool_export_dll bool insertIfNotAvailable( std::string & rsText,
488 std::size_t nPos,
489 const std::string & rsIns );
490 __tool_export_dll bool insertIfNotAvailable( std::wstring & rsText,
491 std::size_t nPos,
492 const std::wstring & rsIns );
494 //-------------------------------------------------------------------------
496
518 __tool_export_dll std::size_t replaceAll( std::string & rsText,
519 const std::string & rsFnd,
520 const std::string & rsRep );
521 __tool_export_dll std::size_t replaceAll( std::wstring & rsText,
522 const std::wstring & rsFnd,
523 const std::wstring & rsRep );
525 //-------------------------------------------------------------------------
548 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
549 const char pzOriginal,
550 const char pzNew );
551 //-------------------------------------------------------------------------
577 __tool_export_dll std::size_t replaceAll( std::string & rstrText,
578 std::vector<std::size_t> & rPosVector,
579 const char pzOriginal,
580 const char pzNew );
581 //-------------------------------------------------------------------------
598 __tool_export_dll std::wstring string2wstring( const std::string & rsSourceString );
599 //-------------------------------------------------------------------------
617 __tool_export_dll std::string wstring2string( const std::wstring & rwsSourceString );
618 //-------------------------------------------------------------------------
620
689 __tool_export_dll bool compareWildcardString( const std::string & rsSearchString,
690 const std::string & rsString );
691 __tool_export_dll bool compareWildcardString( const std::wstring & rsSearchString,
692 const std::wstring & rsString );
694 //-------------------------------------------------------------------------
696
711 __tool_export_dll void colorConsoleCout( const std::string & rsCoutText,
712 EnCoutColor eForeGroundColor,
713 EnCoutColor eBackGroundColor );
714 __tool_export_dll void colorConsoleCout( const std::wstring & rsCoutText,
715 EnCoutColor eForeGroundColor,
716 EnCoutColor eBackGroundColor );
718 //-------------------------------------------------------------------------
719 #if defined(_MSC_VER) || defined(__MINGW32__)
738 EnCoutColor eBackGroundColor );
739 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
740 #elif defined(__GNUC__) || defined(__BORLANDC__)
741 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
756 EnCoutColor eBackGroundColor );
757 #endif // defined(_MSC_VER) || defined(__MINGW32__) <> defined(__GNUC__) || defined(__BORLANDC__)
758 //-------------------------------------------------------------------------
759 #if defined(_MSC_VER) || defined(__MINGW32__)
771 __tool_export_dll void resetColorConsoleCout( WORD wScreenBufferInfo );
772 #endif // defined(_MSC_VER) || defined(__MINGW32__)
773 //-------------------------------------------------------------------------
774 #if defined(__GNUC__) || defined(__BORLANDC__)
785 #endif // defined(__GNUC__) || defined(__BORLANDC__)
786 //-------------------------------------------------------------------------
787 }
788 //---------------------------------------------------------------------------
802 {
803 //-------------------------------------------------------------------------
821 __tool_export_dll std::string getMonth( unsigned int uiMonth );
822 //-------------------------------------------------------------------------
848 __tool_export_dll std::string getMilitaryTime( const std::time_t & rTime );
849 //-------------------------------------------------------------------------
874 //-------------------------------------------------------------------------
892 __tool_export_dll std::string getTimeString( const std::time_t & rTime,
893 const std::string & rsFormat = "%Y.%m.%d - %X" );
894 //-------------------------------------------------------------------------
910 __tool_export_dll std::string getSystemTimeString( const std::string & rsFormat = "%Y.%m.%d - %X" );
911 //-------------------------------------------------------------------------
935 __tool_export_dll std::time_t getTime( unsigned int uiYear,
936 unsigned int uiMonth,
937 unsigned int uiDay,
938 unsigned int uiHour,
939 unsigned int uiMin,
940 unsigned int uiSec);
941 //-------------------------------------------------------------------------
942 }
943 //---------------------------------------------------------------------------
944} // namespace eut
945#endif
Header for ErrorNException
For each library, here 'EuTools' there is a type file.
#define __tool_export_dll
Definition EuToolTypes.h:77
Help functions for the processing of strings.
Definition EuStdFunctions.h:83
__tool_export_dll std::size_t replaceAll(std::string &rsText, const std::string &rsFnd, const std::string &rsRep)
Exchanges all searched substrings in a string with another passed string.
__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)
Outputs a string to the console in color.
__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)
Compares two std::string's.
__tool_export_dll bool insertIfNotAvailable(std::string &rsText, std::size_t nPos, const std::string &rsIns)
Inserts a string at the position passed, if not already present.
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 for std::string inspired by:
__tool_export_dll std::string toUpper(const std::string &rstr)
Converts all lowercase letters of the passed string to uppercase.
__tool_export_dll WORD setColorConsoleCout(EnCoutColor eForeGroundColor, EnCoutColor eBackGroundColor)
__tool_export_dll std::string toLower(const std::string &rstr)
Converts all uppercase letters of the passed string to lowercase.
__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
Help functions for the processing of time.
Definition EuStdFunctions.h:802
__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