00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef Fennel_ResourceDefinition_Included
00024 #define Fennel_ResourceDefinition_Included
00025
00026 #include <string>
00027 #include <boost/format.hpp>
00028
00029 #include "fennel/common/ResourceBundle.h"
00030
00031 FENNEL_BEGIN_NAMESPACE
00032
00033 class FENNEL_COMMON_EXPORT ResourceDefinition
00034 {
00035 const std::string _key;
00036
00037 public:
00038 explicit ResourceDefinition(
00039 ResourceBundle *bundle,
00040 const std::string &key);
00041
00042 virtual ~ResourceDefinition();
00043
00044 std::string format() const;
00045
00046 template<typename t0>
00047 std::string format(const t0 &p0) const
00048 {
00049 boost::format fmt = prepareFormatter(1);
00050
00051 return boost::io::str(fmt % p0);
00052 }
00053
00054 template<typename t0, typename t1>
00055 std::string format(const t0 &p0, const t1 &p1) const
00056 {
00057 boost::format fmt = prepareFormatter(2);
00058
00059 return boost::io::str(fmt % p0 % p1);
00060 }
00061
00062 template<typename t0, typename t1, typename t2>
00063 std::string format(const t0 &p0, const t1 &p1, const t2 &p2) const
00064 {
00065 boost::format fmt = prepareFormatter(3);
00066
00067 return boost::io::str(fmt % p0 % p1 % p2);
00068 }
00069
00070 template<typename t0, typename t1, typename t2, typename t3>
00071 std::string format(
00072 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3) const
00073 {
00074 boost::format fmt = prepareFormatter(4);
00075
00076 return boost::io::str(fmt % p0 % p1 % p2 % p3);
00077 }
00078
00079 template<typename t0, typename t1, typename t2, typename t3, typename t4>
00080 std::string format(
00081 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00082 const t4 &p4) const
00083 {
00084 boost::format fmt = prepareFormatter(5);
00085
00086 return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4);
00087 }
00088
00089 template<typename t0, typename t1, typename t2, typename t3, typename t4,
00090 typename t5>
00091 std::string format(
00092 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00093 const t4 &p4, const t5 &p5) const
00094 {
00095 boost::format fmt = prepareFormatter(6);
00096
00097 return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5);
00098 }
00099
00100 template<typename t0, typename t1, typename t2, typename t3, typename t4,
00101 typename t5, typename t6>
00102 std::string format(
00103 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00104 const t4 &p4, const t5 &p5, const t6 &p6) const
00105 {
00106 boost::format fmt = prepareFormatter(7);
00107
00108 return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6);
00109 }
00110
00111 template<typename t0, typename t1, typename t2, typename t3, typename t4,
00112 typename t5, typename t6, typename t7>
00113 std::string format(
00114 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00115 const t4 &p4, const t5 &p5, const t6 &p6, const t7 &p7) const
00116 {
00117 boost::format fmt = prepareFormatter(8);
00118
00119 return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6 % p7);
00120 }
00121
00122 template<typename t0, typename t1, typename t2, typename t3, typename t4,
00123 typename t5, typename t6, typename t7, typename t8>
00124 std::string format(
00125 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00126 const t4 &p4, const t5 &p5, const t6 &p6, const t7 &p7,
00127 const t8 &p8) const
00128 {
00129 boost::format fmt = prepareFormatter(9);
00130
00131 return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6 % p7 % p8);
00132 }
00133
00134 template<typename t0, typename t1, typename t2, typename t3, typename t4,
00135 typename t5, typename t6, typename t7, typename t8, typename t9>
00136 std::string format(
00137 const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00138 const t4 &p4, const t5 &p5, const t6 &p6, const t7 &p7,
00139 const t8 &p8, const t9 &p9) const
00140 {
00141 boost::format fmt = prepareFormatter(10);
00142
00143 return boost::io::str(
00144 fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6 % p7 % p8 % p9);
00145 }
00146
00147
00148
00149 protected:
00150 boost::format prepareFormatter(int numArgs) const;
00151
00152 private:
00153 ResourceBundle *_bundle;
00154 };
00155
00156 FENNEL_END_NAMESPACE
00157
00158 #endif // not Fennel_ResourceDefinition_Included
00159
00160