15 Header =
"""// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
18 // (c) Copyright Rosetta Commons Member Institutions.
19 // (c) This file is part of the Rosetta software suite and is made available under license.
20 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
21 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
22 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
24 /// @file utility/tools/make_vector.hh
25 /// @brief Common function to build vector, vector0, vector1, map.
26 /// @author Sergey Lyskov
28 #ifndef INCLUDED_utility_tools_%(iguard)s
29 #define INCLUDED_utility_tools_%(iguard)s
39 } // namespace utility
42 #endif // INCLUDED_utility_tools_%(iguard)s
47 r =
"template<typename T>\n%s<T> %s(const T & i0" % (className, functionName)
48 for i
in range(1, n): r +=
', const T & i%d' % i
49 r +=
')\n{\n %s<T> v;\n ' % className
50 for i
in range(n): r +=
' v.push_back(i%d);' % i
51 r +=
'\n return(v);\n}\n\n'
55 r =
"template<typename T1, typename T2>\n%s<T1, T2> make_map(const T1 &f0, const T2 & s0" % className
56 for i
in range(1, n): r +=
', const T1 & f%d, const T2 & s%d' % (i,i)
57 r +=
')\n{\n %s<T1, T2> m;\n '% className
58 for i
in range(n): r +=
' m[f%d]=s%d;' % (i, i)
59 r +=
'\n return(m);\n}\n\n'
63 def makeFile(fileName, include, function, className, cppName):
64 iguard = fileName.replace(
'.',
'_')
65 s = Header % dict(include=include, iguard=iguard)
66 for i
in range(1, NFunctions):
67 s += function(i, className, cppName)
68 s += Footer % dict(iguard=iguard)
69 f = file(fileName,
'wb'); f.write(s); f.close()
73 dict(fileName=
'make_vector.hh', include=
'#include <vector>\n',
74 function=getVectorFunction, className=
'std::vector', cppName=
'make_vector'),
76 dict(fileName=
'make_vector0.hh', include=
'#include <utility/vector0.fwd.hh>\n',
77 function=getVectorFunction, className=
'utility::vector0', cppName=
'make_vector0'),
79 dict(fileName=
'make_vector1.hh', include=
'#include <utility/vector1.fwd.hh>\n',
80 function=getVectorFunction, className=
'utility::vector1', cppName=
'make_vector1'),
82 dict(fileName=
'make_map.hh', include=
'#include <map>\n',
83 function=getMapFunction, className=
'std::map', cppName=
'make_map'),
91 for i in range(1, NFunctions):
92 s += getVectorFunction(i, 'std::vector', 'make_vector')
93 s += getVectorFunction(i, 'utility::vector0', 'make_vector0')
94 s += getVectorFunction(i, 'utility::vector1', 'make_vector1')
95 s += getMapFunction(i, 'std::map')
98 f = file('make_vector.hh', 'wb'); f.write(s); f.close()
101 if __name__ ==
"__main__":
main()