templates

Xcode template <<date>> format

I'm working up a custom Xcode template, and I'd like to change the way <<date>> is formatted. For example: // Created by «FULLUSERNAME» on «DATE». // Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved. if the file was created today would fill as: // Created by SooDesuNe on 2/24/2010. // Copyright 2010 MyOrganization. All r...

Can I extract struct or public class members using a template?

Basically, I have lots of differently typed structs like this: typedef struct { char memberA; int memberB; ... } tStructA; Is it possible to use a template to get/extract an arbitrary member from the struct? In pseudocode, I'm looking for something like this: /*This is pseudocode!*/ template <typename STRUCT_TYPE, typenam...

What's the purpose of boost::detail::addr_impl_ref ?

Inside boost there's boost::detail::addr_impl_ref struct that basically has a constructor accepting a T& reference and an overloaded operator T&() that returns that reference. It is used in the implementation of boost::addressof(): template<class T> T* addressof( T& v ) { return boost::detail::addressof_impl<T>::f( boost::detail::ad...

What are the real advantages of templating engines over just using PHP?

I develop my web applications using only PHP for the view files and I don't feel limited in any way, but I hear there's a consistent number of developers advocating "external" templating engines. So what do template engines offer that simple PHP lacks? I'm looking for practical things, so I exclude the following: babysitting bad devel...

Layout difficulties in ListBoxItem ContentPresenter Template

Good day, I am populating a ListBox withe Shipment objects and I am using an ItemContainerStyle to define how I want the items displayed. Everything is working smoothly with one exception. The template uses a Grid that is inside of two borders. The grid has 7 columns, the last is specified to contain a border that will end up being a...

intellij file templates - scripting possible?

I like the idea of creating file templates for common functionality - for example having a controller template that gives you a subbed out controller. What i am looking for is the ability to do some scripting in the template, for example i can have the controller name be input by the user: ${CONTROLLER_NAME} but then later i might wan...

(How) Can I use string substitution for working w/ Django’s i18n {% trans %} tag?

I'm looking for something like this: {% trans "There are %{flowers}n flowers in the vase" < flowers:3 %} Now obviously syntax is fake, but it should be sufficient to demonstrate what I'm looking for. Should I cook something of my own? It looks like a common usecase, so I was quite surprised that quick web search didn't return anythi...

Does ANSI C support ‘templates?’

I’m taking a C++ class, and my teacher mentioned in passing that the typename keyword existed in C++ (as opposed to using the class keyword in a template declaration), for backwards compatibility with “C templates.” This blew my mind. I’ve never seen or heard tell of anything like C++’s templates (except, perhaps, the preprocessor… and ...

Is it a bad idea to change the app_label assignment on existing Django models?

I have the hair-brained idea of grouping models from different existing apps into one big new shiny app. There's not a super important reason I need to do this, but it would be nice to consolidate all of the code in one subdirectory and it would improve the site to group all the models together in the admin_index under the same module he...

Inheriting off of a list of templated classes, when supplied with the list of template arguments

I'm trying to write some metaprogramming code such that: Inheriting from some class foo<c1, c2, c3, ...> results in inheritance from key<c1>, key<c2>, key<c3>, ... The simplest approach doesn't quite work because you can't inherit from the same empty class more than once. Handling the "..." portion isn't pretty (since it's copy-pasta),...

What java view technology is this?

It seems velocity and freemarker look fairly similiar, at least for basic usage. Anyhow, what is the "built in" or standard view framework called? It looks like: <c:if test="${someobject.property != null}"> ...

Django url address n't saving into db

I have many fields in my template so,from the front end,when i omit URL field and enter data in to the other field ,the data is getting saved into my db,but when i enter URL field with all other field ,it is not getting to db. Where might ,be i m doing mistake? ...

WPF toggle buttons with custom template not accepting click in correct area

I'm a relative beginner in the WPF space so I'm sure this will be the first of many questions! I have a series of toggle buttons all with a custom template designed to show an image with a transparent background that then becomes highlighted when the user toggles the button. I wanted to add padding around the content so that the highlig...

How do I apply a "template" or "skeleton" of code in C# here?

In my business layer, I need many, many methods that follow the pattern: public BusinessClass PropertyName { get { if (this.m_LocallyCachedValue == null) { if (this.Record == null) { this.m_LocallyCachedValue = new BusinessClass( this.Database, this.Pro...

static member initialization for specialized template class

class A { }; template <typename A, int S> class B { public: static int a[S]; B() { a[0] = 0; } }; template<> int B<A, 1>::a[1]; int main() { B<A, 1> t; t; } It compiles under GCC 4.1, but does not link: static.cpp:(.text._ZN1BI1ALi1EEC1Ev[B<A, 1>::B()]+0x5): undefined...

C++ templated functor in lambda expression

This first piece has been solved by Eric's comments below but has led onto a secondary issue that I describe after the horizontal rule. Thanks Eric! I'm trying to pass a functor that is a templated class to the create_thread method of boost thread_group class along with two parameters to the functor. However I can't seem to get beyond m...

Reference a Map by name within Velocity Template

Pretty sure there is an easy answer to this, but just can't find the right VTL syntax. In my context I'm passing a Map which contains other Maps. I'd like to reference these inner maps by name and assign them within my template. The inner maps are constructed by different parts of the app, and then added to the context by way of exampl...

Create derived class instance from a base class instance without knowing the class members.

Is this scenario even possible? class Base { int someBaseMemer; }; template<class T> class Derived : public T { int someNonBaseMemer; Derived(T* baseInstance); }; Goal: Base* pBase = new Base(); pBase->someBaseMemer = 123; // Some value set Derived<Base>* pDerived = new Derived<Base>(pBase); The value of pDerived->someBase...

Can C++ policy classes be used to specify existence / non-existence of constructors?

Suppose I have: struct Magic { Magic(Foo* foo); Magic(Bar* bar); }; Is there a way to make Magic a template, and define template classes s.t. typedef Magic<FooPolicy, ...> MagicFoo; typedef Magic<BarPolicy, ...> MagicBar; typedef Magic<..., ...> MagicNone; typedef Magic<FooPolicy, BarPolicy> MagicAll; s.t. MagicFoo & MagicAll h...

How do I fix class template has already been defined?

I am implementing ZipArchive library into my project, and I fought with it for over an hour getting it setup right to stop all the linker errors. But now I still have this left over and I am not sure of the best approach to fix it, could use some help. C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxtls_.h(199) : error...