1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef NL_TEMPLATIZER_H
18 #define NL_TEMPLATIZER_H
20 #include <nel/misc/types_nl.h>
21 #include <nel/misc/common.h>
22 #include <nel/misc/debug.h>
23 #include <nel/misc/eval_num_expr.h>
29 class ITemplatizerBloc
;
31 const char EnvSeparator
= '/';
43 class CTemplatizerEnv
: public NLMISC::CEvalNumExpr
48 CTemplatizerEnv(CTemplatizerEnv
* parent
) : Parent(parent
), CurrentArrayNode(0) { }
51 virtual ~CTemplatizerEnv();
57 virtual std::string
get(const std::string
& name
);
61 void set(const std::string
& name
, const T
& value
)
63 std::string::size_type dotpos
= name
.find(EnvSeparator
);
64 std::string child
= name
.substr(0, dotpos
);
66 if (dotpos
== std::string::npos
)
68 setAsRawText(name
, NLMISC::toString(value
));
72 getEnv(child
)->set(name
.substr(dotpos
+1), value
);
77 void define(const std::string
& name
)
82 /// Set a Conditional Define
83 void define(bool isdef
, const std::string
& name
)
89 /// Does Variable exist?
90 virtual bool exists(const std::string
& name
) const
92 TValueMap::const_iterator it
= Values
.find(name
);
93 if (it
== Values
.end())
94 return (Parent
== NULL
? false : Parent
->exists(name
));
98 /// Does Sub Environment exist?
99 virtual bool envExists(const std::string
& name
) const
101 std::string::size_type dotpos
= name
.find(EnvSeparator
);
102 std::string child
= name
.substr(0, dotpos
);
107 TEnvMap::const_iterator it
= Envs
.find(child
);
108 if (it
== Envs
.end())
111 return (dotpos
== std::string::npos
) ? true : (*it
).second
->envExists(name
.substr(dotpos
+1));
114 /// Enter Sub Env, like getEnv() but it doesn't look in parent, and always goes in current env
115 virtual CTemplatizerEnv
* getSubEnv(const std::string
& name
)
117 std::string::size_type dotpos
= name
.find(EnvSeparator
);
118 std::string child
= name
.substr(0, dotpos
);
123 CTemplatizerEnv
* env
= NULL
;
129 else if (child
== "..")
131 env
= (Parent
!= NULL
? Parent
: this);
133 else if (child
== "...")
139 TEnvMap::iterator it
= Envs
.find(child
);
140 if (it
!= Envs
.end())
146 env
= new CTemplatizerEnv(this);
152 return (dotpos
== std::string::npos
) ? env
: env
->getSubEnv(name
.substr(dotpos
+1));
156 virtual CTemplatizerEnv
* getEnv(const std::string
& name
)
158 std::string::size_type dotpos
= name
.find(EnvSeparator
);
159 std::string child
= name
.substr(0, dotpos
);
166 return (dotpos
== std::string::npos
) ? this : this->getSubEnv(name
.substr(dotpos
+1));
168 else if (child
== "..")
170 CTemplatizerEnv
* env
= (Parent
!= NULL
? Parent
: this);
171 return (dotpos
== std::string::npos
) ? env
: env
->getSubEnv(name
.substr(dotpos
+1));
173 else if (child
== "...")
175 CTemplatizerEnv
* env
= getRootEnv();
176 return (dotpos
== std::string::npos
) ? env
: env
->getSubEnv(name
.substr(dotpos
+1));
180 TEnvMap::iterator it
= Envs
.find(child
);
181 if (it
!= Envs
.end())
183 return (dotpos
== std::string::npos
) ? (*it
).second
: (*it
).second
->getSubEnv(name
.substr(dotpos
+1));
187 return Parent
!= NULL
? Parent
->getEnv(name
) : getSubEnv(name
);
193 CTemplatizerEnv
* getEnv(uint node
)
195 return getEnv(NLMISC::toString("%08X", node
));
198 /// Evaluate string (string replacement)
199 virtual std::string
eval(const std::string
& text
);
201 /// Get Next Array Node
202 CTemplatizerEnv
* nextArrayNode(const std::string
& array
)
204 CTemplatizerEnv
* aenv
= getSubEnv(array
);
205 uint node
= (aenv
->CurrentArrayNode
)++;
206 return aenv
->getSubEnv(NLMISC::toString("%08X", node
));
210 virtual void setSubEnv(const std::string
& name
, CTemplatizerEnv
* subenv
)
216 virtual CTemplatizerEnv
* getParent()
224 CTemplatizerEnv
* Parent
;
226 typedef std::map
<std::string
, ITemplatizerBloc
*> TValueMap
;
227 typedef std::map
<std::string
, CTemplatizerEnv
*> TEnvMap
;
236 virtual CTemplatizerEnv
* getRootEnv()
238 CTemplatizerEnv
* root
= this;
239 while (root
->getParent() != NULL
)
240 root
= root
->getParent();
245 /// Current Array Node
246 uint CurrentArrayNode
;
249 virtual void setAsRawText(const std::string
& name
, const std::string
& text
);
252 virtual void setValueNode(const std::string
& name
, ITemplatizerBloc
* bloc
)
258 virtual ITemplatizerBloc
* getValueNode(const std::string
& name
)
260 ITemplatizerBloc
* node
= NULL
;
261 CTemplatizerEnv
* env
= NULL
;
262 return getValueNodeAndEnv(name
, node
, env
) ? node
: NULL
;
266 virtual bool getValueNodeAndEnv(const std::string
& name
, ITemplatizerBloc
*& node
, CTemplatizerEnv
*& env
)
268 std::string::size_type pos
= name
.find_last_of(EnvSeparator
);
269 if (pos
== std::string::npos
)
271 node
= getNode(name
);
273 while (node
== NULL
&& env
!= NULL
)
275 env
= env
->getParent();
277 node
= env
->getNode(name
);
282 env
= getEnv(name
.substr(0, pos
));
284 node
= env
->getNode(name
.substr(pos
+1));
287 return node
!= NULL
&& env
!= NULL
;
290 virtual ITemplatizerBloc
* getNode(const std::string
& name
)
292 TValueMap::iterator it
= Values
.find(name
);
293 return it
== Values
.end() ? NULL
: (*it
).second
;
296 virtual NLMISC::CEvalNumExpr::TReturnState
evalValue (const char *value
, double &result
, uint32 userData
);
303 class CTemplatizerRefEnv
: public CTemplatizerEnv
308 CTemplatizerRefEnv(CTemplatizerEnv
* ref
) : CTemplatizerEnv(NULL
), Reference(ref
) { }
317 virtual std::string
get(const std::string
& name
)
319 return Reference
->get(name
);
322 /// Does Variable exist?
323 virtual bool exists(const std::string
& name
) const
325 return Reference
->exists(name
);
328 /// Does Sub Environment exist?
329 virtual bool envExists(const std::string
& name
) const
331 return Reference
->envExists(name
);
335 virtual CTemplatizerEnv
* getEnv(const std::string
& name
)
337 return Reference
->getEnv(name
);
340 /// Evaluate string (string replacement)
341 virtual std::string
eval(const std::string
& text
)
343 return Reference
->eval(text
);
346 /// Enter Sub Env, like getEnv() but it doesn't look in parent, and always goes in current env
347 virtual CTemplatizerEnv
* getSubEnv(const std::string
& name
)
349 return Reference
->getSubEnv(name
);
353 virtual CTemplatizerEnv
* getParent()
355 return Reference
->getParent();
359 CTemplatizerEnv
* Reference
;
362 virtual CTemplatizerEnv
* getRootEnv()
364 return Reference
->getRootEnv();
368 virtual void setAsRawText(const std::string
& name
, const std::string
& text
)
370 Reference
->setAsRawText(name
, text
);
374 virtual void setValueNode(const std::string
& name
, ITemplatizerBloc
* bloc
)
376 Reference
->setValueNode(name
, bloc
);
380 virtual ITemplatizerBloc
* getValueNode(const std::string
& name
)
382 return Reference
->getValueNode(name
);
386 virtual bool getValueNodeAndEnv(const std::string
& name
, ITemplatizerBloc
*& node
, CTemplatizerEnv
*& env
)
388 return Reference
->getValueNodeAndEnv(name
, node
, env
);
391 virtual ITemplatizerBloc
* getNode(const std::string
& name
)
393 return Reference
->getNode(name
);
399 * <Class description>
400 * \author Benjamin Legros
401 * \author Nevrax France
417 * Build templatizer from text
419 bool build(const char* text
);
423 * Evaluate template and render to string
432 void set(const std::string
& var
, const T
& value
)
437 std::string::size_type pos
= var
.find_last_of(EnvSeparator
);
439 if (pos
== std::string::npos
)
441 RootEnv
->set(var
, value
);
445 RootEnv
->getEnv(var
.substr(0, pos
))->set(var
.substr(pos
+1), value
);
451 ITemplatizerBloc
* RootBloc
;
453 CTemplatizerEnv
* RootEnv
;
459 class CTemplatizerParser
463 CTemplatizerParser() : _Buffer(NULL
), _Line(0), _Valid(false) { }
464 CTemplatizerParser(const CTemplatizerParser
& ptr
) : _Buffer(ptr
._Buffer
), _Line(ptr
._Line
), _Valid(ptr
._Valid
) { }
465 CTemplatizerParser(const char* buffer
, uint linestart
= 1) : _Buffer(buffer
), _Line(linestart
), _Valid(_Buffer
!= NULL
) { }
467 char operator * () const { return *_Buffer
; }
468 char operator [] (int i
) const { return _Buffer
[i
]; }
470 CTemplatizerParser
& operator = (const CTemplatizerParser
& ptr
)
472 _Buffer
= ptr
._Buffer
;
478 CTemplatizerParser
& operator ++ ()
480 if (*_Buffer
== '\0')
483 if (*_Buffer
== '\n')
490 CTemplatizerParser
operator ++ (int)
492 CTemplatizerParser
ret(*this);
497 void invalidate() { _Valid
= false; }
498 bool isValid() const { return _Valid
; }
500 uint
getLine() const { return _Line
; }
518 class ITemplatizerBloc
526 virtual ~ITemplatizerBloc();
531 virtual std::string
eval(CTemplatizerEnv
* env
)
535 for (i
=0; i
<Blocs
.size(); ++i
)
536 res
+= Blocs
[i
]->eval(env
);
540 /// Get Text (assuming this is a raw text bloc)
541 virtual std::string
getText(CTemplatizerEnv
* env
)
547 virtual const char** getDefParamList()
552 /// Get Actual Bloc (not a reference)
553 virtual ITemplatizerBloc
* getActualBloc()
560 std::string
evalParam(const std::string
& param
, CTemplatizerEnv
* env
)
562 TParamMap::iterator it
= Params
.find(param
);
563 if (it
== Params
.end())
565 return (*it
).second
->eval(env
);
579 typedef std::vector
<ITemplatizerBloc
*> TBlocList
;
580 typedef std::map
<std::string
, ITemplatizerBloc
*> TParamMap
;
590 static ITemplatizerBloc
* parseBloc(CTemplatizerParser
& ptr
);
592 /// Parse bloc header
593 virtual CTemplatizerParser
parseHeader(CTemplatizerParser ptr
);
595 /// Parse bloc internal data
596 virtual CTemplatizerParser
parseInternal(CTemplatizerParser ptr
);
598 /// Has A Internal Bloc of data
599 virtual bool hasInternal() const { return true; }
607 class CTemplatizerRootBloc
: public ITemplatizerBloc
614 class CTemplatizerReferenceBloc
: public ITemplatizerBloc
618 ITemplatizerBloc
* Reference
;
621 CTemplatizerReferenceBloc(ITemplatizerBloc
* ref
= NULL
) : Reference(ref
) {}
624 virtual ~CTemplatizerReferenceBloc()
630 virtual std::string
eval(CTemplatizerEnv
* env
)
632 std::string name
= evalParam("name", env
);
633 std::string ref
= evalParam("ref", env
);
634 ITemplatizerBloc
* refnode
= env
->getValueNode(ref
);
636 env
->setValueNode(name
, new CTemplatizerReferenceBloc(refnode
));
638 nlwarning("Failed to create reference on '%s', not found", name
.c_str());
642 /// Get Text (assuming this is a raw text bloc)
643 virtual std::string
getText(CTemplatizerEnv
* env
)
645 return Reference
->getText(env
);
649 virtual const char** getDefParamList()
651 static const char* args
[] = { "name", "ref" };
652 return (const char**)args
;
655 /// Get Actual Bloc (not a reference)
656 virtual ITemplatizerBloc
* getActualBloc()
658 return Reference
->getActualBloc();
661 /// Has A Internal Bloc of data
662 virtual bool hasInternal() const { return false; }
667 class CTemplatizerRefEnvBloc
: public ITemplatizerBloc
672 virtual std::string
eval(CTemplatizerEnv
* env
)
674 std::string name
= evalParam("name", env
);
675 std::string ref
= evalParam("ref", env
);
677 CTemplatizerEnv
* refenv
= env
->getEnv(ref
);
679 env
->setSubEnv(name
, new CTemplatizerRefEnv(refenv
));
681 nlwarning("Failed to create reference on env '%s', not found", name
.c_str());
686 virtual const char** getDefParamList()
688 static const char* args
[] = { "name", "ref" };
689 return (const char**)args
;
692 /// Has A Internal Bloc of data
693 virtual bool hasInternal() const { return false; }
703 class CTemplatizerCommentBloc
: public ITemplatizerBloc
707 virtual std::string
eval(CTemplatizerEnv
* env
)
712 /// Parse bloc internal data
713 virtual CTemplatizerParser
parseInternal(CTemplatizerParser ptr
);
721 class CTemplatizerRawTextBloc
: public ITemplatizerBloc
727 virtual std::string
eval(CTemplatizerEnv
* env
)
732 virtual std::string
getText(CTemplatizerEnv
* env
)
739 inline void CTemplatizerEnv::setAsRawText(const std::string
& name
, const std::string
& text
)
741 CTemplatizerRawTextBloc
* bloc
= new CTemplatizerRawTextBloc();
743 setValueNode(name
, bloc
);
747 inline std::string
CTemplatizerEnv::get(const std::string
& name
)
749 ITemplatizerBloc
* bloc
= getValueNode(name
);
751 return (bloc
== NULL
) ? std::string("") : bloc
->getText(this);
754 // eval num expr override
755 inline NLMISC::CEvalNumExpr::TReturnState
CTemplatizerEnv::evalValue (const char *value
, double &result
, uint32 userData
)
759 return NLMISC::CEvalNumExpr::ValueError
;
762 std::string strvalue
= get(value
+1);
764 if (sscanf(strvalue
.c_str(), "%lf", &result
) != 1)
766 result
= (strvalue
.empty() ? 0.0 : 1.0);
769 return NLMISC::CEvalNumExpr::NoError
;
777 class CTemplatizerTextBloc
: public ITemplatizerBloc
783 virtual std::string
eval(CTemplatizerEnv
* env
)
785 return env
->eval(Text
);
788 virtual std::string
getText(CTemplatizerEnv
* env
)
790 return env
->eval(Text
);
793 /// Parse bloc internal data
794 virtual CTemplatizerParser
parseInternal(CTemplatizerParser ptr
);
803 class CTemplatizerSubBloc
: public ITemplatizerBloc
807 virtual std::string
eval(CTemplatizerEnv
* env
)
809 std::string subname
= evalParam("name", env
);
810 CTemplatizerEnv
* subenv
= env
->getSubEnv(subname
);
812 return ITemplatizerBloc::eval(subenv
);
816 virtual const char** getDefParamList()
818 static const char* args
[] = { "name" };
819 return (const char**)args
;
827 class CTemplatizerLoopBloc
: public ITemplatizerBloc
831 virtual std::string
eval(CTemplatizerEnv
* env
)
833 std::string subname
= evalParam("name", env
);
834 CTemplatizerEnv
* subenv
= env
->getSubEnv(subname
);
838 CTemplatizerEnv::TEnvMap::iterator it
;
839 for (it
=subenv
->Envs
.begin(); it
!=subenv
->Envs
.end(); ++it
)
840 res
+= ITemplatizerBloc::eval((*it
).second
);
846 virtual const char** getDefParamList()
848 static const char* args
[] = { "name" };
849 return (const char**)args
;
857 class CTemplatizerIfDefEnvBloc
: public ITemplatizerBloc
861 virtual std::string
eval(CTemplatizerEnv
* env
)
863 std::string subname
= evalParam("name", env
);
864 std::string evalinsub
= evalParam("evalinsub", env
);
866 if (env
->envExists(subname
))
869 NLMISC::fromString(evalinsub
, eval
);
870 CTemplatizerEnv
* subenv
= (eval
? env
->getEnv(subname
) : env
);
871 return ITemplatizerBloc::eval(subenv
);
878 virtual const char** getDefParamList()
880 static const char* args
[] = { "name", "evalinsub" };
881 return (const char**)args
;
889 class CTemplatizerIfDefBloc
: public ITemplatizerBloc
893 virtual std::string
eval(CTemplatizerEnv
* env
)
895 std::string varname
= evalParam("name", env
);
897 if (env
->exists(varname
))
899 return ITemplatizerBloc::eval(env
);
906 virtual const char** getDefParamList()
908 static const char* args
[] = { "name" };
909 return (const char**)args
;
917 class CTemplatizerIfNotDefEnvBloc
: public ITemplatizerBloc
921 virtual std::string
eval(CTemplatizerEnv
* env
)
923 std::string subname
= evalParam("name", env
);
925 if (!env
->envExists(subname
))
927 return ITemplatizerBloc::eval(env
);
934 virtual const char** getDefParamList()
936 static const char* args
[] = { "name" };
937 return (const char**)args
;
945 class CTemplatizerIfNotDefBloc
: public ITemplatizerBloc
949 virtual std::string
eval(CTemplatizerEnv
* env
)
951 std::string varname
= evalParam("name", env
);
953 if (!env
->exists(varname
))
955 return ITemplatizerBloc::eval(env
);
962 virtual const char** getDefParamList()
964 static const char* args
[] = { "name" };
965 return (const char**)args
;
973 class CTemplatizerSwitchBloc
: public ITemplatizerBloc
977 virtual std::string
eval(CTemplatizerEnv
* env
)
979 std::string switchvalue
= evalParam("value", env
);
982 for (i
=0; i
<Blocs
.size(); ++i
)
983 if (Blocs
[i
]->evalParam("case", env
) == switchvalue
)
984 return Blocs
[i
]->eval(env
);
990 virtual const char** getDefParamList()
992 static const char* args
[] = { "value" };
993 return (const char**)args
;
1000 class CTemplatizerFileBloc
: public ITemplatizerBloc
1004 virtual std::string
eval(CTemplatizerEnv
* env
)
1006 std::string clearfile
= evalParam("clear", env
);
1007 std::string filename
= evalParam("name", env
);
1009 std::string result
= ITemplatizerBloc::eval(env
);
1012 f
= NLMISC::nlfopen(filename
, (clearfile
== "true" ? "w" : "a"));
1015 fwrite(result
.c_str(), 1, result
.size(), f
);
1023 virtual const char** getDefParamList()
1025 static const char* args
[] = { "name" };
1026 return (const char**)args
;
1033 class CTemplatizerSetBloc
: public ITemplatizerBloc
1037 virtual std::string
eval(CTemplatizerEnv
* env
)
1039 std::string var
= evalParam("name", env
);
1040 std::string result
= ITemplatizerBloc::eval(env
);
1042 env
->set(var
, result
);
1048 virtual const char** getDefParamList()
1050 static const char* args
[] = { "name" };
1051 return (const char**)args
;
1058 class CTemplatizerAppendBloc
: public ITemplatizerBloc
1062 virtual std::string
eval(CTemplatizerEnv
* env
)
1064 std::string var
= evalParam("name", env
);
1065 std::string result
= ITemplatizerBloc::eval(env
);
1067 ITemplatizerBloc
* bloc
= env
->getValueNode(var
);
1071 CTemplatizerRawTextBloc
* text
= dynamic_cast<CTemplatizerRawTextBloc
*>(bloc
->getActualBloc());
1075 text
->Text
+= result
;
1081 virtual const char** getDefParamList()
1083 static const char* args
[] = { "name" };
1084 return (const char**)args
;
1091 class CTemplatizerDefineBloc
: public ITemplatizerBloc
1095 virtual std::string
eval(CTemplatizerEnv
* env
)
1097 std::string name
= evalParam("name", env
);
1098 env
->setValueNode(name
, new CTemplatizerReferenceBloc(this));
1102 virtual std::string
getText(CTemplatizerEnv
* env
)
1104 return ITemplatizerBloc::eval(env
);
1108 virtual const char** getDefParamList()
1110 static const char* args
[] = { "name" };
1111 return (const char**)args
;
1118 class CTemplatizerIfBloc
: public ITemplatizerBloc
1122 virtual std::string
eval(CTemplatizerEnv
* env
)
1124 std::string value
= evalParam("cond", env
);
1126 NLMISC::CEvalNumExpr::TReturnState res
= env
->evalExpression(value
.c_str(), result
, NULL
);
1128 if (res
== NLMISC::CEvalNumExpr::NoError
&& result
!= 0.0)
1130 return ITemplatizerBloc::eval(env
);
1139 virtual const char** getDefParamList()
1141 static const char* args
[] = { "cond" };
1142 return (const char**)args
;
1149 class CTemplatizerIfNotBloc
: public ITemplatizerBloc
1153 virtual std::string
eval(CTemplatizerEnv
* env
)
1155 std::string value
= evalParam("cond", env
);
1159 return ITemplatizerBloc::eval(env
);
1168 virtual const char** getDefParamList()
1170 static const char* args
[] = { "cond" };
1171 return (const char**)args
;
1178 class CTemplatizerJoinBloc
: public ITemplatizerBloc
1182 virtual std::string
eval(CTemplatizerEnv
* env
)
1184 std::string sep
= evalParam("separator", env
);
1188 for (i
=0; i
<Blocs
.size(); ++i
)
1190 std::string token
= Blocs
[i
]->eval(env
);
1204 virtual const char** getDefParamList()
1206 static const char* args
[] = { "separator" };
1207 return (const char**)args
;
1212 * User Defined function call
1214 class CTemplatizerUserFunctionBloc
: public ITemplatizerBloc
1218 CTemplatizerUserFunctionBloc(const std::string
& name
) : Name(name
) {}
1222 virtual std::string
eval(CTemplatizerEnv
* env
)
1224 ITemplatizerBloc
* func
= NULL
;
1225 CTemplatizerEnv
* fenv
= NULL
;
1226 if (!env
->getValueNodeAndEnv(Name
, func
, fenv
))
1228 nlwarning("Unknown user function '%s'", Name
.c_str());
1232 // subenv is child of object env, not of current env
1233 CTemplatizerEnv
* subenv
= new CTemplatizerEnv(fenv
);
1235 // deport params in subenv
1236 // \todo : eval param in current env
1237 TParamMap::iterator it
;
1238 for (it
=Params
.begin(); it
!=Params
.end(); ++it
)
1239 subenv
->setAsRawText((*it
).first
, (*it
).second
->getText(env
));
1240 //subenv->setValueNode((*it).first, new CTemplatizerReferenceBloc((*it).second));
1242 std::string res
= func
->getText(subenv
);
1250 virtual const char** getDefParamList()
1255 /// Has A Internal Bloc of data
1256 virtual bool hasInternal() const
1265 class CTemplatizerClassBloc
: public ITemplatizerBloc
1269 virtual std::string
eval(CTemplatizerEnv
* env
)
1271 std::string name
= evalParam("name", env
);
1272 env
->setValueNode(name
, new CTemplatizerReferenceBloc(this));
1276 virtual std::string
instantiate(CTemplatizerEnv
* env
)
1278 return ITemplatizerBloc::eval(env
);
1282 virtual const char** getDefParamList()
1284 static const char* args
[] = { "name" };
1285 return (const char**)args
;
1292 class CTemplatizerObjectBloc
: public ITemplatizerBloc
1296 virtual std::string
eval(CTemplatizerEnv
* env
)
1298 std::string classname
= evalParam("class", env
);
1299 std::string name
= evalParam("name", env
);
1301 ITemplatizerBloc
* bloc
= env
->getValueNode(classname
);
1304 nlwarning("Unknown class '%s'", classname
.c_str());
1308 CTemplatizerClassBloc
* classbloc
= dynamic_cast<CTemplatizerClassBloc
*>(bloc
->getActualBloc());
1309 if (classbloc
== NULL
)
1311 nlwarning("object '%s' is not a class", classname
.c_str());
1315 CTemplatizerEnv
* objectenv
= env
->getSubEnv(name
);
1318 return classbloc
->instantiate(objectenv
);
1322 virtual const char** getDefParamList()
1324 static const char* args
[] = { "class", "name" };
1325 return (const char**)args
;
1328 /// Has A Internal Bloc of data
1329 virtual bool hasInternal() const { return false; }
1336 class CTemplatizerBreakpointBloc
: public ITemplatizerBloc
1340 virtual std::string
eval(CTemplatizerEnv
* env
)
1342 std::string value
= evalParam("name", env
);
1347 virtual const char** getDefParamList()
1349 static const char* args
[] = { "name" };
1350 return (const char**)args
;
1355 #endif // NL_TEMPLATIZER_H
1357 /* End of templatizer.h */