Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (29 sloc) 1.273 kb
d2d4ed0 Full Support for Google Reader Sync!
Salvatore Ansani authored
1 #pragma once
2 // Copyright (c) 2008-2010, Vincent Gable.
3 // vincent.gable@gmail.com
4
5 //based off of http://www.dribin.org/dave/blog/archives/2008/09/22/convert_to_nsstring/
6 NSString * VTPG_DDToStringFromTypeAndValue(const char * typeCode, void * value);
7
8 // WARNING: if NO_LOG_MACROS is #define-ed, than THE ARGUMENT WILL NOT BE EVALUATED
9 #ifndef NO_LOG_MACROS
10
11
12 #define LOG_EXPR(_X_) do{\
13 __typeof__(_X_) _Y_ = (_X_);\
14 const char * _TYPE_CODE_ = @encode(__typeof__(_X_));\
15 NSString *_STR_ = VTPG_DDToStringFromTypeAndValue(_TYPE_CODE_, &_Y_);\
16 if(_STR_)\
17 NSLog(@"%s = %@", #_X_, _STR_);\
18 else\
19 NSLog(@"Unknown _TYPE_CODE_: %s for expression %s in function %s, file %s, line %d", _TYPE_CODE_, #_X_, __func__, __FILE__, __LINE__);\
20 }while(0)
21
22 #define LOG_NS(...) NSLog(__VA_ARGS__)
23 #define LOG_FUNCTION() NSLog(@"%s", __func__)
24
25 #else /* NO_LOG_MACROS */
26
27 #define LOG_EXPR(_X_)
28 #define LOG_NS(...)
29 #define LOG_FUNCTION()
30 #endif /* NO_LOG_MACROS */
31
32
33
34 // http://www.wilshipley.com/blog/2005/10/pimp-my-code-interlude-free-code.html
35 static inline BOOL IsEmpty(id thing) {
36 return thing == nil ||
37 ([thing respondsToSelector:@selector(length)] && [(NSData *)thing length] == 0) ||
38 ([thing respondsToSelector:@selector(count)] && [(NSArray *)thing count] == 0);
39 }
Something went wrong with that request. Please try again.