libzypp  13.10.6
Easy.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_EASY_H
13 #define ZYPP_BASE_EASY_H
14 
15 #include <cstdio>
16 
26 #ifndef __GXX_EXPERIMENTAL_CXX0X__
27 #define for_(IT,BEG,END) for ( typeof(BEG) IT = BEG, _for_end = END; IT != _for_end; ++IT )
28 #else
29 #define for_(IT,BEG,END) for ( auto IT = BEG, _for_end = END; IT != _for_end; ++IT )
30 #endif
31 #define for_each_(IT,CONT) for_( IT, CONT.begin(), CONT.end() )
32 
40 #define arrayBegin(A) (&A[0])
41 #define arraySize(A) (sizeof(A)/sizeof(*A))
42 #define arrayEnd(A) (&A[0] + arraySize(A))
43 
50 #define defConstStr(FNC,STR) inline const std::string & FNC { static const std::string val( STR ); return val; }
51 
52 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
53 #if GCC_VERSION < 40600 || not defined(__GXX_EXPERIMENTAL_CXX0X__)
54 #define nullptr NULL
55 #endif
56 
58 #define NON_COPYABLE(CLASS) \
59  CLASS( const CLASS & ) = delete; \
60  CLASS & operator=( const CLASS & ) = delete
61 
63 #define DEFAULT_COPYABLE(CLASS) \
64  CLASS( const CLASS & ) = default; \
65  CLASS & operator=( const CLASS & ) = default
66 
67 #ifndef SWIG // Swig treats it as syntax error
68 
69 #define NON_MOVABLE(CLASS) \
70  CLASS( CLASS && ) = delete; \
71  CLASS & operator=( CLASS && ) = delete
72 
74 #define DEFAULT_MOVABLE(CLASS) \
75  CLASS( CLASS && ) = default; \
76  CLASS & operator=( CLASS && ) = default
77 #else
78 #define NON_MOVABLE(CLASS)
79 #define DEFAULT_MOVABLE(CLASS)
80 #endif
81 
83 #define NON_COPYABLE_BUT_MOVE( CLASS ) \
84  NON_COPYABLE(CLASS); \
85  DEFAULT_MOVABLE(CLASS)
86 
88 #define NON_MOVABLE_BUT_COPY( CLASS ) \
89  NON_MOVABLE(CLASS); \
90  DEFAULT_COPYABLE(CLASS)
91 
93 namespace zypp
94 {
95 } // namespace zypp
98 #endif // ZYPP_BASE_EASY_H