templates

How to create a custom template system in PHP

Hello friend I want to use a custom template system in my php application, What I want is I want to keep away my php codes from design, I would like to use a tpl file for designs and a php file for php codes I dont want to use any ready maid scripts. Can any one point out some links link or useful info how to build a php templating...

Can not get example compiled with typedef in template class

Hi, I have this example code: #include template<class T> class Class { public: typedef boost::shared_ptr<Class<T> > Ref; }; template<class T> class Class2 { public: Class<T>::Ref getAReference() {return Class<T>::Ref(new Class<T>);}; }; int main(){} When I try to compile it, I get: test.cpp:14: error: type ‘Class<T>’ i...

Window.Template kills any Validation.ErrorTemplate ?

Hallo Stackoverflow fellas! In my recent wpf application building I ancountered a strange behaviour: When I set the Template of the Window class in my application every Validation.ErrorTemplate doesn't appear anymore. So in my App.xaml I have defined the following: <Application.Resources> <Style TargetType="{x:Type TextBox}"> ...

Problem with template specialisation for a derived class

When I compile the following #include <iostream> #define XXX 1 #define YYY 2 class X { public: template< int FLD > void func(); }; template<> void X::func< XXX >() { std::cout << "X::func< " << XXX << " >" << std::endl; } class Y : public X { public: }; template<> void Y::func< YYY >() { std::cout << "Y::func< " <<...

Can I get a mediawiki template to change display text depending on its location on a page?

I want to create a MediaWiki template which shows different text depending on where it is on a page. Specifically, it is before the first heading it should show text like, "this template is applicable to this whole page" Alternatively, if it is within a section on a page (after a heading) it should show text like, "this template is spe...

template template total specialization

A template template specification is like this: template < template < class > class T > struct MyTemplate { }; How Im supposed to create a total (or parcial) specialization for this template? Is this possible? ...

Passing Template parameters

I am trying to understand templates better I have a template class that starts like this in my .h: template <class DOC_POLICY, class PRINT_POLICY, class UNDO_POLICY> class CP_EXPORT CP_Application : public CP_Application_Imp Now I need to initialize so in my .cpp so I do: CPLAT::CP_DocumentPolicy_None * d = new CPLAT::CP_DocumentPol...

In C++, how can you avoid explicit downcasts with a map of generic types?

Hey all, This is a little contrived, but say I have a class interface like this: class IResource; class IResourceContainer { public: virtual ~IResourceContainer() {} virtual void AddResource(const std::string& rStrName, std::auto_ptr<IResource> apResource)=0; virtual IResource& GetResource(con...

How to make a "calculated attribute" for a C++ class using templates.

I'm trying to implement generic method to put in a class a calculated value as a read-only memver value. I've successfuly acomplished it using the following macro: #define READONLY_PROPERTY(datatype, containerclass, access, name)\ class name ## _ ## datatype ## _ROP {\ public:\ name ## _ ## datatype ## _ROP(containerclass &c_):...

Two versions of Perl in Mac OS X?

I've installed the Template module via CPAN on my MacBook Pro and it seemed to install correctly. But, when I try to run a script that includes the Template module, I get the following: Can't locate Template.pm in @INC (@INC contains: /Users/purinkle/Sites/rob/modules /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/...

inheriting from a template class causes errors

I have a template class MyTemplate. It works fine. But as soon as I create another class that derives from it, I get errors. //main.cpp template <typename T> class MyTemplate { public: T* test() { return new T(this); //error here. } }; template <typename T> class MyTemplate2 : public MyTemplate<T> { }; ...

validates_presence_of and with templates ruby on rails

I'm trying to validate some ratio buttons making sure the user as selected one of them. I do this by using: validates_presence_of In addition, I have specific template that I use for the page's layout. Normally, without the template layout, The anything that is missing is highlighted automatcially by the validates_pressense_of helper...

How can I make a simple counter with Jinja2 templates?

I have two for loops, both alike in dignity. I'd like to have a counter incremented during each inner iteration. For example, consider this template: from jinja2 import Template print Template(""" {% set count = 0 -%} {% for i in 'a', 'b', 'c' -%} {% for j in 'x', 'y', 'z' -%} i={{i}}, j={{j}}, count={{count}} {% set count =...

differences in two images/ check (tick) detection

i got a questionnaire with check boxes inside. now i would like to match a template of the questionnaire and filled out questionnaire (out of my webcam)... i already did a template matching to find the questionnaire in the webcam image and did a back transformation to the original template.. now my problem is, how to find the checks insi...

Are there any major shortcomings to using Sun's JSP template solution?

This is 10 years old, but still appears to be one of the most widely accepted JSP template solutions. Is this still a viable approach for basic templates? http://java.sun.com/developer/technicalArticles/javaserverpages/jsp_templates/ I've heard some developers discuss Tiles, but from what I can tell the biggest benefit of tiles is that...

Problem with conversion

I have a class: template<class T> class MyClass { public: class Iterator { public: Iterator(MyClass<T>&){/*some code*/}; }; operator Iterator(); Iterator& begin(); }; template<class T> MyClass<T>::operator typename MyClass<T>::Iterator() { ret...

c++ template of template

#include "boost/numeric/ublas/matrix.hpp" using namespace boost::numeric::ublas; template <class matrixform,class input_T> class Layer { private: matrixform <input_T>; public: }; I want to be able to do int main () { Layer<identity_matrix, double> mylayer; } BUT layer.hpp:18: error: ‘matrixform’ is not a template layer.h...

When the virtual member functions of a template class instantiated?

I know that the normal member function of an template class will be instantiated whenever it is used for the first time. But this cannot be done for the virtual member function as it can be accessed through base class pointer. This means that virtual member functions will be instantiated as soon as the tmeplate class is instantiated? If ...

C++: Using enum as template type argument

Hi, are there any restrictions / problems using an enum as template (type) argument in C++? Example: enum MyEnum { A, B, C, D, E }; template <typename _t> class MyTemplate { public: _t value; void func(const _t& param) { /* .... */ } }; // .... MyTemplate<MyEnum> MyInstance; My actual problem using MSVC++ via VS 2008...

Nested templates and constructor

Hi everybody! Edit: Note that my final purpose here is not having the class working, is just learning more about templates :-) Suppose you have a template class which implements a vector: template <typename T> class Vector { public: Vector(size_t dim) { dimension = dim; elements = new T[dim]; ...