6 Usage: genclass [path/]stem
11 test -z "$1" && usage "Missing name!"
13 TOPSRCDIR=${XTOPSRCDIR:-$(cd @CMAKE_SOURCE_DIR@ && pwd)}
14 test -z "$TOPSRCDIR" && {
15 echo "Dir does not exist '$TOPSRCDIR'" >&2
21 STEMDIR=$( cd $OUTDIR && pwd )
22 test -z "$STEMDIR" && {
23 echo "Dir does not exist '$(dirname $1)'" >&2
26 STEMDIR=${STEMDIR#$TOPSRCDIR/}
29 CLASS_H=$STEMDIR/$STEM.h
30 CLASS_CC=$STEMDIR/$STEM.cc
32 OUT_CLASS_H=$OUTDIR/$STEM.h
33 OUT_CLASS_CC=$OUTDIR/$STEM.cc
34 test -e $OUT_CLASS_H -o -e $OUT_CLASS_CC && {
35 test -e $OUT_CLASS_H && echo "File exists '$OUT_CLASS_H' using '$OUT_CLASS_H.new'" >&2
36 test -e $OUT_CLASS_CC && echo "File exists '$OUT_CLASS_CC' using '$OUT_CLASS_CC.new'" >&2
37 OUT_CLASS_H="$OUT_CLASS_H.new"
38 OUT_CLASS_CC="$OUT_CLASS_CC.new"
42 INCLUDE_DEF=$(echo $INCLUDE_H | sed 's/[./]/_/g' | awk '{print toupper($0)}')
43 NSLIST=$(echo $(dirname $INCLUDE_H) | awk '{l=tolower($0);gsub("/"," ",l);print l}')
51 ######################################################################
53 ######################################################################
56 /*---------------------------------------------------------------------\\
58 | |__ / \ / / . \ . \ |
61 | /_____||_| |_| |_| |
63 \---------------------------------------------------------------------*/
70 ######################################################################
72 ######################################################################
75 echo "${I}///////////////////////////////////////////////////////////////////"
76 echo "${I}namespace $N"
77 echo "${I}{ /////////////////////////////////////////////////////////////////"
82 ######################################################################
84 ######################################################################
87 echo "${I}/////////////////////////////////////////////////////////////////"
89 echo "${I}} // namespace $N"
90 echo "${I}///////////////////////////////////////////////////////////////////"
94 ######################################################################
96 ######################################################################
104 #include "zypp/base/PtrTypes.h"
108 ${INDENT}///////////////////////////////////////////////////////////////////
110 ${INDENT}// CLASS NAME : ${CLASS}
113 ${INDENT}class ${CLASS}
115 ${INDENT} friend std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj );
118 ${INDENT} /** Implementation */
119 ${INDENT} class Impl;
122 ${INDENT} /** Default ctor */
123 ${INDENT} ${CLASS}();
124 ${INDENT} /** Dtor */
125 ${INDENT} ~${CLASS}();
130 ${INDENT} /** Pointer to implementation */
131 ${INDENT} RWCOW_pointer<Impl> _pimpl;
133 ${INDENT}///////////////////////////////////////////////////////////////////
135 ${INDENT}/** \relates ${CLASS} Stream output */
136 ${INDENT}std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj );
139 #endif // $INCLUDE_DEF
143 ######################################################################
145 ######################################################################
149 //#include "zypp/base/LogTools.h"
151 #include "${INCLUDE_H}"
157 ${INDENT}///////////////////////////////////////////////////////////////////
159 ${INDENT}// CLASS NAME : ${CLASS}::Impl
161 ${INDENT}/** ${CLASS} implementation. */
162 ${INDENT}struct ${CLASS}::Impl
166 ${INDENT} /** Offer default Impl. */
167 ${INDENT} static shared_ptr<Impl> nullimpl()
169 ${INDENT} static shared_ptr<Impl> _nullimpl( new Impl );
170 ${INDENT} return _nullimpl;
174 ${INDENT} friend Impl * rwcowClone<Impl>( const Impl * rhs );
175 ${INDENT} /** clone for RWCOW_pointer */
176 ${INDENT} Impl * clone() const
177 ${INDENT} { return new Impl( *this ); }
179 ${INDENT}///////////////////////////////////////////////////////////////////
181 ${INDENT}/** \relates ${CLASS}::Impl Stream output */
182 ${INDENT}inline std::ostream & operator<<( std::ostream & str, const ${CLASS}::Impl & obj )
184 ${INDENT} return str << "${CLASS}::Impl";
187 ${INDENT}///////////////////////////////////////////////////////////////////
189 ${INDENT}// CLASS NAME : ${CLASS}
191 ${INDENT}///////////////////////////////////////////////////////////////////
193 ${INDENT}///////////////////////////////////////////////////////////////////
195 ${INDENT}// METHOD NAME : ${CLASS}::${CLASS}
196 ${INDENT}// METHOD TYPE : Ctor
198 ${INDENT}${CLASS}::${CLASS}()
199 ${INDENT}: _pimpl( Impl::nullimpl() )
202 ${INDENT}///////////////////////////////////////////////////////////////////
204 ${INDENT}// METHOD NAME : ${CLASS}::~${CLASS}
205 ${INDENT}// METHOD TYPE : Dtor
207 ${INDENT}${CLASS}::~${CLASS}()
210 ${INDENT}/******************************************************************
212 ${INDENT}** FUNCTION NAME : operator<<
213 ${INDENT}** FUNCTION TYPE : std::ostream &
215 ${INDENT}std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj )
217 ${INDENT} return str << *obj._pimpl;
224 ######################################################################
225 ######################################################################
226 ######################################################################