1 /******************************************************************************
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
9 ******************************************************************************/
10 //$Id: aux_utils.h 5847 2009-01-21 16:09:27Z antonn $
11 #ifndef _AUX_UTILS_H_INCLUDED_
12 #define _AUX_UTILS_H_INCLUDED_
17 #pragma warning(push,3)
18 #pragma warning(disable:4242)
33 //GCC has a bug related to use of toupper/tolower
35 //See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11108
36 //This is a workaround for the bug.
37 static int toupper_gcc_workaround(int c
)
39 static int tolower_gcc_workaround(int c
)
42 inline string
strToUpper(string str
)
44 std::transform(str
.begin(), str
.end(), str
.begin(), toupper_gcc_workaround
);
48 inline string
strToLower(string str
)
50 std::transform(str
.begin(), str
.end(), str
.begin(), tolower_gcc_workaround
);
54 inline int stringToint( const string
& str
)
56 std::istringstream
s( str
);
60 return (s
.rdstate() & std::ios::failbit
) ? 0 : ret
;
63 inline string
intTostring( int value
)
70 inline string
GetFileSystemPathSeparator()
77 #error Unknown operating system
86 friend class CStrTokenizer
;
88 iterator( const iterator
& other
)
89 : m_tokenizer(other
.m_tokenizer
)
90 , m_token(other
.m_token
)
93 const string
& get() const
95 iterator
& operator = (const iterator
& other
);
96 iterator
& operator ++();
97 operator bool() const;
100 const CStrTokenizer
& tokenizer
,
101 const string
& separator
,
103 mutable string m_separator
;
104 const CStrTokenizer
& m_tokenizer
;
108 friend class iterator
;
109 CStrTokenizer( const string
& str
)
112 iterator
begin( const string
& separator
) const
114 return iterator( *this, separator
, 0);
117 bool operator != (const CStrTokenizer
& other
) const
119 return this != &other
;
124 void GetDirectoryContents(const string
& strDir
, string strFileMask
,
125 vector
<string
>& Result
, bool fFilesOnly
);
129 class exc_basic
: public exception
132 virtual ~exc_basic() throw() {
135 virtual const char *what() const throw() {
136 return m_str
.c_str();
143 class exc_assert
: public exc_basic
146 exc_assert (const char* str
,
147 const char *fname
= NULL
,
150 ss
<< "Assertion failed : " << str
;
152 ss
<< fname
<< " : ";
155 ss
<< str_no
<< " : ";
161 #define EXC_ASSERT(expr) \
164 throw exc_assert(#expr, __FILE__, __LINE__); \
168 #endif //_AUX_UTILS_H_INCLUDED_