33 #define lookup( a, b ) _lookup( a, b, sizeof(b)/sizeof(char*) )
34 #define lookup2( a, b ) _lookup2( a, b, sizeof(b)/sizeof(char*) )
35 #define deflookup( a, b, c ) _lookup( a, b, sizeof(b)/sizeof(char*), c )
36 #define deflookup2( a, b, c ) _lookup2( a, b, sizeof(b)/sizeof(char*), c )
46 GLOOX_API
unsigned _lookup(
const std::string& str,
const char* values[],
47 unsigned size,
int def = -1 );
57 GLOOX_API
const std::string
_lookup(
unsigned code,
const char* values[],
58 unsigned size,
const std::string& def =
EmptyString );
68 GLOOX_API
unsigned _lookup2(
const std::string& str,
const char* values[],
69 unsigned size,
int def = -1 );
79 GLOOX_API
const std::string
_lookup2(
unsigned code,
const char* values[],
80 unsigned size,
const std::string& def =
EmptyString );
87 template<
typename T,
typename F >
90 for(
typename T::iterator it = t.begin(); it != t.end(); ++it )
101 template<
typename T,
typename F,
typename D >
104 for(
typename T::iterator it = t.begin(); it != t.end(); ++it )
116 template<
typename T,
typename F,
typename D1,
typename D2 >
117 inline void ForEach( T& t, F f, D1& d1, D2& d2 )
119 for(
typename T::iterator it = t.begin(); it != t.end(); ++it )
120 ( (*it)->*f )( d1, d2 );
132 template<
typename T,
typename F,
typename D1,
typename D2,
typename D3 >
133 inline void ForEach( T& t, F f, D1& d1, D2& d2, D3& d3 )
135 for(
typename T::iterator it = t.begin(); it != t.end(); ++it )
136 ( (*it)->*f )( d1, d2, d3 );
143 template<
typename T >
146 typename std::list< T* >::iterator it = L.begin();
147 typename std::list< T* >::iterator it2;
148 while( it != L.end() )
160 template<
typename Key,
typename T >
163 typename std::map< Key, T* >::iterator it = M.begin();
164 typename std::map< Key, T* >::iterator it2;
165 while( it != M.end() )
168 delete (*it2).second;
178 template<
typename Key,
typename T >
179 inline void clearMap( std::map< const Key, T* >& M )
181 typename std::map< const Key, T* >::iterator it = M.begin();
182 typename std::map< const Key, T* >::iterator it2;
183 while( it != M.end() )
186 delete (*it2).second;
196 GLOOX_API
const std::string
escape( std::string what );
221 GLOOX_API
void replaceAll( std::string& target,
const std::string& find,
const std::string& replace );
229 static inline const std::string long2string(
long int value,
const int base = 10 )
232 if( base < 2 || base > 16 || value == 0 )
239 int len = (int)( log( (
double)( value ? value : 1 ) ) / log( (
double)base ) ) + 1;
240 const char digits[] =
"0123456789ABCDEF";
241 char* num = (
char*)calloc( len + 1 + add,
sizeof(
char ) );
245 while( value && len > -1 )
247 num[len-- + add] = digits[(int)( value % base )];
250 const std::string result( num );
260 static inline const std::string int2string(
int value )
262 return long2string( value );